Hi, new to this so sorry if I am in the wrong place.
Ive written quite a few lines of code now trying various methods for automated trading, and have come across a weird problem that I can't seem to get to the bottom of. Its manifesting itself with standard moving or exponential averages and with the SuperTrend indicator.
I've run all of these indicators set up generally as standard, and the indicators work fine. I have also coded them into my bot for automated decision making, and most of them seem to work ok but averages and supertrend are giving different results to the indicator set up, even though the code has the same parameters as the indicator.
For example, to keep it simple. I have the EMA indicator showing 'close, 200, 0', looks fine. I have coded the same using....
Under "public class DAVE : Robot"
[Parameter("Long Trend EMA", Group = "Indicators", DefaultValue = 200, MinValue = 6, Step = 1, MaxValue = 1000)] public int TrendMME { get; set; }
private ExponentialMovingAverage mme;
Under "protected override void OnStart()"
mme = Indicators.ExponentialMovingAverage(Bars.ClosePrices, TrendMME);
And to get the latest value I use...
mme.Result.Last(1)
To try and debug it ive been 'print'ing those results, and although I get a similar number, its definitely not the same as the indicator is showing.
For instance, on the indicator I hover over and can see a close value such as '4022' but the last value on the code will say maybe 4008 or something. Its not the high or low of the bar. So weird.
Its exactly the same problem with SuperTrend. But I have done it successfully with other indicators and coded indicators such as Aroon, Stocashtic, ADX, RSI, MACD. I think I also had the same problem with Ichi Moku, but stopped trying as tearing what little left of my hair out.
I know its probably something really really stupid, but Im not experienced enough with c# or the environment to know what I've done wrong. Any ideas?