Download MetaTrader 5

Indicator data not shown

To add comments, please log in or register


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()
        //---- line shifts when drawing
//---- 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

                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;

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

        //--- OnCalculate done. Return new prev_calculated.

To add comments, please log in or register