Displaying current Spread as a value in MT4

To add comments, please log in or register
RichMoo
9
RichMoo  

Hello,

How do I display the current spread as a value in my custom indicator? I use the following code, but it doesn't display.


   string displayStr = IntegerToString(spread[0]);
   
   ObjectCreate("ObjName", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("ObjName",displayStr,24, "Verdana", Red);
   ObjectSet("ObjName", OBJPROP_CORNER, 0);
   ObjectSet("ObjName", OBJPROP_XDISTANCE, 20);
   ObjectSet("ObjName", OBJPROP_YDISTANCE, 20);


I am just starting to learn to make indicators for MT4. I noticed some values (like tick_volume) will display, and others like this will not.

I am fairly experienced in coding C / C++ for microcontrollers, but MT4 is new to me.

Keith Watford
Moderator
18338
Keith Watford  

If I remember correctly, when they introduced OnCalculate to MQL4, they seemed to copy across from 5 but I believe that

                const long &volume[],
                const int &spread[])

didn't return any value.

I haven't checked since.

For the spread I just use Ask-Bid in my calculations which of course gives you the decimal value.

RichMoo
9
RichMoo  
Thank you, that worked great.
To add comments, please log in or register