[Help] Weird exponential values (even negative) when I print my data of price and rsi

 

Hello, 

I want to fill these arrays with high and low values of rsi and price. When I use a position of 5 it prints fine (see the first 4 rows of the photo, these are pricehighs, pricelows, rsihighs and rsilows). The moment I use a bigger position to search throught the data 10, 15,... I get weierd exponential data (huge and negative numbers). I have no idea how this came into my code as I haven't dont any calculation to alter the data, what can be happening here? My results are even negative!

This my code:


#include <indicators/indicators.mqh>

CIndicators  g_indicators;
CiRSI       *g_rsi;
CiClose     *g_close;

float pricelows [];
float pricehighs [];
float rsilows []; 
float rsihighs [];


//SIZE I USE TO SCROLL IN THE FOOR LOOP
int AR = 10;

int OnInit() {

    ArrayResize(pricelows,AR); 
    ArrayResize(pricehighs,AR); 
    ArrayResize(rsilows,AR); 
    ArrayResize(rsihighs,AR);

    g_close = new CiClose();
    g_rsi = new CiRSI();
    

    bool setup = (
        g_close.Create(_Symbol, PERIOD_CURRENT)
        && g_rsi.Create(_Symbol, PERIOD_CURRENT, 14, PRICE_CLOSE)
        && g_indicators.Add(g_close)
        && g_indicators.Add(g_rsi)
    );
    if (!setup)
        return INIT_FAILED;
    return INIT_SUCCEEDED;
}


void OnTick() {

    g_indicators.Refresh();  

     //Define lenght of search 
     int position = AR;
   

//----------------------------------------------------------------Make array of lowers and highers    
     
     for (int i = 0; i < position; i++)
     {       
         if(g_close.GetData(i) < g_close.GetData(i+1))
             ArrayFill(pricelows, i, 1, g_close.GetData(i)); 
                              
              //lows
         if(g_close.GetData(i) > g_close.GetData(i+1))
             ArrayFill(pricehighs, i, 1, g_close.GetData(i));                     
     }
          
     for (int i = 0; i < position ; i++)
     {         
         if(g_rsi.Main(i) < g_rsi.Main(i+1))
             ArrayFill(rsilows, i, 1, g_rsi.Main(i));
         
         if(g_rsi.Main(i) > g_rsi.Main(i+1))
             ArrayFill(rsihighs, i, 1, g_rsi.Main(i));      
     }
   
     ArrayPrint(pricehighs);
     ArrayPrint(pricelows); 
     ArrayPrint(rsihighs);
     ArrayPrint(rsilows);
     
     }

and this is my result: See attached image

MQL5.community - User Memo
MQL5.community - User Memo
  • www.mql5.com
You can now not only read articles and download MQL5 programs, but you can also join discussions on the forum, leave comments on articles and source codes, rate MQL5 programs and share your own developments in the Code Base, and even publish articles for a decent fee (see Become an Author at MQL5.com!). MQL5.com services are constantly...
 

//--------[Update]-------//


Even If I change m size to 5 I get the weird huge negative data

 
Your code
if(g_close.GetData(i) < g_close.GetData(i+1))
             ArrayFill(pricelows, i, 1, g_close.GetData(i)); 
equivalent
if(g_close.GetData(i) < g_close.GetData(i+1))
             pricelows[i] = g_close.GetData(i); 
You only fill some elements of your arrays. The rest have garbage.
Reason: