Why is there a difference between journal output and graph plotted?

Hello guys!

I’m quite new to creating EAs and i am testing one out right now.

Problem is, the value output on the journal and what i have on the graph is different.

Can someone help me figure out what went wrong?

Output from journal:

2019.08.06 20:00:00 Ribbon autotrader EURUSD,M30: Blue 6MA is 1.12046444
2019.08.06 20:00:00 Ribbon autotrader EURUSD,M30: Red 6MA is 1.12059222

Value on graph:

I cant put the graphical value of the red value in the image as i can only out 1 image.
But on the graph, the red sma s 1.11878 instead of the 1.1205922 in the output journal.

Code:
Print("Blue 6MA is " + DoubleToString(iMA(NULL,shorttf,6,0,MODE_SMA,PRICE_TYPICAL,1)));
Print("Red 6MA is " + DoubleToString(iMA(NULL,shorttf,6,1,MODE_SMA,PRICE_TYPICAL,1)));

Can someone help to figure out what is wrong?

Hi,
I don’t understand the difference between the ,6,1, and the 6,0 in the code (I am not familiar with the syntax of the code used) but I do know it is important to understand exactly what is meant by SMA and MA. I assume a 6MA is the average of the last six moving average values, but how is that moving average defined? Is it the same as the last six SMA averages (simple moving average) or is MA calculated differently than SMA? Is each contributor to the six moving averages based on O, H, L, C or other parameter? Food for thought. PS. I have been creating and analysing graphs from tabular data since 1978

Good luck with it. And more importantly, does it matter to your overall objective?

Hello Mondeoman,

Thanks for your reply and your input regarding the MA!

Sorry for not mentioning it earlier, I am using mq4. So the difference is that the red MA has a shift of 1 applied to it.
https://docs.mql4.com/indicators/ima

This version of the MA takes the simple average of the (H+L+C)/3 of the last 6 candles. What i am trying to do is automate an EA which places an order when price breaks the MA and the MAs have a crossover.

Based on that, i am confused as to why the graphical value of the MA and the output on the journal is different when going through to see if there is anything wrong with the logic in the code.

Now i realise i can manually calculate the MA to see which value is correct.

Thanks for helping me to realise this I now know how to move forward with the code.

Hi Mangoman,
Glad if I was some help here. Note that the more candles you use in the MA (eg the 100SMA) the further the average curve moves to the right. Which means that most of the price action has already happened before the indicator tells you it has. Doing anything else with the data (eg applying a shift of 1) is cosmetic, but in another way it is making the data fit more closely to the actual candle performance. This can be misleading at the least, and devastating at the most if applied to EA programs. For this example reason and many others, I have bad feelings about the efficacy of EA programs, especially those written by people who don’t understand the fundamental underlying datasets and how their manipulation with equations can have unintended consequences. Good luck with it. It was a lot simpler when you had those white cards that you had to punch holes in to run a computer program. LOL.

Hello Mondeoman,

Thank you for your feedback!

May i know if you do your analysis based more on TA or FA?
Have you tried writing EAs based on pure TA?
What are your thoughts on such EAs that rely purely on TA?

Regards,
Mangoman

Hi Mangoman,
Right now I am in transition in our investment lives, and so it has impacted our trading lives too. We are moving from very active to more passive - we are gettting too old to burn the candle.
I don’t feel I can give any advice on this matter that would be of use to other forum members. I have never written any EAs, but it has occurred to me that some time in the future when I am less busy with other pursuits, the idea interests me. Last year I managed the initial transformation of a service in industry that started to use robotic process automation for some of the simpler, previously manual tasks. As simple as those cases seemed, the automation results did not always perform as expected. Humans seem to cope with machine unpredictability (like outages) far more eloquently than robots.

At this time, I think it would be naive of me to put real money into an EA system (unless I had written it myself) because I have no real life examples of a perfectly working system. That is not to say I ignore EAs.

I see.

I am just starting to try out using EAs so i am not sure what journey it will take me on, so thank you for sharing and your insights!

The MA is calculated differently from the SMA but you will have to confirm this with an expert. Everything else seems fine to me and you shouldn’t really worry about it so much. All the best for your future trades, keep learning.