I have been spinning my tires on this and I can't seem to figure out what is going wrong here. I have a strategy that, when I compile, there are no errors. However, when I try to enable my strategy it attempts to and then does nothing. When I review my output this is the error which is posted
"Strategy 'Tagalong5open': Error on calling 'OnBarUpdate' method on bar 90: Unable to cast object of type 'NinjaTrader.NinjaScript.Series`1[System.Double]' to type 'System.IConvertible'."
When I block off the following code (which is found under the "OnBarUpdate" section) within my strategy it will enable. This leads me to believe that this is where the problem lies
if(Close[0] > Convert.ToInt32(Bollinger(Close,2,BB_Length).Upper )) {UBB_Cross = true; LBB_Cross = false;}
if(Close[0] < Convert.ToInt32(Bollinger(Close,2,BB_Length).Middl e)) {UBB_Cross = false; MBB_Cross_Dn = true;}
if(Close[0] < Convert.ToInt32(Bollinger(Close,2,BB_Length).Lower )) {LBB_Cross = true; UBB_Cross = false;}
if(Close[0] > Convert.ToInt32(Bollinger(Close,2,BB_Length).Middl e)) {LBB_Cross = false; MBB_Cross_Up = true;}
Essentially, what I am attempting to accomplish is to have my strategy react differently once it crosses different points within a specified Bollinger Band. I am using the above code to update bools to keep track of when the price closes beyond the upper band, lower band, and middle band.
Can anyone recognize what is holding me up here?...
Thanks for your help.
Comment