Breakout Strategy help with my code
- This topic has 4 replies, 2 voices, and was last updated 8 years ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
Similar topics:
Forums › ProRealTime English forum › ProOrder support › Breakout Strategy help with my code
Hello
looking for some help on the strategy below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
DEFPARAM CumulateOrders = false // Cumulating positions DEFPARAM PRELOADBARS = 1000 DEFPARAM FLATAFTER = 220000 IF Time = 080000 THEN TradeCounter = 0 ENDIF // Trading Hours IF (Time >= 090000 AND Time <= t1) and dayofweek<=5 then// or (Time >= 220000 AND Time <= 220100) and dayofweek=1 THEN // Tradetime=1 else Tradetime=0 endif t1=220000 //Settings once upper=0 once lower=0 // calculate upper and lower endtime = 090000 If Time = endtime then upper=highest[12](high) lower=lowest[12](low) dif=round(abs((lower-upper)*pipsize*pointvalue)) endif //looking for short position entershort1 = close[1] > upper entershort2 = close crosses under upper entershort3 = close < upper if not onmarket and entershort1 and entershort2 and entershort3 then fadeshort=1 elsif onmarket then fadeshort=0 endif if not onmarket and tradecounter < 1 and tradetime and fadeshort then sellshort 5 contracts at market TradeCounter = TradeCounter + 1 endif set stop loss dif set target profit lower |
Hi Abz, your code seems a bit “scrambled”, I think you did a lot of debugging and copy/paste 🙂
I changed a bit some of the lines and added some variables too (still only short position):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
DEFPARAM CumulateOrders = false // Cumulating positions DEFPARAM PRELOADBARS = 1000 DEFPARAM FLATAFTER = 220000 IF Time = 080000 THEN TradeCounter = 0 ENDIF // Trading Hours t1=220000 tradetime=Time >= 090000 AND Time <= t1 and dayofweek<=5 // calculate upper and lower endtime = 090000 If Time = endtime then upper=highest[12](high) lower=lowest[12](low) dif=upper-lower endif //looking for short position entershort= close[1] crosses under upper and high<upper and close<upper if not onmarket and tradecounter < 1 and tradetime and entershort then sellshort 5 contracts at market tp = close-lower TradeCounter = TradeCounter + 1 endif set stop loss dif set target profit tp |
Please consider that I did not test this code, please do your own tests, thank you.
Thanks Nicolas the code looks much better 🙂
for long will this work? i tried it and i dont get the entry points i am looking for.
1 2 3 4 5 6 7 8 |
//looking for Long position enterlong= close[1] crosses over lower and low>lower and close>lower if not onmarket and tradecounter < 1 and tradetime and enterlong then buy 5 contracts at market tp = close-upper TradeCounter = TradeCounter + 1 endif |
Find exclusive trading pro-tools on