Relative performance.

 

Hi Guys,


Hope you're all well. :)


I am having a problem with the coding for the relative performance between Oil and Gold.

When I just have "GOLD" in the ExtMapBuffer1[i], it shows the Daily price of Gold.

When I just have "OIL" in the ExtMapBuffer1[i], it shows the Daily price of Oil.

But when I put "GOLD / OIL", it doesn't give any value at all.

Any help would be appreciated. :)

Thank you.

int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   int limit = Bars-counted_bars-1;
 
   for (int i=limit; i >= 0; i--) 
   {

      
      // Binary Signal:
     
      double OIL = iClose("UKOil.v",PERIOD_D1,i);
      double GOLD = iClose("XAUUSD.v",PERIOD_D1,i);
      
      ExtMapBuffer1[i] = GOLD / OIL;
      }
  
//----
   return(0);
  }
 
  1.    int    counted_bars=IndicatorCounted();
    

    Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. int start()

    You should stop using the old event handlers (init, start, deinit) and IndicatorCounted() and start using new event handlers (OnInit, OnTick/OnCalculate, OnDeinit).
              Event Handling Functions - MQL4 Reference
              How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)

  3. Tradert618: But when I put "GOLD / OIL", it doesn't give any value at all.

    Of course, it does. That will be a value near unity and off bottom of the chart. Make it a separate chart. Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference


 

Hi William, 

Thank you very much. :)

Reason: