//PRC_TS multiple candlesticks | indicator
//01.03.2017
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
// --- parameters
Size = 1 //position size
StopLoss = 20 //stoploss in points
TakeProfit = 10 //takeprofit in points
Xcandlesticks = 3 //consecutive bullish or bearish candlesticks to open a new position
InverseTrading = 0 //(0=false ; 1=true) trade in the same direction of the candlesticks pattern or not
CumulateOrder = 0 //(0=false ; 1=true) cumulate or not a new trade if the current candlestick is in the same trend as the pattern
// ------------
//HA candles
// Heikin Ashi setup
once xOpen = open
xClose = (open + close + high + low) / 4
if barindex > 0 then
xOpen = (xOpen + xClose[1]) / 2
endif
//detecting patterns
bearpattern = summation[Xcandlesticks](xclose<xopen)=Xcandlesticks
bullishpattern = summation[Xcandlesticks](xclose>xopen)=Xcandlesticks
//first order
if not onmarket then
if bearpattern then
if InverseTrading then
BUY Size CONTRACTS AT MARKET
else
SELLSHORT Size CONTRACT AT MARKET
endif
lastbar = barindex
lastpattern = -1
endif
if bullishpattern then
if InverseTrading then
SELLSHORT Size CONTRACT AT MARKET
else
BUY Size CONTRACTS AT MARKET
endif
lastbar = barindex
lastpattern = 1
endif
endif
//cumulate order when a new pattern occurred
if onmarket and not CumulateOrder and barindex-lastbar>=Xcandlesticks then
if bearpattern then
if InverseTrading then
BUY Size CONTRACTS AT MARKET
else
SELLSHORT Size CONTRACT AT MARKET
endif
lastbar = barindex
endif
if bullishpattern then
if InverseTrading then
SELLSHORT Size CONTRACT AT MARKET
else
BUY Size CONTRACTS AT MARKET
endif
lastbar = barindex
endif
endif
//cumulate order when a new consecutive candletick happen right after the pattern occurred
if onmarket and CumulateOrder and barindex-lastbar=1 then
if longonmarket then
if (close>open and lastpattern=1) or (close<open and lastpattern=-1) then
BUY Size CONTRACTS AT MARKET
lastbar = barindex
endif
endif
if shortonmarket then
if (close>open and lastpattern=1) or (close<open and lastpattern=-1) then
SELLSHORT Size CONTRACT AT MARKET
lastbar = barindex
endif
endif
endif
SET STOP PLOSS StopLoss
SET TARGET PPROFIT TakeProfit