ordersend() coding help... - page 2

 

You know I was just thinking about what I told you earlier I said:

If its a Buy:

SL = Bid - StopLoss* Point

TP = Bid + TakeProfit* Point

If its a Sell:

SL = Ask + StopLoss* Point;

TP = Ask - TakeProfit* Point;

I"ve always done it that way because that is how they do it in the MQL4 book examples but now I'm thinking that doesnt look correct, surely if you open on the Ask price you want to take profit at that price + your TP amount, and you want to stop out at that price - your SL amount ?

In other words the way you had it looks like it would be correct or is there something I am missing ?

 
mugged:

1) Yes this method works! Is there any way around this though? I hate the thought of the worst case where the initial order goes in but the modify doesn't occur (connection dies, error occurs, etc etc.)

Good question! I have NEVER seen anyone with a work around to this.

Pls kindly ask your broker about this "worst case".

 
mugged:

1) Yes this method works! Is there any way around this though? I hate the thought of the worst case where the initial order goes in but the modify doesn't occur (connection dies, error occurs, etc etc.)

In my code if the OrderModify fails it is retried several times, if the retries fail then the Order is closed, if the OrderClose fails it is retried, if the retries fail there is another Function that checks all trades, it will detect the Order with no SL or TP set and try to close it. All these failures will generate errors, these errors are reported on screen and via email, the email will also generate a pushed alert to my mobile phone.

There is one more failure mode that I haven't yet handled, that is a loss of connectivity to the Internet immediatly after the Order is placed and before it is modified . . . I have an idea to handle this but I don't have the required PHP coding skills.

 

I contacted my broker, they were pretty useless as they dont offer any programming help. Pretty much all the rep knew was how to apply an EA to the chart.

Its kinda strange that this issue just started happening though, it was working perfectly fine in the past. I wonder what caused it...

 
Have you guys been experiencing this issue for a long time or is his something new?
 
It's a fact of life with an ECN Broker.
 

Thanks for your help guys.

I guess ill just work around it.

 
RaptorUK:

In my code if the OrderModify fails it is retried several times, if the retries fail then the Order is closed, if the OrderClose fails it is retried, if the retries fail there is another Function that checks all trades, it will detect the Order with no SL or TP set and try to close it. All these failures will generate errors, these errors are reported on screen and via email, the email will also generate a pushed alert to my mobile phone.

There is one more failure mode that I haven't yet handled, that is a loss of connectivity to the Internet immediatly after the Order is placed and before it is modified . . . I have an idea to handle this but I don't have the required PHP coding skills.


Raptor, if you dont mind... how were you planning on checking for connectivity via php?
 
Maybe you could have a cellphone in modem mode connectd to the computer so if the computer loses its regular internet connectivity it can temporarily reconnect using the cellphone network
 
RaptorUK:
There is one more failure mode that I haven't yet handled, that is a loss of connectivity to the Internet immediatly after the Order is placed and before it is modified . . . I have an idea to handle this but I don't have the required PHP coding skills.

My approach is to just report the error and return. On the next tick, on a restart, on reconnect, EA's orderSelect loop will find the open order and then set the stops.

The largest problem is the orderSend returning no result. The order may or may not be open. Once you get the next tick then you'll know.