TimeSeries values are lower than they should be

 

Hello forum,

I was marking some prices with Arrow objects but they were not exactly drawn on the value that they should have had, rather consistently more like 30 points lower or so.

copylow

When I hover over the arrow, the correct value is shown. What bothers me is that I have given the low price as input. I made a test file that takes the price via CopyLow VS iLow, they both do the same.

And when I get the value from the object and print it side by side with the value in the double array, they are exactly the same. So I figured something could be wrong with the drawing...?

number02

Here is the code. If you want to reproduce the effect, please put a breakpoint on the recommended line, see code

#include <ChartObjects\ChartObjectsArrows.mqh>

struct SArrowMark
  {
   CChartObjectArrow    Arrow[];
   ulong             last_error[];
   ulong             tmp_error;
   bool              CreateArrow(string name, double price, datetime time, color Clr, char code, int width);
   void              GetError();
  };


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool SArrowMark::CreateArrow(string name, double price, datetime time, color Clr, char code, int width) // where 1 is up and 2 is down
  {
   bool flag = false;

   ResetLastError();


   int size = ArraySize(Arrow);
   size++;
   ArrayResize(Arrow, size);
   flag = Arrow[size - 1].Create(0, name, 0, time, price, code);
   Arrow[size - 1].Width(5);
   Arrow[size - 1].Color(Clr);


   GetError();

   return(flag);
  }



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SArrowMark::GetError()
  {
   ArraySetAsSeries(last_error, true);
   tmp_error = GetLastError();

   if(tmp_error != 0)
     {
      int error_size = ArraySize(last_error);
      error_size++;
      ArrayResize(last_error, error_size);
      last_error[error_size - 1] = tmp_error;
     }
   ResetLastError();
  }
//+------------------------------------------------------------------+

SArrowMark ArrowCopyLow;
SArrowMark ArrowiLow;

double ARRCopyLow[];
double ARRiLow[];

int num_data = 5;
color InpClrCopyLow = clrDodgerBlue;
color InpClriLow = clrGold;
uchar InpCodeCopyLow = 168;
uchar InpCodeiLow = 252;

int run = 0;

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(run > 1)
     {
      for(int i = 0; i < num_data; i++)
        {
         Print("bar " + string(i) + " ; " + string(ArrowCopyLow.Arrow[i].Price(0)) + " ; " + string(ARRCopyLow[i])); //set breakpoint here
        }

     }

   ArraySetAsSeries(ARRCopyLow, true);
   ArraySetAsSeries(ARRiLow, true);
   ArrayResize(ARRiLow, num_data);

   CopyLow(_Symbol, _Period, 0, num_data, ARRCopyLow);  //set breakpoint here

   for(int i = 0; i < num_data; i++)
     {
      ARRiLow[i] = iLow(_Symbol, _Period, i);
     }

   for(int i = 0; i < num_data; i++)
     {
      ArrowCopyLow.CreateArrow(StringFormat("CopyLow_%d", i), ARRCopyLow[i], iTime(_Symbol, _Period, i), InpClrCopyLow, InpCodeCopyLow, 1);
      ArrowiLow.CreateArrow(StringFormat("iLow_%d", i), ARRiLow[i], iTime(_Symbol, _Period, i), InpClriLow, InpCodeiLow, 1);
     }

   run++;


  }
//+------------------------------------------------------------------+

Is this normal? Am I missing something?

Thanks in advance.

Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
When a graphical object is created using the ObjectCreate() function, it's necessary to specify the type of object being created, which can be one...
 

Oh you are right, that was the thing I didn't notice. Thank you. I don't understand why the Arrow object has no ANCHOR_CENTER... but alright.