Assistance with an EA coding error please

 

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

so

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.

Files:
 
Here is the EA and above is the signal indi
Files:
 
Here is the awesome indicator
Files:
awesome.mq4  4 kb
 

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

 

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

or

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

https://docs.mql4.com/indicators/iao


//===========================================

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

https://charts.mql5.com/4/785/eurusd-h1-fxpro-financial-services-2.png

Files:
awsome_1.mq4  4 kb
 

ffoorr,


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

or

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?

Files:
 

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 ;

https://charts.mql5.com/4/789/gbpusd-h1-fxpro-financial-services.png

Files:
 

fflorr,


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?

 

ryangillSL


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 ..