Download MetaTrader 5

why those are different ?

To add comments, please log in or register
Are you used to trading from your smartphone? Mobile version of MetaTrader 5 will suit you best!
yilmazkahya
311
yilmazkahya 2013.12.31 13:30 

m5 chart is diffent at the same time ! when i changed it m15 and return m5 again, indicator results are diffent ? how can it be possible ??

RaptorUK please help :(

and codes..

// userindicator.mq4 
// The code should be used for educational purpose only.
//--------------------------------------------------------------------
#property indicator_separate_window    // Indicator is drawn in the main window
#property indicator_buffers 1       // Number of buffers
#property indicator_color1 Red    // Color of the 1st line
#property indicator_color2 Red      // Color of the 2nd line
 


double yuro,dolar ;
double Buf_0[],Buf_1[];             // Declaring arrays (for indicator buffers)
//--------------------------------------------------------------------
int init()                          // Special function init()
  {
   SetIndexBuffer(0,Buf_0);         // Assigning an array to a buffer
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);// Line style
   
   return;                          // Exit the special funct. init()
  }
//--------------------------------------------------------------------
int start()                         // Special function start()
  {
  
       int i;
                             // Bar index
       int Counted_bars;                // Number of counted bars
//--------------------------------------------------------------------
   Counted_bars=IndicatorCounted(); // Number of counted bars
   i=Bars-Counted_bars-1;           // Index of the first uncounted
   while(i>=0)                      // Loop for uncounted bars
     {
        Buf_0[i]= (iOpen("EURJPY",PERIOD_M5,i)/iOpen("USDJPY",PERIOD_M5,i))- iOpen ("EURUSD",PERIOD_M5,i);        // Value of 0 buffer on i bar
                   // Value of 1st buffer on i bar
      i--;                          // Calculating index of the next bar
     }
//--------------------------------------------------------------------
   return;                          // Exit the special funct. start()
  }
//--------------------------------------------------------------------
Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.12.31 13:38  
yilmazkahya:

m5 chart is diffent at the same time ! when i changed it m15 and return m5 again, indicator results are diffent ? how can it be possible ??

RaptorUK please help :(

and codes..

Perhaps the first time you ran the Indicator your EURJPY and USDJPY data were out of date . . . then when you changed timeframe and back again the Indicator used the correct updated data. It's hard to know just from looking at the charts . . . you need to add some heavy debugging and be prepared to spend time investigating.
yilmazkahya
311
yilmazkahya 2013.12.31 13:44  

i try MarketInfo for true prices, but i can't carry it on buffer.,

is there any way like this ?

Buf_0[i]= MarketInfo("EURJPY",MODE_OPEN,i)

is it possible ?

Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.12.31 13:56  
yilmazkahya:

i try MarketInfo for true prices, but i can't carry it on buffer.,

is there any way like this ?

is it possible ?

No, it isn't. You have to make sure your data is up to date . . . and make sure it is out of date data causing your issue.

It's a common problem, do some reading: https://www.mql5.com/en/forum/148535

Search for 4066 sorted by date

whroeder1
14504
whroeder1 2013.12.31 14:01  
  1. Buf_0[i]= MarketInfo("EURJPY",MODE_OPEN,i)
    RTFM market info only has TWO parameters.
  2.         Buf_0[i]= (iOpen("EURJPY",PERIOD_M5,i) / iOpen("USDJPY",PERIOD_M5,i))
                      - iOpen ("EURUSD",PERIOD_M5,i);        // Value of 0 buffer on i bar
    
    You are assuming that your chart's bar "i" has the same timestamp as some other pair's M5 chart's "i". This is absolutely false in the tester and extremely likely with live history. Don't hard code periods, don't assume.
    datetime now = Time[i];
    int iEURJPY  = iBarShift("EURJPY", 0, now),
        iUSDJPY  = iBarShift("USDJPY", 0, now),
        iEURUSD  = iBarShift("EURUSD", 0, now);
           Buf_0[i]= (iOpen("EURJPY",0,iEURJPY) / iOpen("USDJPY",0,iUSDJPY))
                      - iOpen ("EURUSD",0,iEURUSD);  // Value of 0 buffer on i bar

yilmazkahya
311
yilmazkahya 2013.12.31 14:26  
thank u i will study these :)
To add comments, please log in or register