Download MetaTrader 5

Having issues with compiler and CopyBuffer()

To add comments, please log in or register
GarrisonLeRock
9
GarrisonLeRock  

I am new to mql. 

I am attempting to write my first tester robot based off of the HeikenAshi indicator that is provided in the metatrader editor. 

In my EA when I try to call CopyBuffer the compiler does not know what that function is. Is there a dependency that I am forgetting?

//+------------------------------------------------------------------+
//|                                              HATradingExpert.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#include <stdlib.mqh>


double open_HA;

double close_HA;

int HA_handle;


//+------------------------------------------------------------------+ 
//| Expert tick function                                             | 
//+------------------------------------------------------------------+ 
void OnTick() 
  { 
  
 
         int copied1 = CopyBuffer(HA_handle,3,0,1,open_HA);
          
   
         int copied2 = CopyBuffer(HA_handle,// indicator handle 
                         4,        // index of the indicator buffer 
                         0,        // starting position to copy from 
                         1,       // number of values for copying 
                          close_HA      // value receiving array 
                         );  
  }

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   HA_handle = iCustom(Symbol(),0,"\MQL4\Indicators\Heiken Ashi.mq4",0,0); 
//---
   return(INIT_SUCCEEDED);
  }

Perhaps a  library that I am failing to import. 


Any help would be appreciated.

Thank you. 

Carl Schreiber
Moderator
7954
Carl Schreiber  
  1. You have an mq4 code. For mq4 is the thread at the bottom.
  2.  CopyBuffer() does not exist for mq4 only for mq5!

A little hint, put the cursor above the a mq4 function and press F1...

GarrisonLeRock
9
GarrisonLeRock  
Carl Schreiber:
  1. You have an mq4 code. For mq4 is the thread at the bottom.
  2.  CopyBuffer() does not exist for mq4 only for mq5!

A little hint, put the cursor above the a mq4 function and press F1...


Rookie mistake. I changed the code to use iCustom instead in mql4. I can now get information from the indicator. Thank you for your help!
To add comments, please log in or register