DEFPARAM CumulateOrders = False
Timeframe(Daily,UpdateOnClose)
ONCE setup = 0
ONCE Distanza = 7
//
// PATTERN
c1 = Close[0] > Open[0] // 4° giornata: rialzista
c2 = Close[1] < Open[1] // 3° giornata: ribassista
c3 = Close[2] < Open[2] // 2° giornata: ribassista
c4 = Close[3] < Open[3] // 1° giornata: ribassista
//
//
IF OnMarket THEN
setup = 0
ENDIF
//
if c1 and c2 and c3 and c4 and Not OnMarket then // se tutte le condizioni sono verificate
gg = OpenDay
setup = 1
entry = high + 1*pipsize
sl = (entry - (lowest[4](low) - 2*pipsize)) * 1.4
tp = sl //entry * 0.04
SET TARGET PROFIT tp
SET STOP LOSS sl
endif
IF Not OnMarket AND ((low <= (entry - sl)) OR (OpenDay <> gg)) THEN
setup = 0
ENDIF
//
Timeframe(default)
IF setup AND Not OnMarket THEN
IF close < (entry - Distanza) THEN
BUY 1 CONTRACT AT Entry STOP
ELSIF close > (entry + Distanza) THEN
BUY 1 CONTRACT AT Entry LIMIT
ELSE
//BUY 1 CONTRACT AT MARKET
ENDIF
ENDIF
//
graphonprice entry
graphonprice entry - sl coloured(255,0,0,255)
graphonprice entry + tp coloured(0,0,255,255)
graph setup