Unable to show selected value in indicator

Need help in showing accurate "PPO_Status" when a bar is selected on the chart. Right now "PPO_Status" only shows status based on last visible bar in the chart.

// Test afl for testing various components of large afl's
// Current testing: PPO Ticked up/ Ticked down for triple screen scan


_SECTION_BEGIN( "PPO" );
// Plain vanilla PPO indicator.

//TChoice=Param("Title Selection ",1,1,2,1);
TChoice = ParamToggle( "Custom Title", "No|Yes", 1 );

PPOShort = Param( "PPO Short Period", 8, 1, 150, 1 );
PPOLong = Param( "PPO Long Period", 17, 1, 150, 1 );
PPOsignal = Param( "PPOsignal", 9, 1, 150, 1 );
PPO = ( EMA( C, PPOShort ) - EMA( C, PPOLong ) ) / EMA( C, PPOLong );
PPOS = ( EMA( PPO, PPOsignal ) );
PPO_H = PPO - PPOS ;

for( i = 1; i < BarCount; i++ )
{
    if( SelectedValue( PPO_H[i] ) > SelectedValue( PPO_H[i - 1] ) )
    {
        PPO_Status = "Ticked Up";
    }
    else
    {
        PPO_Status = "Ticked Down";
    }
}

if( TChoice == 0 )
{
    Plot( PPO , "PPO " + _PARAM_VALUES(), colorRed, styleLine );
    Plot( PPOS , "PPO Signal" , colorBlue, styleLine );
    dynamic_color = IIf( PPO_H > 0, colorGreen, colorRed );
    Plot( PPO_H, "PPO Histogram - " + PPO_Status, dynamic_color, styleHistogram | styleThick );
}

if( TChoice == 1 )
{
    Plot( PPO , "PPO " + _PARAM_VALUES(), colorRed, styleLine );
    Plot( PPOS , "PPO Signal" , colorBlue, styleLine );
    dynamic_color = IIf( PPO_H > 0, colorGreen, colorRed );
    Plot( PPO_H, "PPO Histogram - ", dynamic_color, styleHistogram | styleThick );
    Title = Name() + "  -   " +
            EncodeColor( colorRed ) + "PPO = " + Prec( PPO, 3 ) + "     " +
            EncodeColor( colorBlue ) + "PPOS = " +  Prec( PPOS, 3 ) + "     " +
            EncodeColor( colorRed ) + "PPO Histogram = " +  Prec( PPO_H, 3 ) + "     " +
            EncodeColor( IIf( PPO_Status == "Ticked Up", colorGreen, colorRed ) ) + "PPO Status = " + PPO_Status
            ;
}

_SECTION_END();

That upper one is not proper code.
It should be this:

if( SelectedValue( PPO_H > Ref(PPO_H,- 1) ) )
{
      PPO_Status = "Ticked Up";
}
else
{
     PPO_Status = "Ticked Down";
}
2 Likes

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