Posted By: swingtraderkk
Pending Entries not being hit - 01/29/15 14:18
Hi jcl,
Can you have a look at the attached script and pic please.
I'm trying to set a buy stop at the high of the last candle, but it does not appear to be hit when it should be mid-candle on the next candle, rather it is opened at the open of the subsequent candle.
What am I doing wrong? I have TICKS set in script.
Can you have a look at the attached script and pic please.
I'm trying to set a buy stop at the high of the last candle, but it does not appear to be hit when it should be mid-candle on the next candle, rather it is opened at the open of the subsequent candle.
What am I doing wrong? I have TICKS set in script.
Code:
function run() { set (TICKS); set (PLOTNOW); set (LOGFILE); set (TESTNOW); BarPeriod = 60; BarOffset = (ET+17)*60; LookBack = 100; StartDate = 20110101; EndDate = 20110120; Hedge = 2; vars op = series(priceOpen()); vars cl = series(priceClose()); vars hi = series(priceHigh()); vars lo = series(priceLow()); vars wt = series((hi[0]+lo[0]+cl[0]+cl[0])/4); Stoch(14,3,MAType_EMA,3,MAType_EMA); vars sto5K = series(rSlowK); vars sto5D = series(rSlowD); vars signal = series(0); Stop = 40*PIP; TakeProfit = 20*PIP; EntryTime = 10; if ((sto5K[0] < 30) and (sto5K[0] > sto5K[1])) { signal[0] = 1; } if (NumOpenLong < 1) { if ((NumPendingLong < 1) and (signal[0] > 0)) { enterLong(0,hi[0]); plotGraph("Entry",0,hi[0]+5*PIP,MAIN|TRIANGLE4,PURPLE); } if ((NumPendingLong > 0) and (signal[0] > 0)) { exitLong(); enterLong(0,hi[0]); plotGraph("Entry2",0,hi[0]+5*PIP,MAIN|TRIANGLE4,MAGENTA); } if (((NumPendingLong > 0) and (signal[0] < 1)) and (hi[0] < hi[1])) { exitLong(); enterLong(0,hi[0]); plotGraph("Entry3",0,hi[0]+5*PIP,MAIN|TRIANGLE4,MAROON); } } if (is(EXITRUN)) { exitLong(); exitShort(); } plot("Sto 5,2,2 K",sto5K[0],NEW,RED); plot("Sto 5,2,2 D",sto5D[0],0,BLUE); plot("30",30,0,GREY); plot("70",70,0,GREY); PlotWidth = 2400; PlotHeight1 = 800; }