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.
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...?
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 |//+------------------------------------------------------------------+voidOnTick()
{
//---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 herefor(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++;
}
//+------------------------------------------------------------------+
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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.
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...?
Here is the code. If you want to reproduce the effect, please put a breakpoint on the recommended line, see code
Is this normal? Am I missing something?
Thanks in advance.