ChangeTheColor EA

Post Reply
magft
Trader
Posts: 195
Joined: Tue Nov 15, 2011 9:59 pm
Location: East Midlands, UK

Re: ChangeTheColor EA

Post by magft »

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
ROBST3R
Trader
Posts: 86
Joined: Fri Dec 16, 2011 7:33 pm

Re: ChangeTheColor EA

Post by ROBST3R »

Mike,


What do you think of adding a ma50 above ma only long trades and below ma only short as an extra filter?
magft
Trader
Posts: 195
Joined: Tue Nov 15, 2011 9:59 pm
Location: East Midlands, UK

Re: ChangeTheColor EA

Post by magft »

Update in post #1
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: ChangeTheColor EA

Post by gaheitman »

magft wrote:Update in post #1
Mike,

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

George
ROBST3R
Trader
Posts: 86
Joined: Fri Dec 16, 2011 7:33 pm

Re: ChangeTheColor EA

Post by ROBST3R »

Thnx Mike!
User avatar
spyderman
Trader
Posts: 338
Joined: Sun Dec 11, 2011 1:39 pm

Re: ChangeTheColor EA

Post by spyderman »

Here's what's going on with my H4 demo. Trading on Oanda. :)
You do not have the required permissions to view the files attached to this post.
Snaggin' some pips
Smoochie88
Trader
Posts: 10
Joined: Mon Jan 16, 2012 12:15 pm

Re: ChangeTheColor EA

Post by Smoochie88 »

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
Last edited by Smoochie88 on Thu Jan 19, 2012 11:26 am, edited 1 time in total.
magft
Trader
Posts: 195
Joined: Tue Nov 15, 2011 9:59 pm
Location: East Midlands, UK

Re: ChangeTheColor EA

Post by magft »

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
ROBST3R
Trader
Posts: 86
Joined: Fri Dec 16, 2011 7:33 pm

Re: ChangeTheColor EA

Post by ROBST3R »

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?
User avatar
spyderman
Trader
Posts: 338
Joined: Sun Dec 11, 2011 1:39 pm

Re: ChangeTheColor EA

Post by spyderman »

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. :?
You do not have the required permissions to view the files attached to this post.
Snaggin' some pips
Post Reply

Return to “Automated trading systems”