MQL4 Learning - page 4

 

Help needed - How to code MQL 50% Trailing Stop?

Hi,

Thanks in advance.

Does anyone know the code MQL MT4 to incorporate a

50% Trailing Stop after profit has cross "x" pips?

Thanks thanks thanks.

ed

 

regarding OrderTicket() function

I want my EA to check and make sure that it can only have one pending order in the pool at any one time, so I wrote the following code to do that:

int CheckOrders()

{

//----

int i,orders;

int tickets[];

//----

int ticket = 0;

int total = OrdersTotal();

//----

for(i=total;i>=0;i--) tickets = 0;

//----

for(i=total;i>=0;i--){

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){

if(OrderMagicNumber()==magic_base && OrderType()>1){

orders++;

tickets = OrderTicket();

Print("tickets = ",tickets);

}

}

}

Print("total = ",total," orders = ",orders);

while(orders>1){

for(i=total;i>=0;i--){

if(ticket==0 && tickets>0) ticket = tickets;

if(ticket>tickets) ticket = tickets;

}

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)){

OrderDelete(ticket);

}

orders--;

}

Print("ticket = ",ticket);

//----

return(0);

}

It displays the number of pending orders in the pool by the same EA correctly, but it won't delete the unwanted pending orders, because it always shows that tickets = 0. and because of this, the OrderDelete(ticket) won't work. Could sb please tell me why this would happen?

 

Please check, getting error

Hello, I'm trying this EA but getting this error;

unknown subwindow number 1 for ObjectCreate function

and

name parameter for ObjectDelete function must be a string

What does that mean?

Thanks

 

Noobie need help

hi guys, could some one teach me how to stop EA from trading at news time?

sleep command thing, and how to add in to an existing EA without need to rewrite the whole thing....because i am dumb at reading code an writing code (using metatrader expert advisor builder)

sample of sleep command code in 1 line or only the related line only, dont do the whole EA/indicator and ask me to read...i don't know how to =/ sorry....

i tried many times try to read an EA, even using the metatrader dictionary thing, but alot of the code i saw in an EA isnt in the dictionary....and the dictionary isnt very specify...well atleast for me....

dummy proof please ><

 

MT4 Text indicator? How to...

if i want to draw text on the screen, must it be an object? is there an indicator style for me to draw simple #s on the screen?

 

Resources for MQL4 writing ?

Any videos I can buy, or a complete book on the subject. I have various tutorials, but none very helpfull. Sure would be nice to look at a real EA with notes next to each line indicating exactly what the line means.

Also helpfull if one could get a tutorial on editing an EA, I think that would be the best way to learn, editing an EA to fit your style.

Thanks for any info...

 
mhdeaton:
Any videos I can buy, or a complete book on the subject. I have various tutorials, but none very helpfull. Sure would be nice to look at a real EA with notes next to each line indicating exactly what the line means.

Also helpfull if one could get a tutorial on editing an EA, I think that would be the best way to learn, editing an EA to fit your style.

Thanks for any info...

Try to look at the following:

- mql4 development course;

- Templates to create EAs and Indicators;

- Codersguru lessons in his website;

- Trading the MetaTrader; Codersguru lessons.

- mql4 Metatrader development course;

- All Codersguru lessons in one ebook;

- mql4 starting and continuing.

 

cool thanks...

your link mql4 development course; doesnt seem to work can you fix it ?

Thanks again

Mhdeaton

 
mhdeaton:
cool thanks...

your link mql4 development course; doesnt seem to work can you fix it ?

Thanks again

Mhdeaton

You mean first link?

It's working https://www.mql5.com/en/forum/general

It is the subforum in two sections:

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

and

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

 

Reverse Order Coding Help

Hello all.

I Need some help with coding an EA I'm working on. Could someone here please point me to any threads that discuss or give me examples of how to close the current order and reopen a new order in the reverse direction when i get a signal that my original order conditions have reversed?