stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

ChangeTheColor EA
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=221
Page 10 of 24
Author:  magft [ Wed Jan 18, 2012 11:54 am ]
Post subject:  Re: ChangeTheColor EA

gaheitman wrote:
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
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:

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);
}
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.

Just a thought (as always :D ).

George
Interesting thought!

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 :lol:

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 :roll: I'll be back

Mike
Author:  ROBST3R [ Wed Jan 18, 2012 11:57 am ]
Post subject:  Re: ChangeTheColor EA

Mike,


What do you think of adding a ma50 above ma only long trades and below ma only short as an extra filter?
Author:  magft [ Wed Jan 18, 2012 8:16 pm ]
Post subject:  Re: ChangeTheColor EA

Update in post #1
Author:  gaheitman [ Wed Jan 18, 2012 8:30 pm ]
Post subject:  Re: ChangeTheColor EA

magft wrote:Update in post #1
Mike,

You've really been churning out the code lately. Thanks for all your hard work!

George
Author:  ROBST3R [ Wed Jan 18, 2012 8:39 pm ]
Post subject:  Re: ChangeTheColor EA

Thnx Mike!
Author:  spyderman [ Wed Jan 18, 2012 11:50 pm ]
Post subject:  Re: ChangeTheColor EA

Here's what's going on with my H4 demo. Trading on Oanda. :)
Author:  Smoochie88 [ Thu Jan 19, 2012 10:36 am ]
Post subject:  Re: ChangeTheColor EA

Hi again, is there an easy setting or 'switch' in the settings that enables 24hr trading? Thing is I am fidling with this after work and would like to test then. Trying to solve errors mostly caused by broker limitations.

edit: thanks mike
Author:  magft [ Thu Jan 19, 2012 11:09 am ]
Post subject:  Re: ChangeTheColor EA

Smoochie88 wrote:Hi again, is there an easy setting or 'switch' in the settings that enables 24hr trading? Thing is I am fidling with this after work and would like to test then. Trying to solve errors mostly caused by criminal limitations.
In the latest release i have added Trade24hr, set this to true and it will! You could in old version if you set Start_TimeA to 00:00 and End_TimeA to 24:00.

Regards

Mike
Author:  ROBST3R [ Thu Jan 19, 2012 12:04 pm ]
Post subject:  Re: ChangeTheColor EA

Does there exist an done for the day for the terminal in Empty4? So if i ran multiple pairs and i hit my 2% of my balance that it will close all trades for the rest of the day?
Author:  spyderman [ Thu Jan 19, 2012 12:33 pm ]
Post subject:  Re: ChangeTheColor EA

I love the direction that these trades are heading. Thanks so much Mike for the EA.

A have a few questions for anybody.

On Gbp/Aud below, shouldn't the trade have closed at the change of color. I have "use close on color change" set to true.

I noticed several pairs are stacking, like Usd/Chf. What's the criteria for add on trades? I guess I didn't realize it would do that. :?
All times are UTC Page 10 of 24