PDA

View Full Version : Using comment function to display info over chart



panama84
2012-12-24, 05:15 AM
many expert advisors and indicators add text on chart.https://indian-forex.com/images/smilies/good.gif


Actually it is very simple MQL function Comment()

It takes any number of arguments which will be concatenated together to form the string you want to print.

This is an example:

Comment("Open: ", Open[1],"\nHigh: ", High[1],"\nLow: ", Low[1],"\nClose: ", Close[1]);

this will display the OHLC values on the chart window on the top left corner.

if you need to write multiple lines simply use the value "\n" for going to a new line.

To start open Meta Editor and create a new indicator then add the previous line of code inside the start function so it will look like this



After attaching the indicator to the chart it will show the values like this (See the top left corner of the window).

paijahnpaijo
2012-12-24, 05:20 AM
I want to understand in my chart is how to add text to it in my chart. eg I want to add the words "indian-forex" in the upper right corner of the chart. how?

WDholic
2013-01-12, 04:40 PM
here.. try my void
you can add more lines as you need

void Labeling ()
{ int Fontsize=14;
ObjectCreate("baa", OBJ_LABEL, 0, 0, 0);
ObjectSet("baa", OBJPROP_CORNER,3);
ObjectSet("baa", OBJPROP_BACK,0);
ObjectSet("baa", OBJPROP_XDISTANCE,5 );
ObjectSet("baa", OBJPROP_YDISTANCE,5+1.5*Fontsize*0+(2*Fontsize));
ObjectSetText("baa","=====================",Fontsize,"Arial Bold",Pink);

ObjectCreate("caa", OBJ_LABEL, 0, 0, 0);
ObjectSet("caa", OBJPROP_CORNER,3);
ObjectSet("caa", OBJPROP_BACK,0);
ObjectSet("caa", OBJPROP_XDISTANCE,5 );
ObjectSet("caa", OBJPROP_YDISTANCE,5+1.5*Fontsize*0.8+(2*Fontsize)) ;
ObjectSetText("caa",WindowExpertName(),Fontsize+4,"Arial Bold",OrangeRed);

ObjectCreate("aaa", OBJ_LABEL, 0, 0, 0);
ObjectSet("aaa", OBJPROP_CORNER,3);
ObjectSet("aaa", OBJPROP_BACK,0);
ObjectSet("aaa", OBJPROP_XDISTANCE,5 );
ObjectSet("aaa", OBJPROP_YDISTANCE,5+1.5*Fontsize*2+(2*Fontsize));
ObjectSetText("aaa","=====================",Fontsize ,"Arial Bold",Pink);

ObjectCreate("aab", OBJ_LABEL, 0, 0, 0);
ObjectSet("aab", OBJPROP_CORNER,3);
ObjectSet("aab", OBJPROP_BACK,0);
ObjectSet("aab", OBJPROP_XDISTANCE,5 );
ObjectSet("aab", OBJPROP_YDISTANCE,5+1.5*Fontsize*4+(2*Fontsize));
ObjectSetText("aab",DoubleToStr(AccountBalance(),2)+" = BALANCE",Fontsize,"Arial Bold",Lime);

ObjectCreate("aac", OBJ_LABEL, 0, 0, 0);
ObjectSet("aac", OBJPROP_CORNER,3);
ObjectSet("aac", OBJPROP_BACK,0);
ObjectSet("aac", OBJPROP_XDISTANCE,5 );
ObjectSet("aac", OBJPROP_YDISTANCE,5+1.5*Fontsize*5+(2*Fontsize));
ObjectSetText("aac",DoubleToStr(AccountEquity(),2)+" = EQUITY ",Fontsize,"Arial Bold",Lime);
}

mickel
2013-01-12, 04:56 PM
You are a programmer, if I may ask please, how can we really apply this code because I'm a little confused about how to use the code. Thanks for sharing.

IjoProfit
2013-01-17, 11:25 AM
many expert advisors and indicators add text on chart.https://indian-forex.com/images/smilies/good.gif


Actually it is very simple MQL function Comment()

It takes any number of arguments which will be concatenated together to form the string you want to print.

This is an example:

Comment("Open: ", Open[1],"\nHigh: ", High[1],"\nLow: ", Low[1],"\nClose: ", Close[1]);

this will display the OHLC values on the chart window on the top left corner.

if you need to write multiple lines simply use the value "\n" for going to a new line.

To start open Meta Editor and create a new indicator then add the previous line of code inside the start function so it will look like this



After attaching the indicator to the chart it will show the values like this (See the top left corner of the window).

What you mean is a comment on an EA that will be built, so that later history will look comments section as we want,
if so I think it was things I could do with a little change any part of an EA

pyardilforex
2013-01-17, 11:28 AM
I beginer insufficiently understands by comment presentation function on charts, but I will study to know its ways of working, I pleasantly find new thing of you

barikahalah
2013-01-23, 03:08 PM
I would like to recognize your own method, you can contribute word as well as an image. In case may well inquire, simply because I'm a little perplexed concerning the application of that code, in case you definitely operate the actual code. Many thanks with regard to revealing.

Merabnoor123
2020-12-02, 02:09 PM
agr ap programing janty hen tu phir to ye bohat achi baat he. programing k through ap more earn kar skty hen lekin ye baat bhi sach he k programing koi easy cheez nahi he. isy kafi time dena pary ga.

0007
2020-12-15, 05:01 PM
मैं हमेशा मानता हूं कि अच्छी तरह से तैयार लोगों को अधिक संभावना है; यह हमेशा मुद्रा व्यापार में सच है। कुछ विदेशी मुद्रा शुरुआती विदेशी मुद्रा बाजार के उतार-चढ़ाव का फायदा उठाकर पैसा बनाने के लिए उत्सुक हैं ... और इस तरह के उत्साह के साथ, वे गलतियां करते हैं: पर्याप्त तैयारी के बिना व्यापार में उतरना !!! और नौसिखिए व्यापारियों द्वारा की गई सामान्य गलतियों में से एक अति आत्मविश्वास और कई सौदे हैं। यह निश्चित रूप से खाते के लिए बुरा होगा, बहुत अधिक आत्मविश्वास व्यापारियों को स्टॉप लॉस का उपयोग नहीं करने देगा। जबकि बहुत से लेनदेन कॉल मार्जिन को गति देंगे। इन दोनों से बचा जाना चाहिए, खासकर नए व्यापारियों के लिए।

हम इसे तभी खत्म कर सकते हैं जब हम अपना अनुभव साझा करेंगे। इस मुद्दे का समाधान या विस्तार। हम इसे प्रतिध्वनित करने के लिए अधिक डेटा की आवश्यकता के कारण jsut से लाभ नहीं उठा सकते क्योंकि यह अनियमितता के साथ इतना वास्तविक है। कीट भट बेनिफिट मिल्टा है। और विदेशी मुद्रा व्यापार में नौसिखिया ज्ञान और आक्रामक व्यापारिक मानसिकता की कमी के कारण अपनी पूंजी खो देते हैं, प्रत्येक शुरुआती व्यापारी को बाजार पढ़ने के पूर्वानुमान के बारे में कुछ अनुभव प्राप्त करने और डेमो खाते में इसका उपयोग करने के लिए एक डेमो खाता खोलना चाहिए, व्यापार करते समय धन प्रबंधन से बचने जैसी गलतियां। और विदेशी मुद्रा व्यापारियों के लिए लालच से बचना बहुत मददगार है