Central Bank Dealers Range – Reversal strategy Help please!
Forums › ProRealTime English forum › ProBuilder support › Central Bank Dealers Range – Reversal strategy Help please!
- This topic has 30 replies, 5 voices, and was last updated 4 months ago by crolakstrading.
-
-
06/01/2024 at 3:55 PM #233377
druby is right, change those lines as recommended. This change will still keep your SL changing every candle.
If you want to set your SL only once, I recommend adding these lines at the beginning of your code (in between lines 1 and 2):
123456IF LongOnMarket AND Not LongOnMarket[1] THENSET STOP LOSS StopLoss1ENDIFIF ShortOnMarket AND Not ShortOnMarket[1] THENSET STOP LOSS StopLossENDIFthis will set your SL according to the values retained when the pending order was set (the prior candle).
If you want to set your SL according to the values set when the order was triggered (the currently closed candle), then add those lines in between lines 52 and 53, instead.
2 users thanked author for this post.
06/02/2024 at 1:24 AM #233383Hi druby and robertogozzi,
I have tried adding as robberto mentioned but did not change anything and still the same.
Once the long or the short entry is triggered, SL or TP must not change. should stay the same but it should not go till the next trade. is it possible to cancel everything maybe just before at 19.00. means will exit the whole trade with a loss or a profit as SL or the TP not hit. and everything to be calculated fresh as a new trade from 1900-0100 next day? seems like this one goes on until the SL or the TP hit? Please correct me if I’m wrong.
I have added the same example EURUSD – May 14th still entered and exit at the same time.
Robberto's update123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778DEFPARAM CumulateOrders = FalseIF LongOnMarket AND Not LongOnMarket[1] THENSET STOP LOSS StopLoss1ENDIFIF ShortOnMarket AND Not ShortOnMarket[1] THENSET STOP LOSS StopLossENDIFstarttime = 191500endtime = 011500trigTime = 100000 // added!//------------------------------------------------------ open data windowif time = starttime and startFlag = 0 thenstartFlag = 1startBar = barindexhh = 0ll = 0endFlag = 0trigFlag = 0endif//------------------------------------------------------ update hh/ll while in window openif startFlag = 1 thenif high > hh thenhh = highendifif low < ll or ll = 0 thenll = lowendifendif//------------------------------------------------------ close data windowif time = endTime and startFlag = 1 and endFlag = 0 thenendFlag = 1endBar = barindexstartFlag = 0elsif startFlag = 1 thenendbar = barindexendif//------------------------------------------------------ when window closedif endFlag = 1 thendif = hh-llfib38 = hhfib0 = llendif//------------------------------------------------------ when trigger time reachedif time >= trigTime and startFlag = 0 and endFlag = 1 then // added! +2 linestrigFlag = 1endifEntryPrice = (fib38-fib0)*2.5+fib0EntryPrice1 = (fib0-fib38)*1.5+fib0StopLoss = (fib38-fib0)*3.0050+fib38StopLoss1 = (fib0-fib38)*3.0050+fib0takeprofit = (fib38-fib0)/2+fib0 //changedtakeprofit1 = (fib0-fib38)/2+fib0 //changed!// Conditions to enter Short positionsIF NOT ShortOnMarket AND startFlag = 0 and endFlag = 1 and trigFlag = 0 then // changed!SEllSHORT 1 CONTRACTS AT EntryPrice LIMITENDIFIF OnMarket THENSET STOP LOSS StopLossEndifSet Target pProfit takeprofit// Conditions to enter long positions//IF NOT LongOnMarket AND >tradingtime< and >value2< THEN //????? was this line in error ---If NOT LongOnMarket AND startFlag = 0 and endFlag = 1 and trigFlag = 0 then // changed and added!BUY 1 CONTRACTS AT EntryPrice1 LIMITENDIFIF OnMarket THENSET STOP LOSS StopLoss1ENDIFSet Target pProfit takeprofit1I really appreciate all of your attention, thank you once again.
06/02/2024 at 9:08 AM #23339206/02/2024 at 10:02 AM #233394Hi JS,
Your Pic example shows exactly what should happen. should this change to calculate values instead of percentages if it doesn’t work on spread betting? 🙁
06/02/2024 at 10:15 AM #233396It will make no difference…
1 user thanked author for this post.
06/02/2024 at 10:17 AM #233397Hi,
(Intra) Day starts at 00:00
First action at 01:00: determine the range (HH-LL) over the last six hours…
(Six hours corresponds to the time between yesterday 19:00 and today 01:00)
You only set a new range when there is no position open, this to prevent the SL and TP from changing while a position is open…
If OpenTime=010000 and NOT OnMarket then
HH=Highest[24](High)
LL=Lowest[24](Low)
diff=HH-LL
Level0=HH
Level100=LL
EndIf
Second action runs from 01:00 to 10:00
Positions can be opened in this time slot, but only if there is no open position yet…
If Time>010000 and Time<100000 and NOT OnMarket then
If Low<Level0-(Diff*Mult) then
Buy 1 contract at Market
EndIf
If Close>Level100+(Diff*Mult) then
SellShort 1 contract at Market
EndIf
Set Stop Loss SL*Diff
Set Target Profit TP*Diff
EndIf
That’s it…
Reversal Strategy V2123456789101112131415161718192021222324252627282930313233DefParam CumulateOrders=FalseIf OpenTime=010000 and NOT OnMarket thenHH=Highest[24](High)LL=Lowest[24](Low)Diff=HH-LLLevel0=HHLevel100=LLEndIfIf Time>010000 and Time<100000 and NOT OnMarket thenIf Low<Level0-(Diff*Mult) thenBuy 1 contract at MarketEndIfIf Close>Level100+(Diff*Mult) thenSellShort 1 contract at MarketEndIfSet Stop Loss SL*DiffSet Target Profit TP*DiffEndIf//GraphOnPrice HH as "HH"//GraphOnPrice LL as "LL"GraphOnPrice Level0 as "Level0"GraphOnPrice Level100 as "Level100"Graph Diff as "Diff"GraphOnPrice (Level0-(Diff*Mult)) as "EntryLong" coloured("Green")GraphOnPrice (Level100+(Diff*Mult)) as "EntryShort" coloured("Green")GraphOnPrice (Level0-(Diff*Mult))-(SL*Diff) as "SLLong" coloured("Red")GraphOnPrice (Level100+(Diff*Mult))+(SL*Diff) as "SLShort" coloured("Red")GraphOnPrice (Level0-(Diff*Mult))+(TP*Diff) as "TPLong" coloured("Blue")GraphOnPrice (Level100+(Diff*Mult))-(TP*Diff) as "TPShort" coloured("Blue")2 users thanked author for this post.
06/02/2024 at 10:34 AM #233398If you want to see the same values as on my screenshot, use:
DefParam CumulateOrders=False
Mult=2.5
SL=1.5
TP=2
If OpenTime=010000 and NOT OnMarket then
…1 user thanked author for this post.
06/03/2024 at 1:13 AM #233412Hi JS,
It works nicely… only one or two entries are in different values! thanks very much I’m happy at least to develop this strategy to this level!
I noticed something on EURUSD 17MAY – SL hit at 9.30am and then at 9.45am another long trade gets triggered. is this because it’s before 10am? how to cancel that? same thing has happen on the 17MAR! Please see attached example. How to avoid this please? Please see attached example
1234567891011121314151617181920212223242526272829303132333435DefParam CumulateOrders=FalseMult=2.5SL=1.5TP=2If OpenTime=010000 and NOT OnMarket thenHH=Highest[24](High)LL=Lowest[24](Low)Diff=HH-LLLevel0=HHLevel100=LLEndIfIf Time>010000 and Time<100000 and NOT OnMarket thenIf Low<Level0-(Diff*Mult) thenBuy 1 contract at MarketEndIfIf Close>Level100+(Diff*Mult) thenSellShort 1 contract at MarketEndIfSet Stop Loss SL*DiffSet Target Profit TP*DiffEndIf//GraphOnPrice HH as "HH"//GraphOnPrice LL as "LL"GraphOnPrice Level0 as "Level0"GraphOnPrice Level100 as "Level100"Graph Diff as "Diff"GraphOnPrice (Level0-(Diff*Mult)) as "EntryLong" coloured("Green")GraphOnPrice (Level100+(Diff*Mult)) as "EntryShort" coloured("Green")GraphOnPrice (Level0-(Diff*Mult))-(SL*Diff) as "SLLong" coloured("Red")GraphOnPrice (Level100+(Diff*Mult))+(SL*Diff) as "SLShort" coloured("Red")GraphOnPrice (Level0-(Diff*Mult))+(TP*Diff) as "TPLong" coloured("Blue")GraphOnPrice (Level100+(Diff*Mult))-(TP*Diff) as "TPShort" coloured("Blue")Thanks again to everyone developing this strategy. Even though the original strategy is about Central Banks Dealers Range at 19.00-1.00 ! it gets very interesting when you change the time ranges in different markets.
06/03/2024 at 9:31 AM #233416That’s right, between Time>010000 and Time<100000, the system is free to open and close positions… I have changed the code so that only 1 trade is opened per day…
A few points to consider…
In line 14 “If Low<…” you can use the “Close” or the “Low”
In line 18 “If Close>…” you can use the “Close” or the “High”
Good luck with your system…
Reversal Strategy V312345678910111213141516171819202122232425262728293031323334353637383940414243444546DefParam CumulateOrders=FalseMult=2.5SL=1.5TP=2MaxTrades=1 //One Trade a DayIf IntraDayBarIndex=0 thenLongTally=0ShortTally=0EndIfIf OpenTime=010000 and NOT OnMarket thenHH=Highest[24](High)LL=Lowest[24](Low)Diff=HH-LLLevel0=HHLevel100=LLEndIfIf Time>010000 and Time<100000 and NOT OnMarket thenIf Low<Level0-(Diff*Mult) and LongTally<MaxTrades thenBuy 1 contract at MarketLongTally=LongTally+1EndIfIf Close>Level100+(Diff*Mult) and ShortTally<MaxTrades thenSellShort 1 contract at MarketShortTally=ShortTally+1EndIfSet Stop Loss SL*DiffSet Target Profit TP*DiffEndIf//GraphOnPrice HH as "HH"//GraphOnPrice LL as "LL"GraphOnPrice Level0 as "Level0"GraphOnPrice Level100 as "Level100"//Graph Diff as "Diff"GraphOnPrice (Level0-(Diff*Mult)) as "EntryLong" coloured("Green")GraphOnPrice (Level100+(Diff*Mult)) as "EntryShort" coloured("Green")GraphOnPrice (Level0-(Diff*Mult))-(SL*Diff) as "SLLong" coloured("Red")GraphOnPrice (Level100+(Diff*Mult))+(SL*Diff) as "SLShort" coloured("Red")GraphOnPrice (Level0-(Diff*Mult))+(TP*Diff) as "TPLong" coloured("Blue")GraphOnPrice (Level100+(Diff*Mult))-(TP*Diff) as "TPShort" coloured("Blue")1 user thanked author for this post.
06/06/2024 at 12:34 AM #233571Hi @JS,
Thanks very much again.. I have been checking this it works great I think. I changed the line 28 If Close> to If High>
Some entries both short or long are a bit different. example EURUSD 17MAy it triggers 2 pips above. so instead of hitting TP it goes to SL. This might be a stupid question but is this because of the spread? please see below pic.
Thank yo
Central banks dealers range!12345678910111213141516171819202122232425262728293031323334353637383940414243444546DefParam CumulateOrders=FalseMult=2.5SL=1.5TP=2MaxTrades=1 //One Trade a DayIf IntraDayBarIndex=0 thenLongTally=0ShortTally=0EndIfIf OpenTime=010000 and NOT OnMarket thenHH=Highest[24](High)LL=Lowest[24](Low)Diff=HH-LLLevel0=HHLevel100=LLEndIfIf Time>010000 and Time<100000 and NOT OnMarket thenIf Low<Level0-(Diff*Mult) and LongTally<MaxTrades thenBuy 1 contract at MarketLongTally=LongTally+1EndIfIf high>Level100+(Diff*Mult) and ShortTally<MaxTrades thenSellShort 1 contract at MarketShortTally=ShortTally+1EndIfSet Stop Loss SL*DiffSet Target Profit TP*DiffEndIf//GraphOnPrice HH as "HH"//GraphOnPrice LL as "LL"GraphOnPrice Level0 as "Level0"GraphOnPrice Level100 as "Level100"//Graph Diff as "Diff"GraphOnPrice (Level0-(Diff*Mult)) as "EntryLong" coloured("Green")GraphOnPrice (Level100+(Diff*Mult)) as "EntryShort" coloured("Green")GraphOnPrice (Level0-(Diff*Mult))-(SL*Diff) as "SLLong" coloured("Red")GraphOnPrice (Level100+(Diff*Mult))+(SL*Diff) as "SLShort" coloured("Red")GraphOnPrice (Level0-(Diff*Mult))+(TP*Diff) as "TPLong" coloured("Blue")GraphOnPrice (Level100+(Diff*Mult))-(TP*Diff) as "TPShort" coloured("Blue")u in advance.
06/06/2024 at 7:36 AM #233573On May 17, the “EntryLong” is 1.085480, the “Low” (you have to look at the bar before the entry) is 1.08544 so a long position will be opened on the “Open” of the next bar (1.08557) …
So, it’s exactly right and has nothing to do with the (unused) spread… 🙂
1 user thanked author for this post.
06/11/2024 at 2:05 PM #23374306/11/2024 at 2:33 PM #233747Currently, the orders that are used in your system are “market orders”…
These orders will never open exactly on the drawn lines because they open on the “Open” of the next bar…
If you do want to have an exact execution on the lines, you will have to use a different type of order, for example “limit orders”…
1 user thanked author for this post.
06/11/2024 at 6:48 PM #233769HI @JS,
yeah the lines show exact execution but entries are little bit different. how can we change it to “limit orders”? to get exact entry as the line? this will make the 17th loss in to a profit.
12345678910111213If Time>010000 and Time<100000 and NOT ONMARKET thenIf Low<Level0-(Diff*Mult) and LongTally<MaxTrades thenBuy 1 contract AT close LIMITLongTally=LongTally+1EndIfIf high>Level100+(Diff*Mult) and ShortTally<MaxTrades thenSellShort 1 contract AT close LIMITShortTally=ShortTally+1EndIfSet Stop Loss SL*DiffSet Target Profit TP*DiffEndIftried but clearly i’m doing it wrong!!
06/13/2024 at 2:38 PM #233841Here is the system based on “Limit” orders instead of “Market” orders…
Reversal Strategy V51234567891011121314151617181920212223242526272829303132333435363738394041424344454647TimeFrame(15 minutes)Mult=2.5SL=1.5TP=2MaxDayTrades=1If IntraDayBarIndex=0 thenDayTrades=0EndIfIf OpenTime=010000 and NOT OnMarket thenHH=Highest[24](High)LL=Lowest[24](Low)Diff=HH-LLLevel0=HHLevel100=LLSet Stop Price 0Set Target Price 0EndIfIf Time>010000 and Time<100000 and NOT OnMarket and DayTrades=0 thenBuy 1 contract at (Level0-(Diff*Mult)) LimitSellShort 1 contract at (Level100+(Diff*Mult)) LimitEndIfIf LongOnMarket thenSet Stop Price (Level0-(Diff*Mult))-(SL*Diff)Set Target Price (Level0-(Diff*Mult))+(TP*Diff)DayTrades=1EndIfIf ShortOnMarket thenSet Stop Price (Level100+(Diff*Mult))+(SL*Diff)Set Target Price (Level100+(Diff*Mult))-(TP*Diff)DayTrades=1EndIfGraphOnPrice Level0 as "Level0"GraphOnPrice Level100 as "Level100"GraphOnPrice (Level0-(Diff*Mult)) as "EntryLong" coloured("Green")GraphOnPrice (Level100+(Diff*Mult)) as "EntryShort" coloured("Green")GraphOnPrice (Level0-(Diff*Mult))-(SL*Diff) as "SLLong" coloured("Red")GraphOnPrice (Level100+(Diff*Mult))+(SL*Diff) as "SLShort" coloured("Red")GraphOnPrice (Level0-(Diff*Mult))+(TP*Diff) as "TPLong" coloured("Blue")GraphOnPrice (Level100+(Diff*Mult))-(TP*Diff) as "TPShort" coloured("Blue")1 user thanked author for this post.
-
AuthorPosts