Collection of useful MT4 functions for coding - page 2

 

Trailing Stops

would like to see a good function for trailing stops if possible

 
shawnmstout:
would like to see a good function for trailing stops if possible

Thanks shawnmstout for your contribution. Much appreciated!

A TS function could be tricky, this could be dependent on how each individual EA is coded. Would be a nice tool to have.

Anyone?

 
shawnmstout:
would like to see a good function for trailing stops if possible

Go to this thread:

https://www.mql5.com/en/forum/172924

b.

 

Another good label making function:

void SetLabel(string Name, string Text, int x, int y, string Font, int Size, color Color)

{

if(ObjectFind(Name) == -1)

ObjectCreate (Name, OBJ_LABEL, 0, 0, 0);

ObjectSet (Name, OBJPROP_XDISTANCE, x);

ObjectSet (Name, OBJPROP_YDISTANCE, y);

ObjectSetText (Name, Text, Size, Font, Color);

} [/PHP]

An example of how to use it:

[PHP]SetLabel("1","My Custom Label",10,20,"Courier",15,Red);

This has been fun to use for me, hope others find this helpful.

 

Save Ticks in Array

Ever wanted to save the ticks in real time in an array for your EA to use in some way?

Function to save real time ticks in an array:

#define Array_Length 10000

double bid[Array_Length];

void TickSave()

{

for ( int i = Array_Length-1; i > 0; i-- )

bid = bid;

bid[0] = Bid;

} [/PHP]

Function to clear the array:

[PHP]void ClearTickSave()

{

for ( int i = Array_Length-1; i >= 0; i-- )

bid = 0;

}

I included a simple EA to show how this works. It simply saves the ticks, and shows the most recent ticks as comments on your screen.

bid[0] is the current tick.

Files:
ticks.gif  11 kb
tick_save.mq4  3 kb
 

script to open orders quickly set SL and TP

Go to this thread:

https://www.forex-tsd.com/expert-advisors-metatrader-4/58-trailing-stop-ea.html [/ url]

b. [/ QUOTE]

Hello everyone,

Sorry for the English, but I'm using google translator to write, great work and excellent source of education have found this forum, I wonder if someone can post a script to open orders quickly set SL and TP, it will greatly help a newbie in forex .

Thank you.

Reason: