Guys,
I'm trying to use HASmoothed in a strategy, but I keep getting errors in my log. Has anyone encountered problems and have you found a solution?
Here's what I get:
I'm having trouble using this indicator in a strategy. The log shows the following entry:
Error on calling the 'OnBarUpdate' method for indicator 'HeikenAshiSmoothed' on bar 1: Object reference not set to an instance of an object.
My code is simple enough:
protected override void OnBarUpdate()
{
HA_Open1 = HeikenAshiSmoothed(0.7, HAMA.SMA, HAMA.SMMA, 1, 2).HAOpen[1];
HA_Open0 = HeikenAshiSmoothed(0.7, HAMA.SMA, HAMA.SMMA, 1, 2).HAOpen[0];
HA_Close1 = HeikenAshiSmoothed(0.7, HAMA.SMA, HAMA.SMMA, 1, 2).HAClose[1];
HA_Close0 = HeikenAshiSmoothed(0.7, HAMA.SMA, HAMA.SMMA, 1, 2).HAClose[0];
if (HA_Open1 > HA_Close1 && HA_Open0 > HA_Close0)
{
ExitLong("ExitLongHeiken", "LongOnHeikenReverse");
EnterShortLimit(DefaultQuantity, GetCurrentAsk(), "ShortOnHeikinReverse");
}
// Condition set 2
if (HA_Open1 > HA_Close1 && HA_Open0 > HA_Close0)
{
ExitShort("ExitShortHeiken", "ShortOnHeikenReverse");
EnterLongLimit(DefaultQuantity, GetCurrentBid(), "LongOnHeikenReverse");
}
}
Comment