I'm working on an indicator that uses the built-in NT7 Swing indicator to tell my code what the latest Swing High/Low is. When I run my indicator with the COBC=true, it is reporting the correct values (The high/low of the swing point). When I run my indicator with COBC=false, it reports different values (The open/close of the bar following the swing point). This doesn't make any sense to me as the Swing indicator should just return the Swing High/Low dataseries. Why would the setting of the COBC value modify the Swing values being reported?
Any help figuring this out will be much appreciated.
I've included 2 text files (one file for each COBC setting) containing the Swing high/low output for the time period in the image between the 2 vertical blue bars.
Here is the simplified code which will reproduce what I'm seeing:
{
#region Variables
private int swingStrength = 6;
private double swingLow = 0;
private double swingHigh = 0;
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
// Setting Overlay to true means our indicator will be defaulted to plot on the price panel
Overlay = true;
// Set to false so that tests of the swing points can alert immediately
CalculateOnBarClose = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if(Historical)
return;
if (FirstTickOfBar)
{
swingLow = Swing(swingStrength).SwingLow[0];
swingHigh = Swing(swingStrength).SwingHigh[0];
Print ( Time[0].ToString() );
Print ( Instrument.MasterInstrument.Name + " Swing Low : " + swingLow );
Print ( Instrument.MasterInstrument.Name + " Swing High : " + swingHigh );
}
}
#region Properties
#endregion
}
}
COBCFalseSwings.txt
Comment