//Modified system by EZ - 20th Dec 2017
DEFPARAM CumulateOrders = True // Cumulative orders allowed.
DEFPARAM FlatBefore = 060000 // Cancel any pending orders, close any positions and prevent placement of additional orders.
DEFPARAM FlatAfter = 210000 // Cancel any pending orders, close any positions and prevent placement of additional orders.
Size = 10 //position size
StopLoss = 10 //stoploss in points
TakeProfit = 20 //takeprofit in points
Xcandlesticks = 3 //consecutive bullish or bearish candlesticks to open a new position
Xcandlesticks1 = 1
InverseTrading = 0 //(0=false ; 1=true) trade in the same direction of the candlesticks pattern or not
//Flapping based on low double deviation
doubdev = 4*STD[2](close)
//detecting patterns
bearpattern = summation[Xcandlesticks](close<open)=Xcandlesticks
bullishpattern = summation[Xcandlesticks](close>open)=Xcandlesticks
bearpattern1 = summation[Xcandlesticks1](close<open)=Xcandlesticks
bullishpattern1 = summation[Xcandlesticks1](close>open)=Xcandlesticks
//first order - buy
if not onmarket and doubdev > 5 then
if bearpattern then
if InverseTrading then
BUY Size CONTRACTS AT MARKET
else
SELL Size CONTRACTS AT MARKET
endif
endif
endif
if bullishpattern then
if InverseTrading then
SELL Size CONTRACTS AT MARKET
else
BUY Size CONTRACTS AT MARKET
endif
endif
//first order - sell
if longonmarket and bearpattern1 then
SELL Size CONTRACTS AT MARKET
endif
if shortonmarket and bullishpattern1 then
BUY Size CONTRACTS AT MARKET
endif
SET STOP LOSS StopLoss
SET TARGET PPROFIT TakeProfit