Enivid

Administrator
Staff member
Nov 30, 2008
18,532
1,355
144
Odesa
www.earnforex.com
Because this expression is ambiguous:
MQL4:
(Hour()==CloseHour && Minute()>=CloseMinute)
It may work now, but it may stop working under some specific circumstances or when MT4 gets its next update, or it may work well forever - you'll never know.


The next part has an error. You use the "ii" variable to cycle through the orders, but then you select an order number "i". If you have only one order or if the only order you need deleted happens to be the same as the value stored in the variable "i", it will work. In other cases it will fail:
MQL4:
for (int ii=OrdersTotal()-1; ii>=0; ii--) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
 
Last edited:

amsteronline

Master Trader
Jul 11, 2012
92
1
64
Hello Enivid,

So I tested out this new version of the ea, and it works well, but what I don't understand is is that if I put the ea on two different charts of the same currency pair, then the ea will only open position for the first chart not the second.

Can you help me out on this, why can't the ea open trades on multiple charts of the same currency pair?

P.S.: Except for the GBP/JPY, for that currency pair, the ea opens positions for multiple charts
 
Last edited:

Enivid

Administrator
Staff member
Nov 30, 2008
18,532
1,355
144
Odesa
www.earnforex.com
Currently, order magic number is determined by the news date/time. You can change it to something custom if you want.

Change this:
MQL4:
int Magic;
to this:
MQL4:
extern int Magic = 111111;

And remove this line:
MQL4:
	Magic=NYear+NMonth+NDay+NHour+NMin;

Then you can change 111111 to a unique number for each EA instance via input parameter.
 
Last edited:

amsteronline

Master Trader
Jul 11, 2012
92
1
64
I have tried it out. Unfortunately, on the second chart, as soon as any of the pending orders gets filled, the ea just closes it...can you help me fix it?
 

amsteronline

Master Trader
Jul 11, 2012
92
1
64
the ea closes out the pending orders as soon as any of them gets gets filled. It works only if the ea is attached to only one chart, if it is attached to two charts of the same currency pairs, the pending orders on the second chart will just disappear if any of the pending orders gets filled.
 

Attachments

  • AmazingEA_EveryDay_AnyHour_AnyMM_CloseAll_2.mq4
    51.7 KB · Views: 47
Last edited:

amsteronline

Master Trader
Jul 11, 2012
92
1
64
There is an error saying: 'OrderMagic' - function not defined, so I changed that to OrderMagicNumber, I will let you know if that worked...the market is closed now.
 

amsteronline

Master Trader
Jul 11, 2012
92
1
64
Ok, I got it to work. So for line 298 instead of deleting Magic=NYear+NMonth+NDay+NHour+NMin; I put Magic=111111;
 
Last edited:

amsteronline

Master Trader
Jul 11, 2012
92
1
64
Hello Enivid,

So, I have been analyzing the market and and I think I know what function is missing from Amazing ea.

I believe that everything is fine with this ea except one thing: MARKET REVERSALS. The ea should anticipate market conditions in which the market reverses.

So I was thinking to add two of these functions (DOUBLE REVERSAL) So, we could have two reversal orders reversal 1 and reversal 2. Both of these should have a stop loss and take profit.

SO as an example: if points away is set to 25 pips, once we get BUY order (the market moves 25 pips up) the market moves a little bit, but not good enough to reach our TP (let's say 75 pips) so it REVERSES. Now, our stop loss is hit and we lost 25 pips. Now ea places a SELL order, moves a little bit but unfortunately the market reverses again (DOUBLE REVERSAL), so now the ea places the opposite of our previous order, so now it places a BUY order, the market finally moves in one direction good enough to hit our TP.

So, there should be two functions which we should be able to turn true/false, and they should both have TP/SL in order to make them work.

Let me know what you think, and also if you would be interested in coding this function.

Thanks Enivid!
 
Last edited:

Enivid

Administrator
Staff member
Nov 30, 2008
18,532
1,355
144
Odesa
www.earnforex.com
So, instead of trying to trade only once, it will try to trade 3 times? What happens if OCO = false and double reversal is set to true? Won't these reversal orders interfere with the opposite pending order? BTW, the reversal trades should be market orders, not pending ones, right?
 

amsteronline

Master Trader
Jul 11, 2012
92
1
64
Right, so it will try to order three times but only if the stop losses are hit, just like in the above example. If OCO is false then this strategy won't work. So OCO must always be true. And Yes, the reversal orders should be market orders.
 
Last edited: