PDA

View Full Version : Custom indicator not returning correct values


annettes
09-22-2009, 03:03 AM
I am trying to write my first custom indicator - a very simple displaced moving average (see attached - CentredSMA.zip), but am not sure if I am doing the right thing.
When I plot the indicator on a chart it looks right. But when I use it in a custom strategy (also attached - SMAMACDv3.zip) and print out the values it is returning they do not match the values shown in the Data Box, and the strategy is not functioning properly.
Can anyone see what I am doing wrong please?

NinjaTrader_Bertrand
09-22-2009, 05:23 AM
annettes, please remove any CalculateOnBarClose settings from the Initialize() method of the called indicators (your CenteredSMA), then retry accessing the values from the strategy and check if they hit home then, thanks

annettes
09-22-2009, 05:56 AM
Hi Bertrand,
Thanks for the suggestion. I tried it, but unfortunately I am getting exactly the same values I was before.
Regards,
Annette

NinjaTrader_Bertrand
09-22-2009, 06:16 AM
Annette, just plotted your CenteredSMA, if you look to place trades on this value as charted - this will not be possible, as it's shifted back for historical data, thus giving you the impression to have a non lagging SMA, while those values do not exist when attempting to trade this in realtime.