Smoothed Moving Average
-
I use the following block in my code to make trading decisions. Basically if this passes then "Buy" trade and if it does not then "Sell" trade. Seems like this did not work properly. I can clearly see on my chart that the 5 MA is indeed above 8 MA, it still took a "Sell" trade instead of "Buy"
I will have to say that the EMAs are close but still I confirmed 5MA is > 8MA.Is this possible? What could be happening here?

-
More settings - set Candle ID to 1
because when it is 0, you are working with not closed candle and it "repaints" -
@miro1360 said in Smoothed Moving Average:
More settings - set Candle ID to 1
because when it is 0, you are working with not closed candle and it "repaints"Thank you!!
-
@miro1360 I have set the candle id to 1, but I am continue to see the same problem. I can visually very cleat see the MA5 to be above MA8, but it still takes the "Sell" trade instead of the "Buy" trade?
What could be happening here?
-
you set it for both MA (left and right)?
are you looking in chart for good MA mode (smoothed) and periods? -
@miro1360 said in Smoothed Moving Average:
you set it for both MA (left and right)?
are you looking in chart for good MA mode (smoothed) and periods?I did set it for both MA mode. Yes to left as well as right. See the following screenshot.
Also see the screeshot below it. The red line is my 5MA and blue line is 8MA. If you notice Red line is clearly above the blue line right before the big bull candle. But the EA did not take the "Buy" trade after the close of previous candle. It took a "Sell" trade instead. It did take the "Buy" trade after the close of the Big Bull candle that you see. It just seems to me like it is seeing things 1 candle late.

-
this smoothed MA is only condition which is needed for buy trade?
-
There are other logics I have in blocks but I don't think that matters.
But since you asked I will provide all details.
I am running this on "On Tick" event.
My first block is "Once per bar"
This is followed by the condition which checks the Smoothed MA. If this block passes. I have another condition that check if my Trend variable is equal to "Sell" This means that until now the prices were in downtrend. After the last closed bar now the prices are going to go up (as per my logic and theories/strategies) So I close existing "sell" trades. I then open a "Buy" trade. I then also now set the Trend variable to "buy" since I am not in uptrend. I now wait for another crossover condition when the 5MA < 8MALet me know if I can provide more clarification. I don't believe any other conditions I am using matters. It just seems like it is doing what it is supposed to but 1 candle late.

-
I wanted to update what I have noticed. I find this behavior inconsistent. Sometimes it works and matches with what I see visually on the chart and sometimes it is 1 candle late.
I wonder what could be going on here? Any thoughts? Ideas? Much appreciated.
Could this have something to do with broker spread? Just a thought.
-
try if this is working right ...
https://fxdreema.com/shared/ZXCuCOX1d -
@miro1360 said in Smoothed Moving Average:
try if this is working right ...
https://fxdreema.com/shared/ZXCuCOX1dI first wanted to thank you very much for taking the time and effort for helping me out.
I will sure try what you are suggesting. I still am very curious to ask..what is the difference in what you are suggesting as compared to what I am doing? It looks to me like it will yield the same result. I am curious to know where you think is the problem in what I am doing and why would this work like I want it to work?
I am sure going to try to out and update here in few hours.
Thanks a lot again!
-
not sure yet if it does some different results, if it does, than we can compare

-
@miro1360 said in Smoothed Moving Average:
not sure yet if it does some different results, if it does, than we can compare

I was thinking could it be that the Smoothed MA could be dynamic rather than static?
What I mean is at a point in time the 5MA could be greater than 8MA...but depending on future candles...that point in times value may change. Is that possible?If that is the case, it might explain the behavior I am seeing. When I look at the chart I am seeing the future of when the decision was made based on 5MA being higher or lower than 8MA. But after that decision was made by the EA, there might be sudden price movements that might show me the 5MA and 8MA lines a bit different when I look at it at my time as compared to what it maybe at the time of decision made by the EA.
Let me know your thoughts?
-
what I know, standard SMMA (smoothed MA) from metatrader is static from Candle 1, that means it not repaints ...
-
it still does not seem to work.

See the screenshot below. You see the red 5MA is above 8MA right after Candle(3) but the EA did not take the "Buy" trade. The EA took the "Buy" trade after the bigger candle(2) You can also see the dotted green line that shows my buy trade.Had it taken the buy trade where its supposed to the trade would be in profit, but its in loss right now!
What do you think?

-
actually it is working fine, look here for details in my drawing:

CandleID 3 is not true with condition but CandleID 2 is true with condition and trade was opened when CandleID 2 was CandleID 1 (lool mixed explanation
) ... but it is working right ... MA cross hapened after big bullish candle closed (and you toke trades when candle closes (from ID 1) ) ... so I think, it is working fine -
@miro1360 said in Smoothed Moving Average:
actually it is working fine, look here for details in my drawing:

CandleID 3 is not true with condition but CandleID 2 is true with condition and trade was opened when CandleID 2 was CandleID 1 (lool mixed explanation
) ... but it is working right ... MA cross hapened after big bullish candle closed (and you toke trades when candle closes (from ID 1) ) ... so I think, it is working fineYou are awesome Miro1360!!!! I am not happy that my strategy is not going to be profitable! but I am very joyful that we cracked the problem out. Thank you very much for the diagram and the explanation. This is 100% clear to me and I am in agreement with you about this.
What I learned here is that you do not have to look at the space between the 2 candles to find out if the EMA is above or below each other. But you have to look at the center of the candle itself! Thanks again for the explanation. I am your fan now!!