Download MetaTrader 5

ObjectGetValueByTime() returns wrong results

To add comments, please log in or register
josephcom
26
josephcom  

Each time I call ObjectGetValueByTime(), NO MATTER what datetime parameter I pass to it, it ALWAYS returns the same value:

 

      datetime valleyArray[];

      CopyTime(Symbol(), Period(), 0, 40, valleyArray);

      ObjectCreate(0, valleyObjName, OBJ_STDDEVCHANNEL, 0, valleyArray [0], 0, valleyArray [arraySize-1], 0);

      

     double bottomPrice = ObjectGetValueByTime(0, valleyObjName, valleyArray[0], 2); // returns 4501

     double bottomPrice = ObjectGetValueByTime(0, valleyObjName, valleyArray[1], 2); // returns 4501

     double bottomPrice = ObjectGetValueByTime(0, valleyObjName, valleyArray[2], 2); // returns 4501

     double bottomPrice = ObjectGetValueByTime(0, valleyObjName, valleyArray[...], 2); // returns 4501

 

Any idea or similar experience?    

Willbur
198
Willbur  

4501 means "ERR_GLOBALVARIABLE_NOT_FOUND"

Very strange !

Did you reset the error before?

void  ResetLastError();

Did you check your CopyTime ?

if(CopyTime(      ,40,vallyArray) != 40)     Error !!!


Willbur




josephcom
26
josephcom  
Yes, I did. It drove me crazy so that I decided to do the math myself and calculate what I need. However, I'm still looking forward to your suggestions and ideas. Also, if required, I can provide the whole code for you to take a look at.
Willbur
198
Willbur  

I made some tests with trend line.

Is working fine and all I can get is error "4205 - ERR_OBJECT_GETVALUE_FAILED" - when I use wrong values in order to force errors. 

Maybe you should post a part of the code.

Willbur

josephcom
26
josephcom  

Thank you, I finally got through a mini course on "Standard Deviation" and "Linear Regression" and wrote my own code. Now it's working like a charm...

Willbur
198
Willbur  
A good occasion to refresh old math skills   ;-)
To add comments, please log in or register