AFL how to ignore signals generating in previous candles.

#1
Below is my code:

st = SuperTrend(10,3);

_x = TimeFrameGetPrice("H", inDaily, -1);
_y = (_x * 1.009);
_z = TimeFrameGetPrice("H", inDaily );

cond1 = Cross(C, st); cond2 = _z > _y;

Buy = cond1 AND cond2;
Sell = Cross(st, C) ;

Plot(_y, "PDaysH", colorGold,styleDashed,0,0,0,0,0);
Plot(_z, "PDaysH", colorOrange,styleDashed,0,0,0,0,0);
Plot(st, "STOP", IIf(C>st,colorBrightGreen,colorRed),styleLine|styleStaircase|styleThick); //ploting highlow

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone), colorGreen, 0,L, offset=-120);

Problem I am facing is if cond2 gets satisfied in future, signal gets generated on previous signal candle (at right place) can anyone guide on how to ignore that. I want signal should be generated only if its a latest candle and both conds are true. In the attached file you can see that cond2 turns true after 3 candles from cond1 and buy signal turns true at the place of cond1 == true.


afl querry.gif


Any help much appreciated.

Thank you.
 
Last edited:

bunti_k23

Well-Known Member
#2
hi the problem is in ur conditions itself....u have 2 conditions which are contradicting with themselves. ur logic itself is not clear. try this cond1 = c > st;
 
#3
cond1 = cross(c,st); this is for cross candle (pulse form) for crossing candle only
changing it to c>st; will turn the signal true for all bars where close is above st.


cond2 = H > (ref(H, -1)*1.009); this is in state form

Buy = Cond1 and cond2;
Not only cond1
 
Last edited:

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?