DTParticipant
New
Hello,
I would need some help to create the code for a breakout system. If I would like to go long/short the cable after it have created a 2h-range between 8-10 in the morning and then exit 24 hours later.
Stoploss and entry in the other direction should be at the same level.
I´m learning how to code right now but are not good enough to create this yet…Would be really happy if anyone could help!
Thanks!
WingParticipant
Veteran
Assuming for example you use the 15m timeframe, something like this?
defparam cumulateorders=0
once RangeHigh=10000000
once RangeLow=0
If time=100000 then
RangeHigh=Highest[8](high)
RangeLow=Lowest[8](low)
endif
If Time=PositionTime then
sell at market
exitshort at market
endif
if time>100000
if close>RangeHigh and onmarket=0 then
buy 1 lot at market
PositionTime=Time
set stop loss close-rangelow
endif
if close<RangeLow and onmarket=0 then
sellshort 1 lot at market
set stop loss rangehigh-close
PositionTime=Time
endif
endif
Thank you Wing for your invaluable help in answering the requests of the forum members, it helps me enormously and I am very grateful to you. You deserve the blue badge of ‘best contributor’ 🙂