I am learning AFL

Dear All ,

I've checked a code in guide as below :

Filter=Status("lastbarinrange");
Length = SelectedValue( BarIndex() );
Chg = ROC( C, 1 ); //one bar yield
yield = MA( Chg, Length - 1);
risk =  StDev( Chg, Length - 1);
AddColumn(yield,"yield");
AddColumn(risk,"risk");

Clr = ColorHSB( 2 * Status("stocknum") % 255, 255, 255 );


XYChartAddPoint( "Risk/Yield", Name(), risk[ Length ], yield[ Length ] , Clr );
XYChartSetAxis("Risk/Yield", "Risk[%]", "Yield[%]");

Then I get 2 errors. Please let me know how to correct it?

Thanks for your help.

1 Like

@Huynq99, I copied the code you posted and applied it to a watchlist exploration, and I didn't see any errors.

At the very least, to help us understand the problem, you should post screenshots of the errors you're seeing and indicate which version of Amibroker you're using.

1 Like

Dear My Idol,
How are you today? Thank you for your reply.
I am using Ver 7.

Dear Beppe
I've found a new stock in my list. After then i deleted it and it's ok.
Thanks again.

@Huynq99 this line

SelectedValue( BarIndex() );

The code SelectedValue( BarIndex() ) returns the zero-based index number of the bar that is currently selected by your mouse cursor on the chart.
And it is argument of the moving average or parameter to MA

1 Like