defparam preloadbars=200
DEFPARAM CumulateOrders = False
DEFPARAM FLATbefore = 073000
DEFPARAM FLATafter = 183000
startrade=090000
stoptrade=173000
once numcontr=0.5
timeframe(15 minutes)
HT15 = CALL "PRC_HalfTrend"[2]
timeframe(5 minutes,updateonclose)
HT05x = CALL "PRC_HalfTrend"[2]
LSMA05=EndPointAverage[7](close)
EMA05=ExponentialAverage[4](close)
CCI05=CCI[14](typicalPrice)
timeframe(5 minutes)
HT05 = CALL "PRC_HalfTrend"[2]
timeframe(default,updateonclose) // 1 min
xbuy=0
xsell=0
exitlg=0
exitsh=0
HT = CALL "PRC_HalfTrend"[2]
LSMA=EndPointAverage[7](close)
if LSMA>HT and LSMA>HT05 and LSMA>HT15 then
xbuy=1
elsif LSMA<HT and LSMA<HT05 and LSMA<HT15 then
xsell=1
endif
if ShortOnMarket then
//if ..... then
//exitsh=1
elsif LongOnMarket then
//if ..... then
//exitlg=1
endif
stopd=50
if not onmarket and time >= startrade and time <= stoptrade then
IF xbuy then
BUY numcontr CONTRACTS AT MARKET
SET STOP PTRAILING stopd
elsIF xsell then
sellSHORT numcontr contrACTS AT MARKET
SET STOP PTRAILING stopd
endif
endif
IF LongOnMarket then
if xsell and time >= startrade and time <= stoptrade then
sell at market
sellSHORT numcontr contrACTS AT MARKET
SET STOP PTRAILING stopd
elsIF exitlg then
sell at market
endif
ENDIF
IF ShortOnMarket then
IF xbuy and time >= startrade and time <= stoptrade then
exitshort at market
BUY numcontr CONTRACTS AT MARKET
SET STOP PTRAILING stopd
elsIF exitsh then
exitshort at market
ENDIF
ENDIF
GRAPH 0 COLOURED (0,250,0) as "0"
GRAPH CCI05 COLOURED (0,0,255) as "CCI05"
GRAPHonPRICE HT05 COLOURED (250,0,0) as "HT05"
GRAPHonPRICE HT05x COLOURED (0,0,250) as "HT05x"
GRAPHonPRICE HT15 COLOURED (250,50,250) as "HT15"
GRAPHonPRICE HT COLOURED (0,50,0) as "HT"
GRAPHonPRICE LSMA05 COLOURED (0,0,0) as "LSMA05"