This is on a lower timeframe chart with 30 minute MACD added
Strategy
{
private Series <double> signal;
private Series <double> macdhistogram;
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Minute, 30);
}
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade)
return;
if (BarsInProgress == 1)
{
signal[0] = EMA(MACD(BarsArray[1], 12, 26, 9), 9)[0];
macdhistogram[0] = (MACD(BarsArray[1], 12, 26, 9)[0] - signal[0]);
Print(string.Format("{0};{1};{2};{3};{4};{5};{6}", Time[0], Open[0], High[0], Low[0], Close[0], Position.MarketPosition, macdhistogram[0]));
//Longafter
if (((macdhistogram[0] - macdhistogram[1]) > 0) && ((ToTime(Time[0]) > 010000 && ToTime(Time[0]) < 080000)) || ((ToTime(Time[0]) > 170000 && ToTime(Time[0]) < 230000)) && Position.MarketPosition != MarketPosition.Long)
{
EnterLong("Longafter");
}
--------------
But I keep getting an error of Error on calling 'OnBarUpdate' method on bar 314: Object reference not set to an instance of an object.

Comment