Using SelectedValue function

Is it correct what I am doing ?

I repeat using the SelectedValue function .

delay_Shft_BACK =  12 ; //amibroker setting

Chikou_Span = SelectedValue ( Ref(Close , - delay_Shft_BACK ) ) ; // for exploration

  Tenkan_Sen_Per = 3 ; //amibroker setting

Tenkan_sen  = (  SelectedValue ( HHV( High, Tenkan_Sen_Per ) ) +  SelectedValue ( LLV( Low, Tenkan_Sen_Per ) ) ) / 2 ;

///////////  signals  buy and sell 


Chikou_Span_BUY =  SelectedValue ( C ) >  SelectedValue ( Chikou_Span ) ; //  BUY
Chikou_Span_SELL =  SelectedValue ( C ) <  SelectedValue ( Chikou_Span ) ; //  SELL

Tenkan_sen_BUY =  SelectedValue ( C ) >  SelectedValue ( Tenkan_sen ) ; //  BUY
Tenkan_sen_SELL =  SelectedValue ( C ) <  SelectedValue ( Tenkan_sen ) ; //  SELL

thank you

@needhelp, the SelectedValue() function is mainly used on charts (its purpose: commentary, interpreration code and displaying selected bar values in the title or elsewhere)

For explorations and backtests I suggest removing it. Probably you should change the code to something like:

delay_Shft_BACK =  12 ; //amibroker setting
Tenkan_Sen_Per = 3 ;    //amibroker setting

Chikou_Span = Ref( Close , -delay_Shft_BACK ); // for exploration
Tenkan_sen  = ( HHV( High, Tenkan_Sen_Per ) +  LLV( Low, Tenkan_Sen_Per ) ) / 2 ;

///////////  signals  buy and sell
Chikou_Span_BUY =  C > Chikou_Span; //  BUY
Chikou_Span_SELL =  C <=  Chikou_Span; //  SELL

Tenkan_sen_BUY =  C >  Tenkan_sen ; //  BUY
Tenkan_sen_SELL = C <=  Tenkan_sen; //  SELL

Filter = 1;
AddColumn(Chikou_Span, "Chikou_Span");
AddColumn(Tenkan_sen, "Tenkan_sen");
AddColumn(Chikou_Span_BUY, "Chikou_Span_BUY", 1);
AddColumn(Chikou_Span_SELL, "Chikou_Span_SELL", 1);
AddColumn(Tenkan_sen_BUY, "Tenkan_sen_BUY", 1);
AddColumn(Tenkan_sen_SELL, "Tenkan_sen_SELL", 1);

Then, you should add some exploration code like in the above example (run the Analysis exploration by applying it to a single symbol to make results interpretation easier).
Check the results to see if the code is doing what you expect from it.

Explorations are one of the essential tools to debug your formula and understand how Amibroker array processing works.

When the rules for buying/selling are more complex, already in the past I suggested using very detailed explorations, adding, during the development phase, all the values โ€‹โ€‹of the intermediate arrays to fully understand what is happening!

1 Like

You are Always there for everyone .
thank you for your reply .

know it is clear I do not have to use it in the formula .
but in the chart as below

Title = EncodeColor( 11 ) + _DEFAULT_NAME() + " :  " + EncodeColor( 1 ) +
StrFormat( "{{NAME}} - {{INTERVAL}}; {{DATE}}; \nO=%g, \nH=%g, \nL=%g, \nC=%g
(%.1f%%){{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );

by the way I am not using ( ichimoku ) but I am using the idea only

thank you

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.