How to code? - page 262

 

How to add an alert to my favorite Trailing Stop EA

Hey guys Ive been working on this for hours and cant get it to work its my favorite Trailing stop EA can anyone please please help

All I want to do is add an alert i think its just adding a

Playsound("file") line?

and

maybe

extern bool UseSound = True;

extern string NameFileSound = "expert.wav";

to the user interface script ????

im trying but I really dont know much just yet can anyone help me or change it on the ea and then I will compare that to the original and then know for the future?

Files:
trailme1.mq4  18 kb
 
 

How to fix displayed decimals?

Hello,

I am developing an EA and have a display problem.

string temp = "Signals\n";

temp = temp + "--------------------------------------\n"

+ "Up_Op " + UpSignalOpen + "\n" <- example output is 0.12345000000

+ "Up_Cl " + UpSignalClose + "\n" <- example output is 0.12345000000

+ "------------------------------------------------\n"

+ "Dn_Op " + DnSignalOPen + "\n" <- example output is 0.12345000000

+ "Dn_Cl " + DnSignalClose + "\n" <- example output is 0.12345000000

+ "--------------------------------------\n";

Comment(temp);

I would like to find out how to specify the number of digits to the right of the decimal point (preferably 5) and also increase the font size so that it is larger than the MT4 default ?8 points to 12 points.

Is this doo-able?

Any help gratefully appreciated.

 

# Digits

Use DoubletoSTR(double,#Digits) to specify the number of digits to the right of the decimal place.

Instead of using Comment, use ObjectCreate & ObjectSet. You can put text anywhere on the screen and set the font, font size and color. Search for some Dashboard indicators to use as a guide.

Cheers

 

How to fix displayed decimals?

Tzuman, Thank you very much for this reply. I have seen ObjectCreate and ObjectSet somewhere - I'll go looking in my library. Much appreciated. I only hope I'm up to doing it

Use DoubletoSTR(double,#Digits) to specify the number of digits to the right of the decimal place.

Instead of using Comment, use ObjectCreate & ObjectSet. You can put text anywhere on the screen and set the font, font size and color. Search for some Dashboard indicators to use as a guide.

Cheers

string temp = "Signals\n";

temp = temp + "--------------------------------------\n"

+ "Up_Op " + UpSignalOpen + "\n" <- example output is 0.12345000000

+ "Up_Cl " + UpSignalClose + "\n" <- example output is 0.12345000000

+ "------------------------------------------------\n"

+ "Dn_Op " + DnSignalOPen + "\n" <- example output is 0.12345000000

+ "Dn_Cl " + DnSignalClose + "\n" <- example output is 0.12345000000

+ "--------------------------------------\n";

Comment(temp);

I would like to find out how to specify the number of digits to the right of the decimal point (preferably 5) and also increase the font size so that it is larger than the MT4 default ?8 points to 12 points.

 

Hello Newton

Don't worry, I'm sure you are up to it. Here's a little subroutine I use for printing text on the screen

void Create_Object(string OName,string OText,string OFont, color OColor,int OCorner,int XPosition,int YPosition)

{

ObjectCreate(OName, OBJ_LABEL, 0, 0, 0);

ObjectSetText(OName,OText,9, OFont, OColor);

ObjectSet(OName, OBJPROP_CORNER, OCorner);

ObjectSet(OName, OBJPROP_XDISTANCE, XPosition);

ObjectSet(OName, OBJPROP_YDISTANCE, YPosition);

return(0);

}

Using it saves 5 calls. With it you can set your information anywhere on the chart. Note that the corner=0 is the upper left and corner=1 is the right upper corner. When you are using the right corner, the xposition identifies the number of spaces to place after your string to the right margin. If you specify 0 or a negative number the string will not print. If the corner = 0 then the spaces are placed before the string you want to print. Put constant strings like "Signals" or "------------------" in calls in your Init subroutine to minimize cpu time and put variables that change with each tick in DoubletoStr(x,5); in your Start Subroutine. Also you can test to see if the variable is less than or greater than zero and set a color variable equal to Red if negative or Green if positive.

Here's a call that I use:

color c;

if(Profit<0) c=Red; else c=Lime;

Create_Object("Profita",DoubleToStr(Profit,2),"Arial Black",c,1,5,ypos+yline*15); yline++;

I use ypos to set the first starting line. If I want to change it, I change ypos once and all calls automatically adjust. yline is a line counter so I can insert another line and not have to change all the subsequent calls.

Also don't forget you can use the Wingdings font and print up arrows in green and down arrows in red to signal trends etc. Do a search for wingdings in the MQ4 navigator and you will see all the available symbols. To print a symbol, for instance a down arrow, use CharToStr(234) where 234 is the wingdings font number.

Good Luck

Tzuman

 

Many, Many thanks again for this. I went to bed and was not able to thank you earlier. (I'm in NZ) I will try this

 

How to check magic numbers of open positions

Hi guys,

I need your coding help. I have different open positions from different EAs with unique magic numbers.

Now I want to let check every EA if the EA wants to open a new position to check if there is already an open position with a given magic number.

How can help?

Bset regards,

 

Can an indicator draw in two sub-windows?

Hi Coders and programming experts

I have one simple question:

Is it possible to code an indicator that will open and draw output data in two subwindows when it is dragged onto a chart?

I have tried to find a solution in different MQL4 manuals and forums but with no luck.

If You know it is possible then let me know, and if You can link to a how-to-do-this-manual it's even better.

Cheers,

Tomas

 
Files:
ddm.jpg  141 kb
ddm.mq4  7 kb
Reason: