Indicator data not shown

 

Hello,

have a strange problem. Data of my simple indicator are not shown, if the outside a specific level BUT still in scale range.

The code below demonstrates this. If you select threshold >= 0.9, you can't see any dot in the indicator value. The value is a Sin(x), so between -1 and 1.

To prove there are values, i do also a debug out along with date. Any help appreciated, thank you.


#property indicator_separate_window_window
#property indicator_buffers 1
#property indicator_plots   1
#property indicator_type1   DRAW_LINE
#property indicator_color1  White

//--- input parameters
input double         InThresholdLevel=0.9;         // InThresholdLevel
//--- indicator buffers

double          data[];
void OnInit()
{
        SetIndexBuffer(0,data,INDICATOR_DATA);
        IndicatorSetInteger(INDICATOR_DIGITS,10);
        PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,0);
        //---- line shifts when drawing
        PlotIndexSetInteger(0,PLOT_SHIFT,0);
        PlotIndexSetString(0,PLOT_LABEL,StringFormat("indi",0));
        
        IndicatorSetString(INDICATOR_SHORTNAME,"indi");
        PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
//---- initialization done
}

void OnDeinit(const int reason)
{

}
double get_level(int i)
{
        return MathSin((double) i);
}
//+------------------------------------------------------------------+
//|  Moving Average                                                  |
//+------------------------------------------------------------------+
int OnCalculate (const int rates_total,      // size of input time series
                 const int prev_calculated,  // bars handled in previous call
                 const datetime& time[],     // Time
                 const double& open[],       // Open
                 const double& high[],       // High
                 const double& low[],        // Low
                 const double& close[],      // Close
                 const long& tick_volume[],  // Tick Volume
                 const long& volume[],       // Real Volume
                 const int& spread[])         // Spread
{
        //tc_perf_console perf("OnCalculate");
        //--- check for bars count
        if(rates_total< 1)
                return(0);// not enough bars for calculation

        if(prev_calculated==0)
        {
                ArrayInitialize( data,0);
        }

//--- starting work
        int start=prev_calculated-1;
        //--- correct position
        if(start<1) start=1;

        bool update=( (rates_total - prev_calculated) > 1 ? false : true);      
        //--- main cycle
        for(int i=start;i<rates_total && !IsStopped();i++)
        {
                double tl=10.0;

                tl=get_level(i);
                if(MathAbs(tl) < InThresholdLevel)
                {
                        tl=0.0;
                }
                else
                        Print(StringFormat("%s %.3f",TimeToString(time[i]),tl));
                data[i]= tl;
                


        }
        //--- OnCalculate done. Return new prev_calculated.
        return(rates_total);


}
//+------------------------------------------------------------------+
Reason: