I am trying to loop through array and for i. I need to MAX values of previous 10 values.
So if i= 20, I need to math.max i-10, i-9, i-8... and so forth. But I am struggling to get this to work.
static public void TA(DateTime[] datePrice, double[] openPrice, double[] highPrice, double[] lowPrice, double[] closePrice)
{
#region declare variables
int outBegIdx;
int outNbElement;
int SmaPeriod = 20;
int TOTAL_PERIODS = closePrice.Length;
double[] outputSma = new double[closePrice.Length];
double[] outputStdDev = new double[closePrice.Length];
int[] outputShootingStar = new int[closePrice.Length];
int[] outputHangingMan = new int[closePrice.Length];
int[] outputEngulf = new int[closePrice.Length];
int[] outputMaxIndex = new int[closePrice.Length];
double[] outputTrueRange = new double[closePrice.Length];
double accProfit = 0;
int position = 0;
double openPosPrice = 0;
double profit = 0;
#endregion
#region not sure what this code is for
//for (int i = 0; i < closePrice.Length-TOTAL_PERIODS; i++) //had to change from -1 to -TOTAL_PERIODS
//{
// openPrice[i] = (double)i;
// highPrice[i] = (double)i;
// lowPrice[i] = (double)i;
// closePrice[i] = (double)i;
//}
#endregion
#region Technical Libary
TicTacTec.TA.Library.Core.RetCode Sma = Core.Sma(0, closePrice.Length - 1, closePrice, SmaPeriod, out outBegIdx, out outNbElement, outputSma);
TicTacTec.TA.Library.Core.RetCode StdDev = Core.StdDev(0, closePrice.Length - 1, closePrice, closePrice.Length, 1, out outBegIdx, out outNbElement, outputStdDev);
TicTacTec.TA.Library.Core.RetCode ShootingStar = Core.CdlShootingStar(0, closePrice.Length - 1, openPrice, highPrice, lowPrice, closePrice, out outBegIdx, out outNbElement, outputShootingStar);
TicTacTec.TA.Library.Core.RetCode HangingMan = Core.CdlHangingMan(0, closePrice.Length - 1, openPrice, highPrice, lowPrice, closePrice, out outBegIdx, out outNbElement, outputHangingMan);
TicTacTec.TA.Library.Core.RetCode BullIngulf = Core.CdlEngulfing(0, closePrice.Length - 1, openPrice, highPrice, lowPrice, closePrice, out outBegIdx, out outNbElement, outputEngulf);
TicTacTec.TA.Library.Core.RetCode TrueRange = Core.TrueRange(0, closePrice.Length - 1, highPrice, lowPrice, closePrice, out outBegIdx, out outNbElement, outputTrueRange);
//TicTacTec.TA.Library.Core.RetCode xx = Core.bu
//TicTacTec.TA.Library.Core.RetCode MaxIndex = Core.MaxIndex(0, closePrice.Length - 1, highPrice, 20, out outBegIdx, out outNbElement, outputMaxIndex);
#endregion
for (int i = 20; i < closePrice.Length - 1; i++)
{
for (int j = 0; j < 10; j--)
{
}
}
}