Download MetaTrader 5

Drawing the Calculated Equation on EURUSD Chart

To add comments, please log in or register
They are making profit already using Freelance service. You can join them!
Kerim Horoz
58
Kerim Horoz 2015.09.08 21:14 

Hello,

I have been trying to integrate my calculation on eurusd chart. However, I could not find where I am mistaken. Would you help me out with my codes at below ? Or what do you suggest to have result as a line on EURUSD chart ? 

 

Thanks. 

 

// The code is being used for educational purpose only.
//--------------------------------------------------------------------
#property indicator_chart_window    // Indicator is drawn in the main window
#property indicator_buffers 1       // Number of buffers
#property indicator_color1 Blue     // Color of the 1st line

 
  double Buf_0   [];             // Declaring arrays (for indicator buffer)
  double XAGUSD  [];             // symbol on mt4 of broker as an array
  double USDTRY  [];             // symbol on mt4 of broker as an array
  double EURTRY  [];             // symbol on mt4 of broker as an array
  double USDJPY  [];             // symbol on mt4 of broker as an array
  double USDCHF  [];             // symbol on mt4 of broker as an array
  double USDCAD  [];             // symbol on mt4 of broker as an array
  double GBPUSD  [];             // symbol on mt4 of broker as an array
  double USDINDEX[];             // symbol on mt4 of broker as an array
  double XAUUSD  [];             // symbol on mt4 of broker as an array
  double SP500   [];             // symbol on mt4 of broker as an array
  double DOW     [];             // symbol on mt4 of broker as an array
  double DAX     [];             // symbol on mt4 of broker as an array    
  double FTSE    [];             // symbol on mt4 of broker as an array
  double USOIL   [];             // symbol on mt4 of broker as an array
  
//--------------------------------------------------------------------
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
       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
     {
        XAGUSD[i]       = 1.6382+0.000245*MarketInfo("XAGUSD",MODE_ASK);  //ask price at i. bar
        USDTRY[i]       = 0.25893*MarketInfo("USDTRY",MODE_ASK);          //ask price at i. bar
        EURTRY[i]       = 0.22969*MarketInfo("EURTRY",MODE_ASK);          //ask price at i. bar
        USDJPY[i]       = 0.000678*MarketInfo("USDJPY",MODE_ASK);         //ask price at i. bar 
        USDCHF[i]       = 0.02318*MarketInfo("USDCHF",MODE_ASK);          //ask price at i. bar
        USDCAD[i]       = 0.07650*MarketInfo("USDCAD",MODE_ASK);          //ask price at i. bar    
        GBPUSD[i]       = 0.08350*MarketInfo("GBPUSD",MODE_ASK);          //ask price at i. bar  
        USDINDEX[i]     = 0.007118*MarketInfo("#DXU5",MODE_ASK);          //ask price at i. bar   
        XAUUSD[i]       = 0.050014*MarketInfo("XAUUSD",MODE_ASK);         //ask price at i. bar
        SP500[i]        = 0.000019*MarketInfo("#ESU5",MODE_ASK);          //ask price at i. bar
        DOW[i]          = 0.000002*MarketInfo("#YMU5",MODE_ASK);          //ask price at i. bar
        DAX[i]          = 0.000001*MarketInfo("#FDXU5",MODE_ASK);         //ask price at i. bar 
        FTSE[i]         = 0.000001*MarketInfo("#FFIU5",MODE_ASK);         //ask price at i. bar 
        USOIL[i]        = 0.000031*MarketInfo("#CLV5",MODE_ASK);          //ask price at i. bar
        Buf_0[i]        =     XAGUSD[i]-USDTRY[i]+EURTRY[i]+USDJPY[i]
                             +USDCHF[i]+USDCAD[i]-GBPUSD[i]-USDINDEX[i]
                             -XAUUSD[i]+SP500[i]-DOW[i]-DAX[i]
                             +FTSE[i]-USOIL[i];             // Value of 0 buffer on i bar

      i--;                          // Calculating index of the next bar
     }
//--------------------------------------------------------------------
   return;                          // Exit the special funct. start()
  }
//--------------------------------------------------------------------
Keith Watford
Moderator
9614
Keith Watford 2015.09.08 23:35  

You don't size any of your Symbol arrays.

Why do you need arrays anyway? You are retrieving the current ask on every calculation, not a price relevant to bar[i]

Kerim Horoz
58
Kerim Horoz 2015.09.09 09:20  
GumRai:

You don't size any of your Symbol arrays.

Why do you need arrays anyway? You are retrieving the current ask on every calculation, not a price relevant to bar[i]

    I did not use arrays first and I did not get any changes on the chart and I also thought that array could keep the records of results of my calculations and then I could draw the result on the line. 

    I do not mind to get the line on the chart. I only need to have it somehow if you could understand my target on the codes.  

    I am learning and trying these on samples as ;

   http://www.forexmt4.com/_MT4_Tutorials/lesson11.pdf

   https://book.mql4.com/samples/icustom 

   http://stackoverflow.com/questions/26362199/mql4-coding-empty-buffer-in-line 

To add comments, please log in or register