Login Page - Create Account

Support Board


Date/Time: Mon, 28 Oct 2024 08:57:28 +0000



Post From: trying to get started programming, problem with simple exampe (own SMA)

[2023-09-21 16:55:25]
User138457 - Posts: 38
Not helping either, curretnly the code reads
double sma;
  int BarIndexSize = sc.Input[0].GetInt();
  
  sma=0.;
  if(sc.Index < BarIndexSize)

return;
  //for (int BarIndex = sc.UpdateStartIndex-BarIndexSize+1; BarIndex < sc.ArraySize; BarIndex++)
  for ( int BarIndex = sc.ArraySize-BarIndexSize-1; BarIndex<sc.ArraySize-1; BarIndex++)
  {
    msg.Format("BarIndex = %d",BarIndex);
    sc.AddMessageToLog(msg,1);  
    
    sma=sc.Close[BarIndex];
    msg.Format("SMA = %d",sma);
    sc.AddMessageToLog(msg,1);    
  }
  //sma=sma/(1.*BarIndexSize);
  msg.Format("SMA = %d",sma);
  sc.AddMessageToLog(msg,1);    

Apparently I am gravely misunderstanding sc.ArraySize and sc.Index,
the (rather short) documentation did not enlight me either. Can anyone enlight me, please?