I am in need of some NT8 calculation advise here, as none of it seems to calculate right as compared to DATA BOX/Chart vs print out values, and what it executes on.
In the interest of saving space, I just left MACD and RSI cross for the last bar, and thus an entry decision. However, it executes later than I would want according to the chart, and that's because the values are bogus. I check it, using print; what could be causing these miscalculations? I added some initializing code to show that it's all there right. This is happening for ALL indicator values. If i include a bring out for Bollinger bands, the top of the band print out is above 35 for the entry point, and it's easy to see visible from the chart that 35 is only hit or exceeding for Bollinger Bands around May 10th, not Jun 6-8.
protected override void OnStateChange()
{
if (State == State.SetDefaults)
//RSI
PeriodRSI = 14;
SmoothRSI = 3;
//MACD
FastMacd = 12;
SlowMacd = 26;
SmoothMacd = 9;
}
else if (State == State.Configure)
{
smaFast = EMA(Fast);
smaSlow = EMA(Slow);
smaLarge = EMA(Large);
}
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade)
return;
// Crossing up MACD and RSI, I've left other indicators out of this - as compared to screenshot
if ( Position.MarketPosition == MarketPosition.Flat && CrossAbove(RSI(PeriodRSI,SmoothRSI).Value,RSI(Peri odRSI,SmoothRSI).Avg,3) && CrossAbove(MACD(FastMacd,SlowMacd,SmoothMacd).Valu e, MACD(FastMacd,SlowMacd,SmoothMacd).Avg,5)
{
Print("YOU ARE HERE");
Print(RSI(PeriodRSI,SmoothRSI).Value[0]);
Print(RSI(PeriodRSI,SmoothRSI).Avg[0]);
Print(MACD(FastMacd,SlowMacd,SmoothMacd).Value[0]);
Print(MACD(FastMacd,SlowMacd,SmoothMacd).Avg[0]);
ExitShort();
EnterLongLimit((int)orderQuantity,GetCurrentBid(), "LONG Limit 1.1 ");
Print("LONG Limit 1.1 "+ Position.Instrument + " At current price: "+GetCurrentBid());
justEntered = true;
}
--> THESE are the values from DATA BOX:
(RSI(PeriodRSI,SmoothRSI).Value[0]) = 66.07
(RSI(PeriodRSI,SmoothRSI).Avg[0]) =63.23
(MACD(FastMacd,SlowMacd,SmoothMacd).Value[0]) = 0.772
(MACD(FastMacd,SlowMacd,SmoothMacd).Avg[0]) = 0.304
I'm also not confusing previous bar with this bar, since RSI value for the current entry bar is 63.55. In fact below print values do not show up EVER on the data box or chart
--> THESE are the values from OUTPUT:
(RSI(PeriodRSI,SmoothRSI).Value[0]) = 64.10
(RSI(PeriodRSI,SmoothRSI).Avg[0]) =59.60
(MACD(FastMacd,SlowMacd,SmoothMacd).Value[0]) = 0.365
(MACD(FastMacd,SlowMacd,SmoothMacd).Avg[0]) = 0.227
Any idea what could be causing this?
Please help, I've spent days on this, and can't figure it out.

Comment