//-------------------------------------------------------------------------
// Main code : ryd range box 1-2 min US30 DOW
//-------------------------------------------------------------------------
DEFPARAM CumulateOrders = FALSE
Timeframe(default)
ONCE PL = 130.0
ONCE SL = 60.0
ONCE t = 50.0
ONCE tS = 50.0
ONCE x = 40.0
ONCE y = 1.0
IF Not OnMarket THEN
MyExit = 0
ELSE
c1 = 0
ENDIF
Timeframe(Daily,UpdateOnClose)
// ADR Average Daily Range
MyADR = average[20,0](range)
//
Timeframe(default)
IF (Time = 000000) OR ((Time > 000000) AND (Time < Time[1])) THEN
MyHI = high
MyLO = low
c1 = 0
ENDIF
IF Time <= 142900 THEN
MyHI = max(MyHI,high)
MyLO = min(MyLO,low)
MyRange = MyHI - MyLO
c1 = ((MyRange / MyADR) * 100) < x //75
ENDIF
IF Time >= 142900 AND c1 THEN
BUY 0.2 Contract AT MyHI + y * pipsize STOP
SELLSHORT 0.2 Contract AT MyLO - y * pipsize STOP
SET TARGET pPROFIT PL //40
SET STOP pLOSS SL //80
ENDIF
IF MyExit = 0 THEN
IF (LongOnMarket AND (close - TradePrice) >= t * pipsize) OR (ShortOnMarket AND (TradePrice - close) >= tS * pipsize) THEN //27.5 37.5
MyExit = TradePrice
ENDIF
ENDIF
IF MyExit > 0 THEN
SELL AT MyExit STOP
EXITSHORT AT MyExit STOP
ENDIF
//GraphOnPrice TradePrice coloured(0,0,255,255)
//GraphOnPrice MyHI coloured(0,128,0,200)
//GraphOnPrice MyLO coloured(255,0,0,255)
//Graph close - TradePrice
//Graph c1
//Graph MyADR
//Graph MyRange