I’ve created an indicator which tracks market structure on 4 timeframes which exposes certain public methods like (GetDirection(), GetBias(), etc.). I would like to now use this data in a multi-timeframe strategy (e.g. when 2 timeframes are both bullish enter long, etc.).
The issue that I’m encountering is that no matter what I try, the OnBarUpdate
in the indicator is not being called and it seems like none of the internal code of the indicator is being run at all.
Here is an example strategy which I’d like to use:
public class SimpleMACrossover : Strategy
{
private MSSDV2 mssdv2;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "SimpleMACrossover";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure)
{
AddDataSeries(BarsPeriodType.Second, 15);
AddDataSeries(BarsPeriodType.Minute, 1);
AddDataSeries(BarsPeriodType.Minute, 5);
AddDataSeries(BarsPeriodType.Minute, 15);
} else if(State == State.DataLoaded) {
mssdv2 = MSSDV2();
AddChartIndicator(mssdv2);
}
}
protected override void OnBarUpdate()
{
this.mssdv2 = MSSDV2();
Print(MSSDV2().GetDirectionForTF(3));
Print("Gets here");
}
}
I’ve added a Print statement to the OnBarUpdate of the indicator, but it never gets printed out. Am I missing something here?