Need the help in afl - Candlestick and indicator are shrink


I have a query, I would like to combine the simple trading system and the price chart but I am unable to do it.

I would also like to have buy and sell signals. But the signals are also not popping up.

Hope you can surely help me.

_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() );

SetChartBkGradientFill( ParamColor("BgTop", colorBlack),
ParamColor("BgBottom", colorDarkGrey),ParamColor("TitleBack",colorGrey40) );
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
//AA = Param("AA", 0.1, 0.0, 1.0, 0.01);
AA = Param("AA", 0.1,5,200,10);

CC = 1 - AA;
vEMA = IIR( C, AA, CC);

RE1 = CC*vEMA + Ref(vEMA, -1);
RE2 = (CC^2)*RE1 + Ref(RE1, -1);
RE3 = (CC^4)*RE2 + Ref(RE2, -1);
RE4 = (CC^8)*RE3 + Ref(RE3, -1);
RE5 = (CC^16)*RE4 + Ref(RE4, -1);
RE6 = (CC^32)*RE5 + Ref(RE5, -1);
RE7 = (CC^64)*RE6 + Ref(RE6, -1);
RE8 = (CC^128)*RE7 + Ref(RE7, -1);

output = vEMA - AA*RE8;
Plot(output, "Forward/Reverse EMA", styleLine,0.5,100);
Buy= LLV(output >= 2.5,2);
Sell= LLV(output <= -0.55,2);


PlotShapes(IIf(buy,shapeuparrow,shapeNone),colorBrightGreen, 0, Low );
PlotShapes(IIf(sell,shapedownarrow,shapeNone),coloryellow,0,High );


It's working fine for me.

You should use the tips in How do I debug my formula? to check the formula is definitely generating signals for the instrument you are testing it against.


Dear Sir,

Please see the screen shot attached for your reference. Because for me I can see the price candles are up and the other lines are down.


Look for function Plot in help and also for “styleownscale” and “stylenorescale”

@awilson It looks like @raghu2530 is trying to calculate some sort of moving average. The value of his stock is closing around 10,151 and his moving average is around 3.614!

While the suggestions for for

are good ideas, I think he better double check his code. If that moving average is to be of any use it should be closer to the actual security price.

Hi Sir,

I get the same screen, no changes when I use "styleownscale" and "stylenorescale".image

Kindly suggest me that the line at the bottom should be on the price chart. If you want to see that line only you can take out the price chart and so you may get some ideas.

Thank you so much.

Hi Sir,

Kindly suggest me the better idea how to merge them into one chart.


@raghu2530 You completely ignored the meaning of my post.

They are merged on one chart. Your problem is you want to chart something with a value of "13.2" on the same page as "10,200". So of course the chart will look terrible.

If your code is intended to be some type of moving average then you have made a mistake in your code to be getting an average of 13 on a stock whose price is over 10,000!


@raghu2530 I think maybe this is what you are looking for. The original author uses this indicator in a separate pane. I didn’t recognize that indicator from your different coding. It is not meant as a moving average.

@raghu2530 btw, what Matt had suggested was styleOwnScale.

Plot(output, "Forward/Reverse EMA", colorWhite, styleLine |styleOwnScale);

Which looks like this (if you get rid of the hideous charting lines at the top of your code),

But I think more properly as the author intended in a separate pane like this,



Thank you so much… :slight_smile: