Currently, I have to check how many times it hits inside bar status to know if Bar Magnifier is enabled (see the code below). I need this so I can alert myself if Bar Magnifier is disabled in Strategy Properties.
The following Study is also useful for understanding How Signals are Calculated based on Intra-Bar Order Generation (IOG) and Bar Magnifier settings.
Code: Select all
using System;
namespace PowerLanguage.Strategy
{
[IOGMode(IOGMode.Enabled)]
public class CheckBarMagnifier : SignalObject
{
public CheckBarMagnifier(object ctx) : base(ctx) { }
private int _insideBarHitCount;
protected override void StartCalc()
{
_insideBarHitCount = 0;
Output.Clear();
}
protected override void CalcBar()
{
CheckBarMagnifierIsEnabled();
}
private void CheckBarMagnifierIsEnabled()
{
if (Bars.CurrentBar == 1)
{
Output.WriteLine("Bar: {0}\t Time: {1}\t\t Update Time: {2}\t\t Status: {3}\t Price: {4}",
Bars.CurrentBar, Bars.TimeValue, Bars.BarUpdateTime, Bars.Status, Bars.CloseValue);
if (Bars.Status == EBarState.Inside)
{
_insideBarHitCount++;
}
else if (Bars.Status == EBarState.Close)
{
Output.WriteLine("IOGMode is {0}",
Environment.IOGEnabled ? "ENABLED" : "DISABLED");
if (_insideBarHitCount > 2)
{
Output.WriteLine("Bar Magnifier is ENABLED.");
}
else
{
Output.WriteLine("Bar Magnifier is DISABLED.");
}
}
}
}
}
}