Assistance with an EA coding error please

Back to topics list To post a new topic, please log in or register
Mccallum28 2014.05.22 15:59

I have an EA that I have put together however the problem is it is not placing orders the way I want it to.

The logic behind it is to trade Short when the following conditions are met:

Perceptron is < 0

When TradeShort = True ( a combination of the following signals

bool macdShort= ((MACDM1<=MACD_SIGM1)&& (MACDM1<0) && (MACDM5<=MACD_SIGM5)&&(MACDM5<0) && (MACDM15<=MACD_SIGM15)&&(MACDM15<0));

bool strShort=  ((rsi_m5 < 50) && (stoc_M5 < 60) && (cci_MM5 < 0) && (rsi_m15 < 50) && (stoc_M15 < 60) && (cci_MM15 < 0));

bool maShort=   ((EMA_M1 <= ema_m1) && (EMA_M5 <= ema_m5) && (EMA_M15 <= ema_m15));

and when the awesome indicator shows a RED bar

double Longc = iCustom(NULL,0,"Awesome",short_mean,long_mean,meanAO,0,0);

double Longp = iCustom(NULL,0,"Awesome",short_mean,long_mean,meanAO,1,0);


if((perceptron() < 0) && (TradeShort=True) &&(Longc!=1 && Longp==1)) 

The EA trades long when the 1m|5m|15m signal bars are red as shown using the Signal_Bars_v3_Daily.mq4 indicator. Also when the awesome indicator is on a RED bar.

It should only trade long when perceptron > 0 &&  1m|5m|15m signals are green && awesome indicator is GREEN.

Can someone assist with pointing out my errors.

Attached files:
  _signal_bars_v3_daily.mq4  (40.22 KB)
Mccallum28 2014.05.22 16:00 #
Here is the EA and above is the signal indi
Attached files:
  autovm5xawesomeo2.mq4  (9.60 KB)
Mccallum28 2014.05.22 16:00 #
Here is the awesome indicator
Attached files:
  awesome.mq4  (3.32 KB)
ffoorr 2014.05.22 21:02 #

hello ryangiLLSL,

if the desired condition are awesome <0 and red bar,

double AW = iCustom(NULL,0,"Awesome",short_mean,long_mean,meanAO,0,0);

double lime_bar_AW  = iCustom(NULL,0,"Awesome",short_mean,long_mean,meanAO,1,0);

double red_bar_AW  = iCustom(NULL,0,"Awesome",short_mean,long_mean,meanAO,2,0);

if((perceptron() < 0) && (TradeShort=True) &&(AW <0  && red_bar_AW != 0.0)) 

you should check all the takeProfit and stoploss 

if(!OrderModify(OrderTicket(), OrderOpenPrice(), Ask+ModifySL*PointAsk-ModifyTP*Point,0, Blue)) 

ticket = OrderSend(Symbol(), OP_SELL, lots * 2, Bid, 3, Ask + sl * Point, Ask - Target*Point, "AI", MagicNumber, 0, Red); 

ffoorr 2014.05.23 08:09 #

I forgot something, sorry,

If you have a look at the amesome indicator, you will see that it do not take any extern, so it should be called that way 

double AO  = iAO(NULL,0,1);


double AO = iCustom(NULL,0,"Awesome",0,1);


if someone is interessed, this awesome can be smoothed, or optimized, extern are :   PERIOD_FAST, PERIOD_SLOW,  PERIOD_SMOOTH 

double AO = iCustom(NULL,0,"Awsome_1",PERIOD_FAST, PERIOD_SLOW,  PERIOD_SMOOTH ,0,1);

Attached files:
  awsome_1.mq4  (3.78 KB)
Mccallum28 2014.05.23 10:50 #


Thanks for helping me with the adjustments, I have adjusted the code however the EA now only opens short orders and I cannot see why.

Also with regards to calling A0:

double AO  = iAO(NULL,0,1);


double AO = iCustom(NULL,0,"Awesome",0,1);

What do I need to adjust or replace>?

The EA does seem to be preforming more in line with what I want, the only problem is I need to open shorts as well as long positions. Can you see why?

Attached files:
  autorm5eawesomep3.mq4  (9.72 KB)
ffoorr 2014.05.23 15:59 #

the EA work I think.

The trailing_stop cannot be less than 50 Point.

The take profit cannot be modified.

there s a problem of logic. In the original AI there is no Target profit, the profit is within this line, it's the "sl".

   // check profit 
 if(Bid > (OrderStopLoss() + (sl * 2  + spread) * Point)) 

check everything, as usual,  ;-)   

I have added an object label to show the profit ;

Attached files:
  autovm5xawesomeo2_1.mq4  (10.26 KB)
Mccallum28 2014.05.23 16:50 #


Thats great, thank you very much. The EA seems to close out when an opposing signal is produced, I want each trade to only close out when profit target or stop loss is hit.  Can you help me with this, or do you think I would need something to filter out chop?

ffoorr 2014.05.24 08:25 #


This EA is from an MQL4 article, "non conventional trading", you can find it on this site (MQL4) . Read it.

Entries are random, following the perceptron().

With so many indicator as soon as an order is closed, another order is taken randomly, that is why there is so many loss in choppy market.

 The code should be optimized to find the best TimeFrame and setting. Order are closed on SL or when the profit is reached AND a reverse signal appears.

Unfortunately it take too much time to develop an EA, I have my own EA to take care about, ;-) But you will always find someone to help here ..

Back to topics list  

To add comments, please log in or register