Download MetaTrader 5

Trend look back

To add comments, please log in or register
GrumpyDuckMan
602
GrumpyDuckMan  

Hello everyone,

I just started this code today, but I'm having some problems understanding the error message. "could be one of 3 function(s)"  isn't particularly helpful. 

Some ideas please.

void Draw_Trendline()
  {

   datetime StartDate=TimeLocal();
   datetime FinishDate=TimeLocal();

   PriceClose = CopyClose(Symbol(),Period(),0, 100, ClosePriceArray);
   PriceOpen  = CopyOpen(Symbol(),Period(), 0, 100, OpenPriceArray);
   Copy       = CopyTime(Symbol(),Period(),0,100,StartDate,FinishDate,DateArray); // could be one of 3 function(s)

   ObjectCreate(0,Trend,OBJ_TREND,0,StartDate,ClosePriceArray[0],FinishDate,OpenPriceArray[99],0,0);
   ObjectSetInteger(Chart_ID,Trend,OBJPROP_COLOR,clrBlue);
   ObjectSetInteger(Chart_ID,Trend,OBJPROP_WIDTH,1);
   ObjectSetInteger(Chart_ID,Trend,OBJPROP_BACK,false);
   ObjectSetInteger(Chart_ID,Trend,OBJPROP_SELECTABLE,false);
   ObjectSetInteger(Chart_ID,Trend,OBJPROP_SELECTED,false);
   ObjectSetInteger(Chart_ID,Trend,OBJPROP_RAY_RIGHT,false);
   ObjectSetInteger(Chart_ID,Trend,OBJPROP_HIDDEN,false);
   ObjectSetInteger(Chart_ID,Trend,OBJPROP_ZORDER,false);

  }
SanjayBalraj
48
SanjayBalraj  
GrumpyDuckMan:

Hello everyone,

I just started this code today, but I'm having some problems understanding the error message. "could be one of 3 function(s)"  isn't particularly helpful. 

Some ideas please.

http://www.learncpp.com/cpp-tutorial/4-2a-why-global-variables-are-evil/

4.2a — Why global variables are evil
4.2a — Why global variables are evil
  • www.learncpp.com
If you were to ask a veteran programmer for one piece of advice on good programming practices, after some thought, the most likely answer would be, “Avoid global variables!”. And with g…
Icham Aidibe
10818
Icham Aidibe  
GrumpyDuckMan:

Hello everyone,

I just started this code today, but I'm having some problems understanding the error message. "could be one of 3 function(s)"  isn't particularly helpful. 

Some ideas please.

Syntax. You are using 7 parameters, CopyTime takes only 5.

https://www.mql5.com/en/docs/series/copytime

Documentation on MQL5: Timeseries and Indicators Access / CopyTime
Documentation on MQL5: Timeseries and Indicators Access / CopyTime
  • www.mql5.com
The function gets to time_array history data of bar opening time for the specified symbol-period pair in the specified quantity. It should be noted that elements ordering If you know the amount of data you need to copy, it should better be done to a statically allocated buffer, in order to prevent the allocation of excessive memory. No matter...
whroeder1
17127
whroeder1  
GrumpyDuckMan: I just started this code today, but I'm having some problems understanding the error message. "could be one of 3 function(s)"  isn't particularly helpful. 
Perhaps you should read the manual.
          CopyTime - Timeseries and Indicators Access - MQL4 Reference
Your code
Version 1Version 2Version 3
Copy = CopyTime(
  Symbol(),
  Period(),
  0,
  100,
  StartDate,
  FinishDate,
  DateArray
); // could be one 
// of 3 function(s)
int  CopyTime(
 string          symbol_name,
 ENUM_TIMEFRAMES timeframe,  
 int             start_pos,  
 int             count,      
                            
                            
 datetime        time_array[]
);

int  CopyTime(
 string          symbol_name,
 ENUM_TIMEFRAMES timeframe,  
 datetime        start_time,
 int             count,      
                            
                            
 datetime        time_array[]
);

int  CopyTime(
 string          symbol_name,
 ENUM_TIMEFRAMES timeframe,  
                            
                            
 datetime        start_time,
 datetime        stop_time,
 datetime        time_array[]
);

GrumpyDuckMan
602
GrumpyDuckMan  

Hello again,

I realized that I tried to set too many parameters for function copytime() after I posted the thread.

Thank you posts to #2 & #3.

To add comments, please log in or register