I have built 2 indicators.
The 1st, outputs an SMA, based on the 5minute dataseries
The 2nd , imports the first as an object. and will be loaded on a 1 minute chart.
The intention is to see the data from the 5 minute SMA, on the 1 minute timeframe.
But the Problem is , that the data from the 5minute SMA is distorted when i load it on the 1 minute chart.
> this distortion, also occurs when i access the object through the 2nd indicator that i have built.
Here is the Main script,(that is loaded on a 1 minute)
public class MainSnippet : Indicator
{
private Indicator _SMASnippet101; // import indicator as object
private Series<double> SMA_5m_import; // store the output series to local series
[Browsable(false)]
[XmlIgnore]
public Series<double> SMA_5min
{
get { return Values[0]; }
}
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
//
}
else if (State == State.Configure)
{
AddDataSeries("EURUSD", Data.BarsPeriodType.Minute, 5);
}
else if (State == State.DataLoaded)
{
SMA_5m_import = new Series<double>(this); // 5m
var SMA5min = SMASnippet101(20);
SMA_5m_import = SMA5min.SMA_5m; // the series from the object is imported to local series
_SMASnippet101 = SMA5min;
}
}
protected override void OnBarUpdate()
{
SMA_5min[0] = SMA_5m_import[0]; // imported series used in Main method, & stored in the Output signal
}
}
Here is the 1st indicator / object that i'm trying to import
> its simply a SMA, using a 5 minute BarsArray
[Browsable(false)]
[XmlIgnore]
public Series<double> SMA_5m
{
get { return Values[0]; }
}
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Name = "SMASnippet101";
AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameSMA);
}
else if (State == State.Configure)
{
priorSum = 0;
sum = 0;
AddDataSeries("EURUSD", Data.BarsPeriodType.Minute, 5); // Import 5 minute DataSeries
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 1)
{
SMA_5m[0] = SMA_Method(Closes[1]); // calculate SMA, using 5 minute Data Series
}
}
What i am hoping to see is that the signal from the 5minute data series stays flat for the 5 minute period.
Like this..
> but instead the signal from the 5min is distorted ( i get different values on every bar), when the Main indicator is loaded on a 1min

Comment