EA entry conditions - error in code

 

Hi all,

I have the attached EA that I have put together but it is not workinmg exactly as I want it to and I cant see my errors.

Once all conditions are met it should enter a trade, if perceptron signals short and indicators signal short and Awesome is on a red bar then only then should there be a short entry.

as you can see by the picture attached there was a buy entry when the awesome bar was red, this should only have allowed a short entry.

Also it only seems to take long orders with no shorts?

Where have i gone wrong?

Files:
 
rg83:
Hi all,

I have the attached EA that I have put together but it is not workinmg exactly as I want it to and I cant see my errors.

Once all conditions are met it should enter a trade, if perceptron signals short and indicators signal short and Awesome is on a red bar then only then should there be a short entry.

as you can see by the picture attached there was a buy entry when the awesome bar was red, this should only have allowed a short entry.

Also it only seems to take long orders with no shorts?

Where have i gone wrong?

rg83

You are using opened bars for signals. In those cases it can happen : in one moment it is green, your ea opens a position and then it reverts to red. Use closed bars for signals instead and you will avoid those false signals

 

Hi Mladen,

How would I change to closed bars, also have I made a mistake as I can only get it to open long trades, no shorts?

Thanks,

 
rg83:
Hi Mladen,

How would I change to closed bars, also have I made a mistake as I can only get it to open long trades, no shorts?

Thanks,

Change the shift (index) from 0 to 1

 

Thanks Mladen,

Great advice and assistance as always.

Will this solve the uissue of only opening long positions as I want to trade both short and long.

 
rg83:
Thanks Mladen,

Great advice and assistance as always.

Will this solve the uissue of only opening long positions as I want to trade both short and long.

It will not solve the issue of opening only long orders

That is probably caused by some error in logical conditions. You have to check the conditions form opening short positions

 

Thats the thing, I have looked through the conditions and they all seem to be correct.

 
rg83:
Thats the thing, I have looked through the conditions and they all seem to be correct.

Just some observations : macd long is not an inverse of macd short and "|" in ma long is not meaning or but bitwise or - change it to "||"

Reason: