Interesting thought!gaheitman wrote:Mike,magft wrote:Yes, i over slept! The 2yr twins both woke several times in the night so i am taking a while to get up to speed today![]()
I have added the ECN bit to the Modify order part so it locks and unlocks in there, i tried it outside as you suggested and i found i had several trades with no sl set! Running EU on 6 tfs today is proving useful for testing as i can watch M5 trades in between M15 trades and every half hr and hr M30 and H1 kick in as well. Quite a profitable morning on EU. I'll keep testing and see how it goes.
Thanks
Mike
Here's another crazy idea, how about we provide wrapper functions that replicate OrderSend() and OrderModify() that include the locking code. Then they would be drop-ins for existing EAs. Something like:
Then you change all the calls to OrderSend() and OrderModify() to _OrderSend() and _OrderModify(). The only bad part is we would lose the error number for the trade if there is also an error updating the global variable.Code: Select all
int _OrderSend(string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment="", int magic=0, datetime expiration=0, color arrow_color=CLR_NONE) { int res = -1; //try to lock resource if (LockTradingThread()<0) { Alert("Unable to place trade, timeout exceeded."); return(res); } RefreshRates(); //place trade res = OrderSend(symbol, cmd, volume, price, slippage, stoploss, takeprofit, comment, magic, expiration, arrow_color); //unlock resource UnlockTradingThread(); return(res); } bool _OrderModify( int ticket, double price, double stoploss, double takeprofit, datetime expiration, color arrow_color=CLR_NONE) { bool res = false; //try to lock resource if (LockTradingThread()<0) { Alert("Unable to modify trade, timeout exceeded."); return(res); } RefreshRates(); //modify order res = OrderModify(ticket, price, stoploss, takeprofit, expiration, arrow_color); //unlock resource UnlockTradingThread(); return(res); }
Just a thought (as always).
George
I was thinking along same lines and also thinking we are getting very bulky code. I am thinking of dropping bits into separate files, like they suggest in the TradeContext article. We could then just change the trigger and maybe like you have written add a _ to library functions. Then if we want to override for a given EA, ie the candlestick routine in this one, we just remove the _ and write in the EA. It would make cherry picking bits easier as we would have a library of functions like DoneForTheDay. The only thing is version history, maybe store rev in file name or require some sort of dependency check.
Anyway, i think this is a discussion over in the coders section
Back to this EA, i think there is an error in the new code as i have a trade trying to update SL and it is unsuccessful. Looking at the GVs it is left as 1 so i set it back to 0 and on the next update it adds SL!! Strange, and i need to finish some paid work
Mike