I would like to know the current chosen BarsPeriod params (Value, Value2...) during OnStateChange State.SetDefaults when setting properties' default values. I am aware that the BarsPeriod object doesn't formally exist in this state, but the Strategy Analyzer has the Data Series params in the UI, or when set on a chart, the chart already has a BarsPeriod. Is there a way to access that information?
Here are some more details of what I am trying to achieve - In a strategy, I am calculating some properties' default values based on other properties by extending the { get; set; } to something like:
protected override void OnStateChange()
{
if (State==State.SetDefaults)
{
Description = unitName+@" Better World For Us LLC - Auto Algo Box";
Name = externalUnitName;
// ...
SetPropertiesDefaults();
}
else if (State==State.Configure)
{
// ...
}
}
private void SetPropertiesDefaults()
{
RE_NumTargets = 4;
RE_TargetValue0 = 1;
CalcDefaultRETargetSizes(RE_NumTargets);
}
private void CalcDefaultRETargetSizes(int numTargets)
{
double enterPoint = 0.25;
deltaTarget = (RE_TargetValue0-0.25)/(numTargets+1);
if (numTargets>1)
RE_TargetValue1 = RE_TargetValue0-deltaTarget*1;
// ...
}
private int _RE_NumTargets;
[NinjaScriptProperty]
[Display(Name="# of Targets", Order=32, GroupName="ReEnters"),Range(1,10)]
[RefreshProperties(RefreshProperties.All)] // Needed to refresh the property grid when the value changes
public int RE_NumTargets
{
get {return _RE_NumTargets;}
set
{
_RE_NumTargets = value;
CalcDefaultRETargetSizes(_RE_NumTargets);
}
}
[NinjaScriptProperty]
[Display(Name="Target Size 1", Order=40, GroupName="ReEnters"),Range(0,double.MaxValue)]
public double RE_TargetValue0 { get; set; }
[NinjaScriptProperty]
[Display(Name="Target Size 2", Order=41, GroupName="ReEnters"),Range(0,double.MaxValue)]
public double RE_TargetValue1 { get; set; }
I would like to know the current chosen Data Series params


Comment