private DataSeries ExitMAfast;
private DataSeries ExitMAslow;
protected override void Initialize()
{
ExitMAfast = new DataSeries(this);
ExitMAslow = new DataSeries(this)
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 1)
{
If (MovingAverageType == 1)
{
ExitMAfast.Set(EMA(exitMAPeriodFast)[0]);
ExitMAslow.Set(EMA(exitMAPeriodSlow)[0]);
}
else
{
ExitMAfast.Set(HMA(exitMAPeriodFast)[0]);
ExitMAslow.Set(HMA(exitMAPeriodSlow)[0]);
}
}
if (BarsInProgress == 0)
{
...
if (Position.MarketPosition == MarketPosition.Long &&
CrossBelow(ExitMAfast, ExitMASlow, 1))
{
ExitLong();
}
...
}
}
- While backtesting in OnBarClose mode, if there is a primary bar (5 min) close event and there is a secondary bar (30 min) intra-bar moving average crossover condition, I would like to initiate a exit trading signal. In other words, after three 5 minute primary bars have printed, can you also determine the intra-bar value halfway through the 30 minute secondary bar, as well as any indicator values that have been defined on that secondary bar (BarsArray[1])?
- - How does this answer differ for real-time vs backtesting and OnTickClose vs OnBarClose?
- - As you can see in the code, I am trying to use a dataseries to selectively assign the indicator values for the higher time frame indicators while BarsInProgress = 1 so that I can use these values to initiate a trading signal (Exit) when BarsInProgress = 0. This approach doesn't seem to work and its unclear whether a private dataseries cannot be used in this manner or its a limitation with the CrossAbove/Below functions. Any suggestions?
The true event based multiple-instrument/timeframe functionality is a very compelling and useful feature . . . thanks for being ahead of the curve on this.
Regards,
Whitmark

Comment