I have a last unsolved issue on this.
Applying your code as described I am able to pass a value from my custom BarType to the strategy. The issue I have is that running a backtest, "get;" takes only the value of the first bar and does not load anymore the changes happening on the following bars.
I did the following:
- in my custom BarType:
namespace NinjaTrader.NinjaScript.BarsTypes
{
public double MySharedDouble
{ get; set; }
.....
protected override void OnDataPoint(Bars bars, double open, double high, double low, double close, DateTime time, long volume, bool isBar, double bid, double ask) //on every tick
{
MySharedDouble = CalculateMySD(bars, time);
- in my Strategy
if (barsType == null)
{
return;
}
else
{
double MySD = barsType.MySharedDouble;
Print(Time[0] + " " + MySD );
}
The CalculateMySD(bars, time) method correctly calculates a new value on every incoming tick in the BarType, but this updated value is not passing to the Strategy, that takes and keeps only the value calculated on the first bar. How do I get the public double passing an updated value on each bar?
Thank you for your support
Martin

Comment