Entry point and its trail

Hi Guys,
A quick question. I'm trying plot shapes, after a signal is true. For example when price crosses an MA, I would like all the bars after that signal, while the close is above or crosses below the MA
In the example below, The buy signal is plotted, but I would like the bars since that signal trailed by the MA. Hopefully this all makes sense.

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

MYma = MA( C, 20 );
Plot(MYma , _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
Buy = Cross(C,myma);
PlotShapes( IIf(Buy , shapeUpArrow, shapeNone ), colorGreen, 0, L, -25);

//Buy_trail = BarsSince(Buy) AND C > MYma;
//PlotShapes( IIf(Buy_trail, shapeUpArrow, shapeNone ), colorGreen, 0, L, -25);
![Trail|690x411](upload://jTka0TgVwXp5cwserAb8Kpv08mV.png) 

You have not inserted your picture correctly.
Do you know of post editing functionality of forum?
Trail


If you want arrows to show up for whole period of being above of MA then use Flip (for example).

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

MYma = MA( C, 20 );
Plot(MYma , _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
Buy = Cross(C,myma);
Cross_Below = Cross(myma,C);
PlotShapes( IIf(Flip(Buy,Cross_Below), shapeUpArrow, shapeNone ), colorGreen, 0, L, -25);
// Or
//PlotShapes( IIf(C > myMA, shapeUpArrow, shapeNone ), colorGreen, 0, L, -25);
_SECTION_END();

or use

Buy = C > myMA;

instead of Cross() function.

State vs. impulse.

2 Likes