How to draw a horizontal line in OnCalculate function
How to draw a horizontal line in OnCalculate function
Loading saved threads...
user1451111 · External communityPost link
External question — Stack Overflow Stack Exchange
Author: user1451111
Original post: https://stackoverflow.com/questions/78098102
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
The question is about MQL4 language for MetaTraders 4 platform.
I want to draw a horizontal line. I found the below mentioned snippet somewhere online and am trying to use it inside
OnCaculate()
function to draw a horizontal line on, let's say the maximum value in last 5 minutes.
int i; //let's assume it has a valid value for the highest value index
if (!ObjectCreate(0, "HLine", OBJ_HLINE, 0, 0, High[i]))
{
Print(__FUNCTION__, ": Failed to create a horizontal line! Error code =", GetLastError());
return (false);
}
I see this error in the log window:
OnCalculate: Failed to create a horizontal line! Error code = 4200
What is wrong in this snippet? If it is incorrect, please guide me with a correct way.
Quote
Report
Mark SdS · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: Mark SdS
Original post: https://stackoverflow.com/a/78105519
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Error 4200
means
Object already exists
:
see error codes
So you'll need to
ObjectDelete(0, "HLine")
first.
Quote
Report
Post Reply
Checking account access…