Dap's Oscillator- Short Term Momentum and Trend. 
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CheatCode1

//@version=5
indicator("Dap's Oscillator", "Moving Average Momentum Indicator", overlay = false)

Lf = input.int(3, 'Look Forward Length', 1, 100, group = 'Pivot Value')
Lb = input.int(55, 'Look Back Length', 1, 500, group = 'Pivot Value')
//Simple and Exponential Moving average Variables
    //SMA
    
sma1 = ta.sma(close, 5)
sma2 = ta.sma(close, 10)
sma3 = ta.sma(close, 15)
sma4 = ta.sma(close, 20)
sma5 = ta.sma(close, 25)
sma6 = ta.sma(close, 30)
sma7 = ta.sma(close, 35)
sma8 = ta.sma(close, 40)
sma9 = ta.sma(close, 45)
sma10 = ta.sma(close, 50)
sma11 = ta.sma(close, 55)
sma12 = ta.sma(close, 60)
sma13 = ta.sma(close, 65)
sma14 = ta.sma(close, 70)
sma15 = ta.sma(close, 75)
sma16 = ta.sma(close, 100)
sma17 = ta.sma(close, 120)
sma18 = ta.sma(close, 150)
sma19 = ta.sma(close, 200)
sma20 = ta.sma(close, 250)
    //EMA
ema1 = ta.ema(close, 5)
ema2 = ta.ema(close, 10)
ema3 = ta.ema(close, 15)
ema4 = ta.ema(close, 20)
ema5 = ta.ema(close, 25)
ema6 = ta.ema(close, 30)
ema7 = ta.ema(close, 35)
ema8 = ta.ema(close, 40)
ema9 = ta.ema(close, 45)
ema10 = ta.ema(close, 50)
ema11 = ta.ema(close, 55)
ema12 = ta.ema(close, 60)
ema13 = ta.ema(close, 65)
ema14 = ta.ema(close, 70)
ema15 = ta.ema(close, 75)
ema16 = ta.ema(close, 100)
ema17 = ta.ema(close, 120)
ema18 = ta.ema(close, 150)
ema19 = ta.ema(close, 200)
ema20 = ta.ema(close, 250)


//Moving average differences

ma5 = (sma1 - ema1)  
ma10 = (sma2 - ema2) 
ma15 = (sma3 - ema3) 
ma20 = (sma4 - ema4) 
ma25 = (sma5 - ema5) 
ma30 = (sma6 - ema6) 
ma35 = (sma7 - ema7) 
ma40 = (sma8 - ema8) 
ma45 = (sma9 - ema9) 
ma50 = (sma10 - ema10) 
ma55 = (sma11 - ema11) 
ma60 = (sma12 - ema12) 
ma65 = (sma13 - ema13) 
ma70 = (sma14 - ema14) 
ma75 = (sma15 - ema15) 
ma100 = (sma16 - ema16) 
ma120 = (sma17 - ema17) 
ma150 = (sma18 - ema18) 
ma200 = (sma19 - ema19) 
ma250 = (sma20 - ema20) 

ReferenceMA = ma50*-1

//Average of Moving Average differences + DAP Equation Variables

AvgDiff1 = (ma5 + ma10 + ma15 + ma20 + ma25 + ma30 + ma35 + ma40 + ma45 + ma50 + ma55 + ma60 + ma65 + ma70 + ma75 + ma100 + ma120 + ma150 + ma200 + ma250)/20
AvgDiff = AvgDiff1/100*-1
AvgDiff2 = AvgDiff1 * AvgDiff1
AvgDiff_sqrt = math.sqrt(hl2/AvgDiff)

//Standard Deviation Differences

stdev5 = ta.stdev(ma5, 5)
stdev10 = ta.stdev(ma10, 10)
stdev15 = ta.stdev(ma15, 15)
stdev20 = ta.stdev(ma20, 20)
stdev25 = ta.stdev(ma25, 25)
stdev30 = ta.stdev(ma30, 30)
stdev35 = ta.stdev(ma35, 35)
stdev40 = ta.stdev(ma40, 40)
stdev45 = ta.stdev(ma45, 45)
stdev50 = ta.stdev(ma50, 50)
stdev55 = ta.stdev(ma55, 55)
stdev60 = ta.stdev(ma60, 60)
stdev65 = ta.stdev(ma65, 65)
stdev70 = ta.stdev(ma70, 70)
stdev75 = ta.stdev(ma75, 75)
stdev100 = ta.stdev(ma100, 100)
stdev120 = ta.stdev(ma120, 120)
stdev150 = ta.stdev(ma150, 150)
stdev200 = ta.stdev(ma200, 200)
stdev250 = ta.stdev(ma250, 250)
AVGstdev = (stdev5 + stdev10 + stdev15 + stdev20 + stdev25 + stdev30 + stdev35 + stdev40 + stdev45 + stdev50 + stdev55 + stdev60 + stdev65 + stdev70 + stdev75 + stdev100 + stdev120 + stdev150 + stdev200 + stdev250)/20


//DAP'S OSCILLATOR               //DAP'S OSCILLATOR              //DAP'S OSCILLATOR            //DAP'S OSCILLATOR                   //DAP'S OSCILLATOR          //DAP'S OSCILLATOR              //DAP'S OSCILLATOR              //DAP'S OSCILLATOR              //DAP'S OSCILLATOR          //DAP'S OSCILLATOR

docp = AVGstdev - (AvgDiff*2)
docn = AvgDiff -(AVGstdev*2)

//Length's

len1 = input.int(3, 'DAP\'s Oscillator', 0, 100, group = 'Osillator Length')
len3 = input.int(250, 'RC Average Length', 1, 500, group = 'RC MOVING AVERAGE')
len4 = int(175)
//Variable Libraries 
    //Positive + 
AVGdocp5_A = (docp[4] + docp[3] + docp[2] +docp[1] + docn)/5
AVGdocp5_B = (docp[5] + docp[6] + docp[7] + docp[8] + docp[9])/5
AVGdocp5_C = (docp[14] + docp[13] + docp[12] + docp[11] + docp[10])/5
AVGdocp5_D = (docp[15] + docp[16] + docp[17] +docp[18] + docp[19])/5
AVGdocp5_E = (docp[24] + docp[23] + docp[22] + docp[21] + docp[20])/5
AVGdocp5_F = (docp[25] + docp[26] + docp[27] + docp[28] + docp[29])/5
AVGdocp5_G = (docp[34] + docp[33] + docp[32] + docp[31] + docp[30])/5
AVGdocp5_H = (docp[35] + docp[36] + docp[37] + docp[38] + docp[39])/5
AVGdocp5_I = (docp[44] + docp[43] + docp[42] + docp[41] + docp[40])/5
AVGdocp5_J = (docp[45] + docp[46] + docp[47] + docp[48] + docp[49])/5
AVGdocp5_K = (docp[54] + docp[53] + docp[52] + docp[51] + docp[50])/5
AVGdocp5_L = (docp[55] + docp[56] + docp[57] + docp[58] + docp[59])/5
AVGdocp5_M = (docp[64] + docp[63] + docp[62] + docp[61] + docp[60])/5
AVGdocp5_N = (docp[65] + docp[66] + docp[67] + docp[68] + docp[69])/5
AVGdocp5_O = (docp[74] + docp[73] + docp[72] + docp[71] + docp[70])/5
AVGdocp5_P = (docp[75] + docp[76] + docp[77] + docp[78] + docp[79])/5
AVGdocp5_Q = (docp[84] + docp[83] + docp[82] + docp[81] + docp[80])/5
AVGdocp5_R = (docp[85] + docp[86] + docp[87] + docp[88] + docp[89])/5
AVGdocp5_S = (docp[94] + docp[93] + docp[92] + docp[91] + docp[90])/5
AVGdocp5_T = (docp[95] + docp[96] + docp[97] + docp[98] + docp[99])/5

AVGdocp5_AB = math.avg (AVGdocp5_A, AVGdocp5_B)
AVGdocp5_ABC = math.avg (AVGdocp5_A, AVGdocp5_B, AVGdocp5_C)
AVGdocp5_ABCD = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D)
AVGdocp5_ABCDE = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E)
AVGdocp5_ABCDEF = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F)
AVGdocp5_ABCDEFG = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G)
AVGdocp5_ABCDEFGH = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G , AVGdocp5_H)
AVGdocp5_ABCDEFGHI = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G , AVGdocp5_H , AVGdocp5_I)
AVGdocp5_ABCDEFGHIJ = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G , AVGdocp5_H , AVGdocp5_I , AVGdocp5_J)
AVGdocp5_ABCDEFGHIJK = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G , AVGdocp5_H , AVGdocp5_I , AVGdocp5_J , AVGdocp5_K)
AVGdocp5_ABCDEFGHIJKL = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G , AVGdocp5_H , AVGdocp5_I , AVGdocp5_J , AVGdocp5_K , AVGdocp5_L)
AVGdocp5_ABCDEFGHIJKLM = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G , AVGdocp5_H , AVGdocp5_I , AVGdocp5_J , AVGdocp5_K , AVGdocp5_L , AVGdocp5_M)
AVGdocp5_ABCDEFGHIJKLMN = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G , AVGdocp5_H , AVGdocp5_I , AVGdocp5_J , AVGdocp5_K , AVGdocp5_L , AVGdocp5_M , AVGdocp5_N)
AVGdocp5_ABCDEFGHIJKLMNO = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G , AVGdocp5_H , AVGdocp5_I , AVGdocp5_J , AVGdocp5_K , AVGdocp5_L , AVGdocp5_M , AVGdocp5_N , AVGdocp5_O)
AVGdocp5_ABCDEFGHIJKLMNOP = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G , AVGdocp5_H , AVGdocp5_I , AVGdocp5_J , AVGdocp5_K , AVGdocp5_L , AVGdocp5_M , AVGdocp5_N , AVGdocp5_O , AVGdocp5_P)
AVGdocp5_ABCDEFGHIJKLMNOPQ =  math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G , AVGdocp5_H , AVGdocp5_I , AVGdocp5_J , AVGdocp5_K , AVGdocp5_L , AVGdocp5_M , AVGdocp5_N , AVGdocp5_O , AVGdocp5_P , AVGdocp5_Q)
AVGdocp5_ABCDEFGHIJKLMNOPQR = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G , AVGdocp5_H , AVGdocp5_I , AVGdocp5_J , AVGdocp5_K , AVGdocp5_L , AVGdocp5_M , AVGdocp5_N , AVGdocp5_O , AVGdocp5_P , AVGdocp5_Q , AVGdocp5_R)
AVGdocp5_ABCDEFGHIJKLMNOPQRS = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G , AVGdocp5_H , AVGdocp5_I , AVGdocp5_J , AVGdocp5_K , AVGdocp5_L , AVGdocp5_M , AVGdocp5_N , AVGdocp5_O , AVGdocp5_P , AVGdocp5_Q , AVGdocp5_R , AVGdocp5_S)
AVGdocp5_ABCDEFGHIJKLMNOPQRST = math.avg (AVGdocp5_A , AVGdocp5_B , AVGdocp5_C , AVGdocp5_D , AVGdocp5_E , AVGdocp5_F , AVGdocp5_G , AVGdocp5_H , AVGdocp5_I , AVGdocp5_J , AVGdocp5_K , AVGdocp5_L , AVGdocp5_M , AVGdocp5_N , AVGdocp5_O , AVGdocp5_P , AVGdocp5_Q , AVGdocp5_R , AVGdocp5_S , AVGdocp5_T)


    //Negative - 

AVGdocn5_A = (docn[4] + docn[3] + docn[2] +docn[1] + docn)/5
AVGdocn5_B = (docn[5] + docn[6] + docn[7] + docn[8] + docn[9])/5
AVGdocn5_C = (docn[14] + docn[13] + docn[12] + docn[11] + docn[10])/5
AVGdocn5_D = (docn[15] + docn[16] + docn[17] +docn[18] + docn[19])/5
AVGdocn5_E = (docn[24] + docn[23] + docn[22] + docn[21] + docn[20])/5
AVGdocn5_F = (docn[25] + docn[26] + docn[27] + docn[28] + docn[29])/5
AVGdocn5_G = (docn[34] + docn[33] + docn[32] + docn[31] + docn[30])/5
AVGdocn5_H = (docn[35] + docn[36] + docn[37] + docn[38] + docn[39])/5
AVGdocn5_I = (docn[44] + docn[43] + docn[42] + docn[41] + docn[40])/5
AVGdocn5_J = (docn[45] + docn[46] + docn[47] + docn[48] + docn[49])/5
AVGdocn5_K = (docn[54] + docn[53] + docn[52] + docn[51] + docn[50])/5
AVGdocn5_L = (docn[55] + docn[56] + docn[57] + docn[58] + docn[59])/5
AVGdocn5_M = (docn[64] + docn[63] + docn[62] + docn[61] + docn[60])/5
AVGdocn5_N = (docn[65] + docn[66] + docn[67] + docn[68] + docn[69])/5
AVGdocn5_O = (docn[74] + docn[73] + docn[72] + docn[71] + docn[70])/5
AVGdocn5_P = (docn[75] + docn[76] + docn[77] + docn[78] + docn[79])/5
AVGdocn5_Q = (docn[84] + docn[83] + docn[82] + docn[81] + docn[80])/5
AVGdocn5_R = (docn[85] + docn[86] + docn[87] + docn[88] + docn[89])/5
AVGdocn5_S = (docn[94] + docn[93] + docn[92] + docn[91] + docn[90])/5
AVGdocn5_T = (docn[95] + docn[96] + docn[97] + docn[98] + docn[99])/5


AVGdocn5_AB = math.avg (AVGdocn5_A, AVGdocn5_B)
AVGdocn5_ABC = math.avg (AVGdocn5_A, AVGdocn5_B, AVGdocn5_C)
AVGdocn5_ABCD = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D)
AVGdocn5_ABCDE = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E)
AVGdocn5_ABCDEF = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F)
AVGdocn5_ABCDEFG = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G)
AVGdocn5_ABCDEFGH = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G , AVGdocn5_H)
AVGdocn5_ABCDEFGHI = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G , AVGdocn5_H , AVGdocn5_I)
AVGdocn5_ABCDEFGHIJ = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G , AVGdocn5_H , AVGdocn5_I , AVGdocn5_J)
AVGdocn5_ABCDEFGHIJK = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G , AVGdocn5_H , AVGdocn5_I , AVGdocn5_J , AVGdocn5_K)
AVGdocn5_ABCDEFGHIJKL = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G , AVGdocn5_H , AVGdocn5_I , AVGdocn5_J , AVGdocn5_K , AVGdocn5_L)
AVGdocn5_ABCDEFGHIJKLM = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G , AVGdocn5_H , AVGdocn5_I , AVGdocn5_J , AVGdocn5_K , AVGdocn5_L , AVGdocn5_M)
AVGdocn5_ABCDEFGHIJKLMN = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G , AVGdocn5_H , AVGdocn5_I , AVGdocn5_J , AVGdocn5_K , AVGdocn5_L , AVGdocn5_M , AVGdocn5_N)
AVGdocn5_ABCDEFGHIJKLMNO = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G , AVGdocn5_H , AVGdocn5_I , AVGdocn5_J , AVGdocn5_K , AVGdocn5_L , AVGdocn5_M , AVGdocn5_N , AVGdocn5_O)
AVGdocn5_ABCDEFGHIJKLMNOP = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G , AVGdocn5_H , AVGdocn5_I , AVGdocn5_J , AVGdocn5_K , AVGdocn5_L , AVGdocn5_M , AVGdocn5_N , AVGdocn5_O , AVGdocn5_P)
AVGdocn5_ABCDEFGHIJKLMNOPQ =  math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G , AVGdocn5_H , AVGdocn5_I , AVGdocn5_J , AVGdocn5_K , AVGdocn5_L , AVGdocn5_M , AVGdocn5_N , AVGdocn5_O , AVGdocn5_P , AVGdocn5_Q)
AVGdocn5_ABCDEFGHIJKLMNOPQR = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G , AVGdocn5_H , AVGdocn5_I , AVGdocn5_J , AVGdocn5_K , AVGdocn5_L , AVGdocn5_M , AVGdocn5_N , AVGdocn5_O , AVGdocn5_P , AVGdocn5_Q , AVGdocn5_R)
AVGdocn5_ABCDEFGHIJKLMNOPQRS = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G , AVGdocn5_H , AVGdocn5_I , AVGdocn5_J , AVGdocn5_K , AVGdocn5_L , AVGdocn5_M , AVGdocn5_N , AVGdocn5_O , AVGdocn5_P , AVGdocn5_Q , AVGdocn5_R , AVGdocn5_S)
AVGdocn5_ABCDEFGHIJKLMNOPQRST = math.avg (AVGdocn5_A , AVGdocn5_B , AVGdocn5_C , AVGdocn5_D , AVGdocn5_E , AVGdocn5_F , AVGdocn5_G , AVGdocn5_H , AVGdocn5_I , AVGdocn5_J , AVGdocn5_K , AVGdocn5_L , AVGdocn5_M , AVGdocn5_N , AVGdocn5_O , AVGdocn5_P , AVGdocn5_Q , AVGdocn5_R , AVGdocn5_S , AVGdocn5_T)

//Array Series
 
    // Positive +
doc_p = array.new_float(100, len1),                 
array.insert(doc_p, 0 , docn),
array.insert(doc_p, 1 , (docp[1] + docn)/2),
array.insert(doc_p, 2 , (docp[2] + docp[1] + docn)/3),
array.insert(doc_p, 3 , (docp[3] + docp[2] + docp[1] + docn)/4),
array.insert(doc_p, 4 , AVGdocp5_A),
array.insert(doc_p, 5 , (AVGdocp5_A + docp[5])/2),
array.insert(doc_p, 6 , (AVGdocp5_A + docp[6] + docp[5])/3),
array.insert(doc_p, 7 , (AVGdocp5_A + docp[7] + docp[6] + docp[5])/4),
array.insert(doc_p, 8 , (AVGdocp5_A + docp[8] + docp[7] + docp[6] + docp[5])/5),
array.insert(doc_p, 9 , (AVGdocp5_AB)),
array.insert(doc_p, 10 , (AVGdocp5_AB + docp[10] )/2),
array.insert(doc_p, 11 , (AVGdocp5_AB + docp[11] + docp[10] )/3),
array.insert(doc_p, 12 , (AVGdocp5_AB + docp[12] + docp[11] + docp[10] )/4),
array.insert(doc_p, 13 , (AVGdocp5_AB + docp[13] + docp[12] + docp[11] + docp[10] )/5),
array.insert(doc_p, 14 , (AVGdocp5_ABC)),
array.insert(doc_p, 15 , (AVGdocp5_ABC + docp[15]  )/2),
array.insert(doc_p, 16 , (AVGdocp5_ABC + docp[16] + docp[15])/3),
array.insert(doc_p, 17 , (AVGdocp5_ABC + docp[17] + docp[16] + docp[15])/4),
array.insert(doc_p, 18 , (AVGdocp5_ABC + docp[18] + docp[17] + docp[16] + docp[15])/7),
array.insert(doc_p, 19 , (AVGdocp5_ABCD)),
array.insert(doc_p, 20 , (AVGdocp5_ABCD + docp[20]) /2),
array.insert(doc_p, 21 , (AVGdocp5_ABCD + docp[21] + docp[20])/3),
array.insert(doc_p, 22 , (AVGdocp5_ABCD + docp[22] + docp[21] + docp[20] )/4),
array.insert(doc_p, 23 , (AVGdocp5_ABCD + docp[23] + docp[22] + docp[21] + docp[20] )/5),
array.insert(doc_p, 24 , (AVGdocp5_ABCDE)),
array.insert(doc_p, 25 , (AVGdocp5_ABCDE + docp[25] )/2),
array.insert(doc_p, 26 , (AVGdocp5_ABCDE + docp[26] + docp[25])/3),
array.insert(doc_p, 27 , (AVGdocp5_ABCDE + docp[27] + docp[26] + docp[25] )/4),
array.insert(doc_p, 28 , (AVGdocp5_ABCDE + docp[28] + docp[27] + docp[26] + docp[25] )/5),
array.insert(doc_p, 29 , (AVGdocp5_ABCDEF)),
array.insert(doc_p, 30 , (AVGdocp5_ABCDEF + docp[30] )/2),
array.insert(doc_p, 31 , (AVGdocp5_ABCDEF + docp[31] + docp[30] )/3),
array.insert(doc_p, 32 , (AVGdocp5_ABCDEF + docp[32] + docp[31] + docp[30] )/4),
array.insert(doc_p, 33 , (AVGdocp5_ABCDEF + docp[33] + docp[32] + docp[31] + docp[30] )/5),
array.insert(doc_p, 34 , (AVGdocp5_ABCDEFG)),
array.insert(doc_p, 35 , (AVGdocp5_ABCDEFG + docp[35] )/2),
array.insert(doc_p, 36 , (AVGdocp5_ABCDEFG + docp[36] + docp[35] )/3),
array.insert(doc_p, 37 , (AVGdocp5_ABCDEFG + docp[37] + docp[36] + docp[35] )/4),
array.insert(doc_p, 38 , (AVGdocp5_ABCDEFG + docp[38] + docp[37] + docp[36] + docp[35] )/5),
array.insert(doc_p, 39 , (AVGdocp5_ABCDEFGH )),
array.insert(doc_p, 40 , (AVGdocp5_ABCDEFGH + docp[40] )/2),
array.insert(doc_p, 41 , (AVGdocp5_ABCDEFGH + docp[41] + docp[40])/3),
array.insert(doc_p, 42 , (AVGdocp5_ABCDEFGH + docp[42] + docp[41] + docp[40])/4),
array.insert(doc_p, 43 , (AVGdocp5_ABCDEFGH + docp[43] + docp[42] + docp[41] + docp[40])/5),
array.insert(doc_p, 44 , (AVGdocp5_ABCDEFGHI)),
array.insert(doc_p, 45 , (AVGdocp5_ABCDEFGHI + docp[45] )/2),
array.insert(doc_p, 46 , (AVGdocp5_ABCDEFGHI + docp[46] + docp[45] )/3),
array.insert(doc_p, 47 , (AVGdocp5_ABCDEFGHI + docp[47] + docp[46] + docp[45] )/4),
array.insert(doc_p, 48 , (AVGdocp5_ABCDEFGHI + docp[48] + docp[47] + docp[46] + docp[45] )/5),
array.insert(doc_p, 49 , (AVGdocp5_ABCDEFGHIJ)),
array.insert(doc_p, 50 , (AVGdocp5_ABCDEFGHIJ + docp[50])/2),
array.insert(doc_p, 51 , (AVGdocp5_ABCDEFGHIJ + docp[51] + docp[50] )/3),
array.insert(doc_p, 52 , (AVGdocp5_ABCDEFGHIJ + docp[52] + docp[51] + docp[50] )/4),
array.insert(doc_p, 53 , (AVGdocp5_ABCDEFGHIJ + docp[53] + docp[52] + docp[51] + docp[50] )/5),
array.insert(doc_p, 54 , (AVGdocp5_ABCDEFGHIJK)),
array.insert(doc_p, 55 , (AVGdocp5_ABCDEFGHIJK + docp[55] )/2),
array.insert(doc_p, 56 , (AVGdocp5_ABCDEFGHIJK + docp[56] + docp[55] )/3),
array.insert(doc_p, 57 , (AVGdocp5_ABCDEFGHIJK + docp[57] + docp[56] + docp[55] )/4),
array.insert(doc_p, 58 , (AVGdocp5_ABCDEFGHIJK + docp[58] + docp[57] + docp[56] + docp[55] )/5),
array.insert(doc_p, 59 , (AVGdocp5_ABCDEFGHIJKL)),
array.insert(doc_p, 60 , (AVGdocp5_ABCDEFGHIJKL + docp[60] )/2),
array.insert(doc_p, 61 , (AVGdocp5_ABCDEFGHIJKL + docp[61] + docp[60] )/3),
array.insert(doc_p, 62 , (AVGdocp5_ABCDEFGHIJKL + docp[62] + docp[61] + docp[60] )/4),
array.insert(doc_p, 63 , (AVGdocp5_ABCDEFGHIJKL + docp[63] + docp[62] + docp[61] + docp[60] )/5),
array.insert(doc_p, 64 , (AVGdocp5_ABCDEFGHIJKLM)),
array.insert(doc_p, 65 , (AVGdocp5_ABCDEFGHIJKLM + docp[65] )/2),
array.insert(doc_p, 66 , (AVGdocp5_ABCDEFGHIJKLM + docp[66] + docp[65] )/3),
array.insert(doc_p, 67 , (AVGdocp5_ABCDEFGHIJKLM + docp[67] + docp[66] + docp[65] )/4),
array.insert(doc_p, 68 , (AVGdocp5_ABCDEFGHIJKLM + docp[68] + docp[67] + docp[66] + docp[65] )/5),
array.insert(doc_p, 69 , (AVGdocp5_ABCDEFGHIJKLMN)),
array.insert(doc_p, 70 , (AVGdocp5_ABCDEFGHIJKLMN + docp[70] )/2),
array.insert(doc_p, 71 , (AVGdocp5_ABCDEFGHIJKLMN + docp[71] + docp[70] )/3),
array.insert(doc_p, 72 , (AVGdocp5_ABCDEFGHIJKLMN + docp[72] + docp[71] + docp[70] )/4),
array.insert(doc_p, 73 , (AVGdocp5_ABCDEFGHIJKLMN + docp[73] + docp[72] + docp[71] + docp[70] )/5),
array.insert(doc_p, 74 , (AVGdocp5_ABCDEFGHIJKLMNO)),
array.insert(doc_p, 75 , (AVGdocp5_ABCDEFGHIJKLMN + docp[75] )/2),
array.insert(doc_p, 76 , (AVGdocp5_ABCDEFGHIJKLMN + docp[76] + docp[75] )/3),
array.insert(doc_p, 77 , (AVGdocp5_ABCDEFGHIJKLMN + docp[77] + docp[76] + docp[75] )/4),
array.insert(doc_p, 78 , (AVGdocp5_ABCDEFGHIJKLMN + docp[78] + docp[77] + docp[76] + docp[75] )/5),
array.insert(doc_p, 79 , (AVGdocp5_ABCDEFGHIJKLMNOP)),
array.insert(doc_p, 80 , (AVGdocp5_ABCDEFGHIJKLMNOP + docp[80])/2),
array.insert(doc_p, 81 , (AVGdocp5_ABCDEFGHIJKLMNOP + docp[81] + docp[80])/3),
array.insert(doc_p, 82 , (AVGdocp5_ABCDEFGHIJKLMNOP + docp[82] + docp[81] + docp[80])/4),
array.insert(doc_p, 83 , (AVGdocp5_ABCDEFGHIJKLMNOP + docp[83] + docp[82] + docp[81] + docp[80] )/5),
array.insert(doc_p, 84 , (AVGdocp5_ABCDEFGHIJKLMNOPQ)),
array.insert(doc_p, 85 , (AVGdocp5_ABCDEFGHIJKLMNOPQ + docp[85] )/2),
array.insert(doc_p, 86 , (AVGdocp5_ABCDEFGHIJKLMNOPQ + docp[86] + docp[85] )/3),
array.insert(doc_p, 87 , (AVGdocp5_ABCDEFGHIJKLMNOPQ + docp[87] + docp[86] + docp[85] )/4),
array.insert(doc_p, 88 , (AVGdocp5_ABCDEFGHIJKLMNOPQ + docp[88] + docp[87] + docp[86] + docp[85] )/5),
array.insert(doc_p, 89 , (AVGdocp5_ABCDEFGHIJKLMNOPQR)),
array.insert(doc_p, 90 , (AVGdocp5_ABCDEFGHIJKLMNOPQR + docp[90] )/2),
array.insert(doc_p, 91 , (AVGdocp5_ABCDEFGHIJKLMNOPQR + docp[91] + docp[90] )/3),
array.insert(doc_p, 92 , (AVGdocp5_ABCDEFGHIJKLMNOPQR + docp[92] + docp[91] + docp[90])/4),
array.insert(doc_p, 93 , (AVGdocp5_ABCDEFGHIJKLMNOPQR + docp[93] + docp[92] + docp[91] + docp[90])/5),
array.insert(doc_p, 94 , (AVGdocp5_ABCDEFGHIJKLMNOPQRS)),
array.insert(doc_p, 95 , (AVGdocp5_ABCDEFGHIJKLMNOPQRS + docp[95] )/2),
array.insert(doc_p, 96 , (AVGdocp5_ABCDEFGHIJKLMNOPQRS + docp[96] + docp[95] )/3),
array.insert(doc_p, 97 , (AVGdocp5_ABCDEFGHIJKLMNOPQRS + docp[97] + docp[96] + docp[95] )/4),
array.insert(doc_p, 98 , (AVGdocp5_ABCDEFGHIJKLMNOPQRS + docp[98] + docp[97] + docp[96] + docp[95] )/5),
array.insert(doc_p, 99 , (AVGdocp5_ABCDEFGHIJKLMNOPQRST))

    // Negative -

doc_n = array.new_float(100, len1),                 
array.insert(doc_n, 0 , docn),
array.insert(doc_n, 1 , (docn[1] + docn)/2),
array.insert(doc_n, 2 , (docn[2] + docn[1] + docn)/3),
array.insert(doc_n, 3 , (docn[3] + docn[2] + docn[1] + docn)/4),
array.insert(doc_n, 4 , AVGdocn5_A),
array.insert(doc_n, 5 , (AVGdocn5_A + docn[5])/2),
array.insert(doc_n, 6 , (AVGdocn5_A + docn[6] + docn[5])/3),
array.insert(doc_n, 7 , (AVGdocn5_A + docn[7] + docn[6] + docn[5])/4),
array.insert(doc_n, 8 , (AVGdocn5_A + docn[8] + docn[7] + docn[6] + docn[5])/5),
array.insert(doc_n, 9 , (AVGdocn5_AB)),
array.insert(doc_n, 10 , (AVGdocn5_AB + docn[10] )/2),
array.insert(doc_n, 11 , (AVGdocn5_AB + docn[11] + docn[10] )/3),
array.insert(doc_n, 12 , (AVGdocn5_AB + docn[12] + docn[11] + docn[10] )/4),
array.insert(doc_n, 13 , (AVGdocn5_AB + docn[13] + docn[12] + docn[11] + docn[10] )/5),
array.insert(doc_n, 14 , (AVGdocn5_ABC)),
array.insert(doc_n, 15 , (AVGdocn5_ABC + docn[15]  )/2),
array.insert(doc_n, 16 , (AVGdocn5_ABC + docn[16] + docn[15])/3),
array.insert(doc_n, 17 , (AVGdocn5_ABC + docn[17] + docn[16] + docn[15])/4),
array.insert(doc_n, 18 , (AVGdocn5_ABC + docn[18] + docn[17] + docn[16] + docn[15])/7),
array.insert(doc_n, 19 , (AVGdocn5_ABCD)),
array.insert(doc_n, 20 , (AVGdocn5_ABCD + docn[20]) /2),
array.insert(doc_n, 21 , (AVGdocn5_ABCD + docn[21] + docn[20])/3),
array.insert(doc_n, 22 , (AVGdocn5_ABCD + docn[22] + docn[21] + docn[20] )/4),
array.insert(doc_n, 23 , (AVGdocn5_ABCD + docn[23] + docn[22] + docn[21] + docn[20] )/5),
array.insert(doc_n, 24 , (AVGdocn5_ABCDE)),
array.insert(doc_n, 25 , (AVGdocn5_ABCDE + docn[25] )/2),
array.insert(doc_n, 26 , (AVGdocn5_ABCDE + docn[26] + docn[25])/3),
array.insert(doc_n, 27 , (AVGdocn5_ABCDE + docn[27] + docn[26] + docn[25] )/4),
array.insert(doc_n, 28 , (AVGdocn5_ABCDE + docn[28] + docn[27] + docn[26] + docn[25] )/5),
array.insert(doc_n, 29 , (AVGdocn5_ABCDEF)),
array.insert(doc_n, 30 , (AVGdocn5_ABCDEF + docn[30] )/2),
array.insert(doc_n, 31 , (AVGdocn5_ABCDEF + docn[31] + docn[30] )/3),
array.insert(doc_n, 32 , (AVGdocn5_ABCDEF + docn[32] + docn[31] + docn[30] )/4),
array.insert(doc_n, 33 , (AVGdocn5_ABCDEF + docn[33] + docn[32] + docn[31] + docn[30] )/5),
array.insert(doc_n, 34 , (AVGdocn5_ABCDEFG)),
array.insert(doc_n, 35 , (AVGdocn5_ABCDEFG + docn[35] )/2),
array.insert(doc_n, 36 , (AVGdocn5_ABCDEFG + docn[36] + docn[35] )/3),
array.insert(doc_n, 37 , (AVGdocn5_ABCDEFG + docn[37] + docn[36] + docn[35] )/4),
array.insert(doc_n, 38 , (AVGdocn5_ABCDEFG + docn[38] + docn[37] + docn[36] + docn[35] )/5),
array.insert(doc_n, 39 , (AVGdocn5_ABCDEFGH )),
array.insert(doc_n, 40 , (AVGdocn5_ABCDEFGH + docn[40] )/2),
array.insert(doc_n, 41 , (AVGdocn5_ABCDEFGH + docn[41] + docn[40])/3),
array.insert(doc_n, 42 , (AVGdocn5_ABCDEFGH + docn[42] + docn[41] + docn[40])/4),
array.insert(doc_n, 43 , (AVGdocn5_ABCDEFGH + docn[43] + docn[42] + docn[41] + docn[40])/5),
array.insert(doc_n, 44 , (AVGdocn5_ABCDEFGHI)),
array.insert(doc_n, 45 , (AVGdocn5_ABCDEFGHI + docn[45] )/2),
array.insert(doc_n, 46 , (AVGdocn5_ABCDEFGHI + docn[46] + docn[45] )/3),
array.insert(doc_n, 47 , (AVGdocn5_ABCDEFGHI + docn[47] + docn[46] + docn[45] )/4),
array.insert(doc_n, 48 , (AVGdocn5_ABCDEFGHI + docn[48] + docn[47] + docn[46] + docn[45] )/5),
array.insert(doc_n, 49 , (AVGdocn5_ABCDEFGHIJ)),
array.insert(doc_n, 50 , (AVGdocn5_ABCDEFGHIJ + docn[50])/2),
array.insert(doc_n, 51 , (AVGdocn5_ABCDEFGHIJ + docn[51] + docn[50] )/3),
array.insert(doc_n, 52 , (AVGdocn5_ABCDEFGHIJ + docn[52] + docn[51] + docn[50] )/4),
array.insert(doc_n, 53 , (AVGdocn5_ABCDEFGHIJ + docn[53] + docn[52] + docn[51] + docn[50] )/5),
array.insert(doc_n, 54 , (AVGdocn5_ABCDEFGHIJK)),
array.insert(doc_n, 55 , (AVGdocn5_ABCDEFGHIJK + docn[55] )/2),
array.insert(doc_n, 56 , (AVGdocn5_ABCDEFGHIJK + docn[56] + docn[55] )/3),
array.insert(doc_n, 57 , (AVGdocn5_ABCDEFGHIJK + docn[57] + docn[56] + docn[55] )/4),
array.insert(doc_n, 58 , (AVGdocn5_ABCDEFGHIJK + docn[58] + docn[57] + docn[56] + docn[55] )/5),
array.insert(doc_n, 59 , (AVGdocn5_ABCDEFGHIJKL)),
array.insert(doc_n, 60 , (AVGdocn5_ABCDEFGHIJKL + docn[60] )/2),
array.insert(doc_n, 61 , (AVGdocn5_ABCDEFGHIJKL + docn[61] + docn[60] )/3),
array.insert(doc_n, 62 , (AVGdocn5_ABCDEFGHIJKL + docn[62] + docn[61] + docn[60] )/4),
array.insert(doc_n, 63 , (AVGdocn5_ABCDEFGHIJKL + docn[63] + docn[62] + docn[61] + docn[60] )/5),
array.insert(doc_n, 64 , (AVGdocn5_ABCDEFGHIJKLM)),
array.insert(doc_n, 65 , (AVGdocn5_ABCDEFGHIJKLM + docn[65] )/2),
array.insert(doc_n, 66 , (AVGdocn5_ABCDEFGHIJKLM + docn[66] + docn[65] )/3),
array.insert(doc_n, 67 , (AVGdocn5_ABCDEFGHIJKLM + docn[67] + docn[66] + docn[65] )/4),
array.insert(doc_n, 68 , (AVGdocn5_ABCDEFGHIJKLM + docn[68] + docn[67] + docn[66] + docn[65] )/5),
array.insert(doc_n, 69 , (AVGdocn5_ABCDEFGHIJKLMN)),
array.insert(doc_n, 70 , (AVGdocn5_ABCDEFGHIJKLMN + docn[70] )/2),
array.insert(doc_n, 71 , (AVGdocn5_ABCDEFGHIJKLMN + docn[71] + docn[70] )/3),
array.insert(doc_n, 72 , (AVGdocn5_ABCDEFGHIJKLMN + docn[72] + docn[71] + docn[70] )/4),
array.insert(doc_n, 73 , (AVGdocn5_ABCDEFGHIJKLMN + docn[73] + docn[72] + docn[71] + docn[70] )/5),
array.insert(doc_n, 74 , (AVGdocn5_ABCDEFGHIJKLMNO)),
array.insert(doc_n, 75 , (AVGdocn5_ABCDEFGHIJKLMN + docn[75] )/2),
array.insert(doc_n, 76 , (AVGdocn5_ABCDEFGHIJKLMN + docn[76] + docn[75] )/3),
array.insert(doc_n, 77 , (AVGdocn5_ABCDEFGHIJKLMN + docn[77] + docn[76] + docn[75] )/4),
array.insert(doc_n, 78 , (AVGdocn5_ABCDEFGHIJKLMN + docn[78] + docn[77] + docn[76] + docn[75] )/5),
array.insert(doc_n, 79 , (AVGdocn5_ABCDEFGHIJKLMNOP)),
array.insert(doc_n, 80 , (AVGdocn5_ABCDEFGHIJKLMNOP + docn[80])/2),
array.insert(doc_n, 81 , (AVGdocn5_ABCDEFGHIJKLMNOP + docn[81] + docn[80])/3),
array.insert(doc_n, 82 , (AVGdocn5_ABCDEFGHIJKLMNOP + docn[82] + docn[81] + docn[80])/4),
array.insert(doc_n, 83 , (AVGdocn5_ABCDEFGHIJKLMNOP + docn[83] + docn[82] + docn[81] + docn[80] )/5),
array.insert(doc_n, 84 , (AVGdocn5_ABCDEFGHIJKLMNOPQ)),
array.insert(doc_n, 85 , (AVGdocn5_ABCDEFGHIJKLMNOPQ + docn[85] )/2),
array.insert(doc_n, 86 , (AVGdocn5_ABCDEFGHIJKLMNOPQ + docn[86] + docn[85] )/3),
array.insert(doc_n, 87 , (AVGdocn5_ABCDEFGHIJKLMNOPQ + docn[87] + docn[86] + docn[85] )/4),
array.insert(doc_n, 88 , (AVGdocn5_ABCDEFGHIJKLMNOPQ + docn[88] + docn[87] + docn[86] + docn[85] )/5),
array.insert(doc_n, 89 , (AVGdocn5_ABCDEFGHIJKLMNOPQR)),
array.insert(doc_n, 90 , (AVGdocn5_ABCDEFGHIJKLMNOPQR + docn[90] )/2),
array.insert(doc_n, 91 , (AVGdocn5_ABCDEFGHIJKLMNOPQR + docn[91] + docn[90] )/3),
array.insert(doc_n, 92 , (AVGdocn5_ABCDEFGHIJKLMNOPQR + docn[92] + docn[91] + docn[90])/4),
array.insert(doc_n, 93 , (AVGdocn5_ABCDEFGHIJKLMNOPQR + docn[93] + docn[92] + docn[91] + docn[90])/5),
array.insert(doc_n, 94 , (AVGdocn5_ABCDEFGHIJKLMNOPQRS)),
array.insert(doc_n, 95 , (AVGdocn5_ABCDEFGHIJKLMNOPQRS + docn[95] )/2),
array.insert(doc_n, 96 , (AVGdocn5_ABCDEFGHIJKLMNOPQRS + docn[96] + docn[95] )/3),
array.insert(doc_n, 97 , (AVGdocn5_ABCDEFGHIJKLMNOPQRS + docn[97] + docn[96] + docn[95] )/4),
array.insert(doc_n, 98 , (AVGdocn5_ABCDEFGHIJKLMNOPQRS + docn[98] + docn[97] + docn[96] + docn[95] )/5),
array.insert(doc_n, 99 , (AVGdocn5_ABCDEFGHIJKLMNOPQRST)),


//Variable Declerations 

docAVG_ = math.avg(array.avg(doc_n), array.avg(doc_p))
doc_nV = array.get(doc_n, len1) 
doc_pV = array.get(doc_p, len1) 
coV_sig2_array = ta.variance(docAVG_, len1) - (array.covariance(doc_p, doc_n, len1) - docAVG_)
e = ta.sma(close - (close-coV_sig2_array), len3)
m = ta.mom(close, len3) 
a = ta.alma((close-(close-coV_sig2_array)), len4, 0, 6)

//Plot Functions

plot(a, 'alma', color.red, 1, plot.style_line, display = display.none)
plot(e, 'The RC Average', color.yellow , 1, plot.style_linebr)
plot(m, 'Momentum', m >= e and m >= a and m >= coV_sig2_array ? color.green:(m<= e and m <= a and m <= coV_sig2_array ? color.red:color.teal) , 3, plot.style_linebr )
plot(coV_sig2_array, 'DAP\'s Oscillator', color.aqua , 6)


