I'm having trouble with one of my sell signals.
The buy signal works perfect but when I turn it around for a sell signal it gives me a False statement the whole time.
Has anyone encountered this before?
Thanks in advance!
I tried that already and both moving averages have a value.
This is a example of what it printed:
EURUSD,H1: Sell Conditions
EURUSD,H1: Sell 1true
EURUSD,H1: Sell 2false
sell_condition_2 = (1.088302857142855 < 1.088302380952381) : false
Though you have only difference on 7th decimal.
I don't understand then where I could be wrong. It shows that 7 period MA is always higher than the 21 period MA. How can this be? It is averaged out so it should definitly be possible for the 21 to be higher than the 7 at some point.
I just want it to sell when 7 MA < 21 MA and buy when 7 MA > 21 MA
If you want to sell when fast is less than slow and buy when fast is greater than slow, with your conditions you are always going to be either selling or buying on each and every bar regardless of the previous state. You should consider using only crosses instead.
Thank you for your response Mladen! I managed to figure out the problem.. really simple actually, I had the IMA declarations before my OnTick() loop so the two MA values were stuck as the same numbers for the whole loop everytime.
I actually have another buy and sell condition that is the main focus of my EA. I just added the MA condition so that I protect against losses incase of a heavy upward or downward trend.
Thanks for the help and advice!