req coding help for positioning arrows 2 bars later

rvlv

Active Member
#1
hi afl experts

I have a simple formula.
I need to position the buy or sell arrows 2 bars later than what it is now.
can you help with the code please
===========================
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
MA10 = MA( C,10);
MA20 = MA( C,20);
Plot(MA10,"MA 10",colorGreen,styleThick);
Plot(MA20,"MA 20",colorRed,styleThick);
buy =cross(ma10,ma20);
sell = cross(ma20,ma10);
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;

PlotShapes( shape, IIf( Buy, colorGreen, colorYellow ), 0, IIf( Buy, Low, High ) );

//==============

i need the buy sell arrows to appear after 2 bars from where it is now.
thanks in advance
 
Last edited:

boarders

Well-Known Member
#2
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
MA10 = MA( C,10);
MA20 = MA( C,20);
Plot(MA10,"MA 10",colorGreen,styleThick);
Plot(MA20,"MA 20",colorRed,styleThick);
buy =cross(ma10,ma20);
sell = cross(ma20,ma10);


buy1=ref(buy,-2);
sell1=ref(sell,-2);

shape = Buy1 * shapeUpArrow + Sell1 * shapeDownArrow;
PlotShapes( shape, IIf( Buy1, colorGreen, colorYellow ), 0, IIf( Buy1, Low, High ) );
 

Aman1

Well-Known Member
#3
Can you give me the logic for this strategy?

anyway you can use this also:

_SECTION_BEGIN("buysellma1");
M=MA(C,10);
m1=MA(C,20);
Buy1=M>m1;
Sell2=M<m1;
Buy=Ref(Buy1,-2);
Sell=Ref(Sell2,-2);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Color =IIf(Buy,colorGreen,IIf(Sell,colorRed,colorBlue));
SetBarFillColor(color);


Plot(Close,"Close",colorWhite,styleCandle);
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );
GraphXSpace = 5;
_SECTION_END();
 

rvlv

Active Member
#4
Hi friends

Thank you for the code.

Is it possible to get modified code as per rule below- please.

I have ma10 cross above ma20 and i have one more condition.
the price has to make 2 lows higher than ma10.
the arrow needs to appear below second low after ma crossover.
similarly sell condition gets modified as
sell= ma20 cross above ma10 and price makes 2 highs below ma10.
the sell arrow appears above second high that forms after ma cross
thanks in advance
we are just trying to test this scenario if it gives a good winning edge ,
regards-thanks
 

Similar threads