Hello,
I need to get the high and low price of RECTANGLE in my EA with below code.
but I receive wrong prices as below.
price1 = -1202941964 , price2 = 2122057442
what is my mistake ? how to fix it ?
Please make sure that you are applying the right values for "Chart ID" and "Object name".
string obj_name; int TotalObj = ObjectsTotal(NULL, 0, OBJ_RECTANGLE); for(int i=TotalObj-1 ; i>=0 ; i--) { obj_name=ObjectName(NULL,i,0,OBJ_RECTANGLE); double price1 = ObjectGetDouble(NULL,obj_name,OBJPROP_PRICE,0); double price2 = ObjectGetDouble(NULL,obj_name,OBJPROP_PRICE,1); printf("%s : price1 = %d , price2 = %d",obj_name,price1,price2); }
the above is complete of my code for this and below is the result.
SUPPLY PERIOD_M15 3 : price1 = -1669883285 , price2 = 2122057442
SUPPLY PERIOD_H1 1 : price1 = -1669883285 , price2 = 395824186
DEMAND PERIOD_M15 2 : price1 = 1808696628 , price2 = 68719477
DEMAND PERIOD_H1 0 : price1 = 258385232 , price2 = 1964002645
the above is complete of my code for this and below is the result.
SUPPLY PERIOD_M15 3 : price1 = -1669883285 , price2 = 2122057442
SUPPLY PERIOD_H1 1 : price1 = -1669883285 , price2 = 395824186
DEMAND PERIOD_M15 2 : price1 = 1808696628 , price2 = 68719477
DEMAND PERIOD_H1 0 : price1 = 258385232 , price2 = 1964002645
Your code is running on my system with correct output.
You are using printf in the wrong manner.
e | double | A real value in the format [-] d.dddde[sign] ddd, where d - one decimal digit, dddd - one or more decimal digits, ddd - a three-digit number that determines the size of the exponent, sign - plus or minus |
use %e
Documentation on MQL5: Common Functions / PrintFormat
Post edited by moderator to reference MQL5 documentation instead of MQL4.
- www.mql5.com
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Post edited by moderator to reference MQL5 documentation instead of MQL4.
When answering posts in the MT5/MQL5 sections, please reference the MQL5 and not the MQL4 documentation.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I need to get the high and low price of RECTANGLE in my EA with below code.
but I receive wrong prices as below.
price1 = -1202941964 , price2 = 2122057442
what is my mistake ? how to fix it ?