Declare Lower;
# GLOBAL DEFINITIONS
DefineGlobalColor("TrendUp", Color.Cyan);
DefineGlobalColor("TrendDown", Color.Magenta);
input agg = AggregationPeriod.FIVE_MIN;
input agg2 = AggregationPeriod.THIRTY_MIN;
input agg3 = AggregationPeriod.HOUR;
input agg4 = AggregationPeriod.TWO_Hours;;
input agg5 = AggregationPeriod.FOUR_HOURs;
Input apc = 7;
input DotSize = 3;
input n = 6;
def n1 = n + 1;
Input Length1 =3;
Input Length2 =6;
Input Length3 =9;
Input Length4 =12;
Input Length5 =15;
Input Length6 =30;
Input Length7 =45;
Input Length8 =60;
def o = Open(Period = AGG);
def C = Close(Period =AGG);
def o2 = Open(Period = AGG2);
def C2 = Close(Period =AGG2);
def o3 = Open(Period = AGG3);
def C3 = Close(Period =AGG3);
def o4 = Open(Period = AGG4);
def C4 = Close(Period =AGG4);
def o5 = Open(Period = AGG5);
def C5 = Close(Period =AGG5);
Def price =(O+C)/2;
Def Bprice =(O2+C2)/2;
Def Cprice =(O3+C3)/2;
Def Dprice =(O4+C4)/2;
Def Eprice =(O5+C5)/2;
input averageType = AverageType.exponential;
def D1 = MovingAverage(AveragetYPE,Price,length1);
def D2 = MovingAverage(AverageType,price,Length2);
def D3 = MovingAverage(AverageType,price,Length3);
def D4 = MovingAverage(AverageType,price,Length4);
def W1 = MovingAverage(AveragetYPE,Price,length5);
def W2 = MovingAverage(AverageType,price,Length6);
def W3 = MovingAverage(AverageType,price,Length7);
def W4 = MovingAverage(AverageType,price,Length8);
def BD1 = MovingAverage(AveragetYPE,BPrice,length1);
def BD2 = MovingAverage(AverageType,Bprice,Length2);
def BD3 = MovingAverage(AverageType,Bprice,Length3);
def BD4 = MovingAverage(AverageType,Bprice,Length4);
def BW1 = MovingAverage(AveragetYPE,BPrice,length5);
def BW2 = MovingAverage(AverageType,Bprice,Length6);
def BW3 = MovingAverage(AverageType,Bprice,Length7);
def BW4 = MovingAverage(AverageType,Bprice,Length8);
def CD1 = MovingAverage(AveragetYPE,CPrice,length1);
def CD2 = MovingAverage(AverageType,Cprice,Length2);
def CD3 = MovingAverage(AverageType,Cprice,Length3);
def CD4 = MovingAverage(AverageType,Cprice,Length4);
def CW1 = MovingAverage(AveragetYPE,CPrice,length5);
def CW2 = MovingAverage(AverageType,Cprice,Length6);
def CW3 = MovingAverage(AverageType,Cprice,Length7);
def CW4 = MovingAverage(AverageType,Cprice,Length8);
def DD1 = MovingAverage(AveragetYPE,DPrice,length1);
def DD2 = MovingAverage(AverageType,Dprice,Length2);
def DD3 = MovingAverage(AverageType,Dprice,Length3);
def DD4 = MovingAverage(AverageType,Dprice,Length4);
def DW1 = MovingAverage(AveragetYPE,DPrice,length5);
def DW2 = MovingAverage(AverageType,Dprice,Length6);
def DW3 = MovingAverage(AverageType,Dprice,Length7);
def DW4 = MovingAverage(AverageType,Dprice,Length8);
def ED1 = MovingAverage(AveragetYPE,EPrice,length1);
def ED2 = MovingAverage(AverageType,Eprice,Length2);
def ED3 = MovingAverage(AverageType,Eprice,Length3);
def ED4 = MovingAverage(AverageType,Eprice,Length4);
def EW1 = MovingAverage(AveragetYPE,EPrice,length5);
def EW2 = MovingAverage(AverageType,Eprice,Length6);
def EW3 = MovingAverage(AverageType,Eprice,Length7);
def EW4 = MovingAverage(AverageType,Eprice,Length8);
def DCondition1 = If(D1 > D2 and D2 > D3 and D3 > D4, 5,
If((D1 > D2 and D2 > D4 and D4 > D3) or (D1 > D3 and D3 > D2 and D2 > D4) or
(D2 > D1 and D1 > D3 and D3 > D4), 4, If(D2 > D1 and D1 > D4 and D4 > D3, 3,
If((D1 > D3 and D3 > D4 and D4 > D2) or ( D1 > D4 and D4 > D2 and D2 > D3) or
(D2 > D3 and D3 > D1 and D1 > D4) or (D3 > D1 and D1 > D2 and D2 > D4) , 2,
If((D1 > D4 and D4 > D3 and D3 > D2) or (D3 > D2 and D2 > D1 and D1 > D4), 1, 0)))));
def DCondition2 = If(D4 > D3 and D3 > D2 and D2 > D1, -5,
If((D3 > D4 and D4 > D2 and D2 > D1) or (D4 > D2 and D2 > D3 and D3 > D1) or
(D4 > D3 and D3 > D1 and D1 > D2), -4, If(D3 > D4 and D4 > D1 and D1 > D2, -3,
If((D2 > D4 and D4 > D3 and D3 > D1) or (D3 > D2 and D2 > D4 and D4 > D1) or
(D4 > D1 and D1 > D3 and D3 > D2) or (D4 > D2 and D2 > D1 and D1 > D3) , -2,
If((D2 > D3 and D3 > D4 and D4 > D1) or (D4 > D1 and D1 > D2 and D2 > D3), -1, 0)))));
def WCondition1 = If(W1 > W2 and W2 > W3 and W3 > W4, 50,
If((W1 > W2 and W2 > W4 and W4 > W3) or (W1 > W3 and W3 > W2 and W2 > W4) or
(W2 > W1 and W1 > W3 and W3 > W4), 40, If(W2 > W1 and W1 > W4 and W4 > W3, 30,
If((W1 > W3 and W3 > W4 and W4 > W2) or ( W1 > W4 and W4 > W2 and W2 > W3) or
(W2 > W3 and W3 > W1 and W1 > W4) or (W3 > W1 and W1 > W2 and W2 > W4) , 20,
If((W1 > W4 and W4 > W3 and W3 > W2) or (W3 > W2 and W2 > W1 and W1 > W4), 10, 0)))));
def WCondition2 = If(W4 > W3 and W3 > W2 and W2 > W1, -50,
If((W3 > W4 and W4 > W2 and W2 > W1) or (W4 > W2 and W2 > W3 and W3 > W1) or
(W4 > W3 and W3 > W1 and W1 > W2), -40, If(W3 > W4 and W4 > W1 and W1 > W2, -30,
If((W2 > W4 and W4 > W3 and W3 > W1) or (W3 > W2 and W2 > W4 and W4 > W1) or
(W4 > W1 and W1 > W3 and W3 > W2) or (W4 > W2 and W2 > W1 and W1 > W3) , -20,
If((W2 > W3 and W3 > W4 and W4 > W1) or (W4 > W1 and W1 > W2 and W2 > W3), -10, 0)))));
def BDCondition1 = If(BD1 > BD2 and BD2 > BD3 and BD3 > BD4, 5,
If((BD1 > BD2 and BD2 > BD4 and BD4 > BD3) or (BD1 > BD3 and BD3 > BD2 and BD2 > BD4) or
(BD2 > BD1 and BD1 > BD3 and BD3 > BD4), 4, If(BD2 > BD1 and BD1 > BD4 and BD4 > BD3, 3,
If((BD1 > BD3 and BD3 > BD4 and BD4 > BD2) or ( BD1 > BD4 and BD4 > BD2 and BD2 > BD3) or
(BD2 > BD3 and BD3 > BD1 and BD1 > BD4) or (BD3 > BD1 and BD1 > BD2 and BD2 > BD4) , 2,
If((BD1 > BD4 and BD4 > BD3 and BD3 > BD2) or (BD3 > BD2 and BD2 > BD1 and BD1 > BD4), 1, 0)))));
def BDCondition2 = If(BD4 > BD3 and BD3 > BD2 and BD2 > BD1, -5,
If((BD3 > BD4 and BD4 > BD2 and BD2 > BD1) or (BD4 > BD2 and BD2 > BD3 and BD3 > BD1) or
(BD4 > BD3 and BD3 > BD1 and BD1 > BD2), -4, If(BD3 > BD4 and BD4 > BD1 and BD1 > BD2, -3,
If((BD2 > BD4 and BD4 > BD3 and BD3 > BD1) or (BD3 > BD2 and BD2 > BD4 and BD4 > BD1) or
(BD4 > BD1 and BD1 > BD3 and BD3 > BD2) or (BD4 > BD2 and BD2 > BD1 and BD1 > BD3) , -2,
If((BD2 > BD3 and BD3 > BD4 and BD4 > BD1) or (BD4 > BD1 and BD1 > BD2 and BD2 > BD3), -1, 0)))));
def BWCondition1 = If(BW1 > BW2 and BW2 > BW3 and BW3 > BW4, 50,
If((BW1 > BW2 and BW2 > BW4 and BW4 > BW3) or (BW1 > BW3 and BW3 > BW2 and BW2 > BW4) or
(BW2 > BW1 and BW1 > BW3 and BW3 > BW4), 40, If(BW2 > BW1 and BW1 > BW4 and BW4 > BW3, 30,
If((BW1 > BW3 and BW3 > BW4 and BW4 > BW2) or ( BW1 > BW4 and BW4 > BW2 and BW2 > BW3) or
(BW2 > BW3 and BW3 > BW1 and BW1 > BW4) or (BW3 > BW1 and BW1 > BW2 and BW2 > BW4) , 20,
If((BW1 > BW4 and BW4 > BW3 and BW3 > BW2) or (BW3 > BW2 and BW2 > BW1 and BW1 > BW4), 10, 0)))));
def BWCondition2 = If(BW4 > BW3 and BW3 > BW2 and BW2 > BW1, -50,
If((BW3 > BW4 and BW4 > BW2 and BW2 > BW1) or (BW4 > BW2 and BW2 > BW3 and BW3 > BW1) or
(BW4 > BW3 and BW3 > BW1 and BW1 > BW2), -40, If(BW3 > BW4 and BW4 > BW1 and BW1 > BW2, -30,
If((BW2 > BW4 and BW4 > BW3 and BW3 > BW1) or (BW3 > BW2 and BW2 > BW4 and BW4 > BW1) or
(BW4 > BW1 and BW1 > BW3 and BW3 > BW2) or (BW4 > BW2 and BW2 > BW1 and BW1 > BW3) , -20,
If((BW2 > BW3 and BW3 > BW4 and BW4 > BW1) or (BW4 > BW1 and BW1 > BW2 and BW2 > BW3), -10, 0)))));
def CDCondition1 = If(CD1 > CD2 and CD2 > CD3 and CD3 > CD4, 5,
If((CD1 > CD2 and CD2 > CD4 and CD4 > CD3) or (CD1 > CD3 and CD3 > CD2 and CD2 > CD4) or
(CD2 > CD1 and CD1 > CD3 and CD3 > CD4), 4, If(CD2 > CD1 and CD1 > CD4 and CD4 > CD3, 3,
If((CD1 > CD3 and CD3 > CD4 and CD4 > CD2) or ( CD1 > CD4 and CD4 > CD2 and CD2 > CD3) or
(CD2 > CD3 and CD3 > CD1 and CD1 > CD4) or (CD3 > CD1 and CD1 > CD2 and CD2 > CD4) , 2,
If((CD1 > CD4 and CD4 > CD3 and CD3 > CD2) or (CD3 > CD2 and CD2 > CD1 and CD1 > CD4), 1, 0)))));
def CDCondition2 = If(CD4 > CD3 and CD3 > CD2 and CD2 > CD1, -5,
If((CD3 > CD4 and CD4 > CD2 and CD2 > CD1) or (CD4 > CD2 and CD2 > CD3 and CD3 > CD1) or
(CD4 > CD3 and CD3 > CD1 and CD1 > CD2), -4, If(CD3 > CD4 and CD4 > CD1 and CD1 > CD2, -3,
If((CD2 > CD4 and CD4 > CD3 and CD3 > CD1) or (CD3 > CD2 and CD2 > CD4 and CD4 > CD1) or
(CD4 > CD1 and CD1 > CD3 and CD3 > CD2) or (CD4 > CD2 and CD2 > CD1 and CD1 > CD3) , -2,
If((CD2 > CD3 and CD3 > CD4 and CD4 > CD1) or (CD4 > CD1 and CD1 > CD2 and CD2 > CD3), -1, 0)))));
def CWCondition1 = If(CW1 > CW2 and CW2 > CW3 and CW3 > CW4, 50,
If((CW1 > CW2 and CW2 > CW4 and CW4 > CW3) or (CW1 > CW3 and CW3 > CW2 and CW2 > CW4) or
(CW2 > CW1 and CW1 > CW3 and CW3 > CW4), 40, If(CW2 > CW1 and CW1 > CW4 and CW4 > CW3, 30,
If((CW1 > CW3 and CW3 > CW4 and CW4 > CW2) or ( CW1 > CW4 and CW4 > CW2 and CW2 > CW3) or
(CW2 > CW3 and CW3 > CW1 and CW1 > CW4) or (CW3 > CW1 and CW1 > CW2 and CW2 > CW4) , 20,
If((CW1 > CW4 and CW4 > CW3 and CW3 > CW2) or (CW3 > CW2 and CW2 > CW1 and CW1 > CW4), 10, 0)))));
def CWCondition2 = If(CW4 > CW3 and CW3 > CW2 and CW2 > CW1, -50,
If((CW3 > CW4 and CW4 > CW2 and CW2 > CW1) or (CW4 > CW2 and CW2 > CW3 and CW3 > CW1) or
(CW4 > CW3 and CW3 > CW1 and CW1 > CW2), -40, If(CW3 > CW4 and CW4 > CW1 and CW1 > CW2, -30,
If((CW2 > CW4 and CW4 > CW3 and CW3 > CW1) or (CW3 > CW2 and CW2 > CW4 and CW4 > CW1) or
(CW4 > CW1 and CW1 > CW3 and CW3 > CW2) or (CW4 > CW2 and CW2 > CW1 and CW1 > CW3) , -20,
If((CW2 > CW3 and CW3 > CW4 and CW4 > CW1) or (CW4 > CW1 and CW1 > W2 and CW2 > CW3), -10, 0)))));
def DDCondition1 = If(DD1 > DD2 and DD2 > DD3 and DD3 > DD4, 5,
If((DD1 > DD2 and DD2 > DD4 and DD4 > DD3) or (DD1 > DD3 and DD3 > DD2 and DD2 > DD4) or
(DD2 > DD1 and DD1 > DD3 and DD3 > DD4), 4, If(DD2 > DD1 and DD1 > DD4 and DD4 > DD3, 3,
If((DD1 > DD3 and DD3 > DD4 and DD4 > DD2) or ( DD1 > DD4 and DD4 > DD2 and DD2 > DD3) or
(DD2 > DD3 and DD3 > DD1 and DD1 > DD4) or (DD3 > DD1 and DD1 > DD2 and DD2 > DD4) , 2,
If((DD1 > DD4 and DD4 > DD3 and DD3 > DD2) or (DD3 > DD2 and DD2 > DD1 and DD1 > DD4), 1, 0)))));
def DDCondition2 = If(DD4 > DD3 and DD3 > DD2 and DD2 > DD1, -5,
If((DD3 > DD4 and DD4 > DD2 and DD2 > DD1) or (DD4 > DD2 and DD2 > DD3 and DD3 > DD1) or
(DD4 > DD3 and DD3 > DD1 and DD1 > DD2), -4, If(DD3 > DD4 and DD4 > DD1 and DD1 > DD2, -3,
If((DD2 > DD4 and DD4 > DD3 and DD3 > DD1) or (DD3 > DD2 and DD2 > DD4 and DD4 > DD1) or
(DD4 > DD1 and DD1 > DD3 and DD3 > DD2) or (DD4 > DD2 and DD2 > DD1 and DD1 > DD3) , -2,
If((DD2 > DD3 and DD3 > DD4 and DD4 > DD1) or (DD4 > DD1 and DD1 > DD2 and DD2 > DD3), -1, 0)))));
def DWCondition1 = If(DW1 > DW2 and DW2 > DW3 and DW3 > DW4, 50,
If((DW1 > DW2 and DW2 > DW4 and DW4 > DW3) or (DW1 > DW3 and DW3 > DW2 and DW2 > DW4) or
(DW2 > DW1 and DW1 > DW3 and DW3 > DW4), 40, If(DW2 > DW1 and DW1 > DW4 and DW4 > DW3, 30,
If((DW1 > DW3 and DW3 > DW4 and DW4 > DW2) or ( DW1 > DW4 and DW4 > DW2 and DW2 > DW3) or
(DW2 > DW3 and DW3 > DW1 and DW1 > DW4) or (DW3 > DW1 and DW1 > DW2 and DW2 > DW4) , 20,
If((DW1 > DW4 and DW4 > DW3 and DW3 > DW2) or (DW3 > DW2 and DW2 > DW1 and DW1 > DW4), 10, 0)))));
def DWCondition2 = If(DW4 > DW3 and DW3 > DW2 and DW2 > DW1, -50,
If((DW3 > DW4 and DW4 > DW2 and DW2 > DW1) or (DW4 > DW2 and DW2 > DW3 and DW3 > DW1) or
(DW4 > DW3 and DW3 > DW1 and DW1 > DW2), -40, If(DW3 > DW4 and DW4 > DW1 and DW1 > DW2, -30,
If((DW2 > DW4 and DW4 > DW3 and DW3 > DW1) or (DW3 > DW2 and DW2 > DW4 and DW4 > DW1) or
(DW4 > DW1 and DW1 > DW3 and DW3 > DW2) or (DW4 > DW2 and DW2 > DW1 and DW1 > DW3) , -20,
If((DW2 > DW3 and DW3 > DW4 and DW4 > DW1) or (DW4 > DW1 and DW1 > DW2 and DW2 > DW3), -10, 0)))));
def EDCondition1 = If(ED1 > ED2 and ED2 > ED3 and ED3 > D4, 5,
If((ED1 > ED2 and ED2 > ED4 and ED4 > ED3) or (ED1 > ED3 and ED3 > ED2 and ED2 > ED4) or
(ED2 > ED1 and ED1 > ED3 and ED3 > ED4), 4, If(ED2 > ED1 and ED1 > ED4 and ED4 > ED3, 3,
If((ED1 > ED3 and ED3 > ED4 and ED4 > ED2) or ( ED1 > ED4 and ED4 > ED2 and ED2 > ED3) or
(ED2 > ED3 and ED3 > ED1 and ED1 > ED4) or (ED3 > ED1 and ED1 > ED2 and ED2 > ED4) , 2,
If((ED1 > ED4 and ED4 > ED3 and ED3 > ED2) or (ED3 > ED2 and ED2 > ED1 and ED1 > ED4), 1, 0)))));
def EDCondition2 = If(ED4 > ED3 and ED3 > ED2 and ED2 > ED1, -5,
If((ED3 > ED4 and ED4 > ED2 and ED2 > ED1) or (ED4 > ED2 and ED2 > ED3 and ED3 > ED1) or
(ED4 > ED3 and ED3 > ED1 and ED1 > ED2), -4, If(ED3 > ED4 and ED4 > ED1 and ED1 > ED2, -3,
If((ED2 > ED4 and ED4 > ED3 and ED3 > ED1) or (ED3 > ED2 and ED2 > ED4 and ED4 > ED1) or
(ED4 > ED1 and ED1 > ED3 and ED3 > ED2) or (ED4 > ED2 and ED2 > ED1 and ED1 > ED3) , -2,
If((ED2 > ED3 and ED3 > ED4 and ED4 > ED1) or (ED4 > ED1 and ED1 > ED2 and ED2 > ED3), -1, 0)))));
def EWCondition1 = If(EW1 > EW2 and EW2 > EW3 and EW3 > EW4, 50,
If((EW1 > EW2 and EW2 > EW4 and EW4 > EW3) or (EW1 > EW3 and EW3 > EW2 and EW2 > EW4) or
(EW2 > EW1 and EW1 > EW3 and EW3 > EW4), 40, If(EW2 > EW1 and EW1 > EW4 and EW4 > EW3, 30,
If((EW1 > EW3 and EW3 > EW4 and EW4 > EW2) or ( EW1 > EW4 and EW4 > EW2 and EW2 > EW3) or
(EW2 > EW3 and EW3 > EW1 and EW1 > EW4) or (EW3 > EW1 and EW1 > EW2 and EW2 > EW4) , 20,
If((EW1 > EW4 and EW4 > EW3 and EW3 > EW2) or (EW3 > EW2 and EW2 > EW1 and EW1 > EW4), 10, 0)))));
def EWCondition2 = If(EW4 > EW3 and EW3 > EW2 and EW2 > EW1, -50,
If((EW3 > EW4 and EW4 > EW2 and EW2 > EW1) or (EW4 > EW2 and EW2 > EW3 and EW3 > EW1) or
(EW4 > EW3 and EW3 > EW1 and EW1 > EW2), -40, If(EW3 > EW4 and EW4 > EW1 and EW1 > EW2, -30,
If((EW2 > EW4 and EW4 > EW3 and EW3 > EW1) or (EW3 > EW2 and EW2 > EW4 and EW4 > EW1) or
(EW4 > EW1 and EW1 > EW3 and EW3 > EW2) or (EW4 > EW2 and EW2 > EW1 and EW1 > EW3) , -20,
If((EW2 > EW3 and EW3 > EW4 and EW4 > EW1) or (EW4 > EW1 and EW1 > EW2 and EW2 > EW3), -10, 0)))));
def WT = (WCondition1+WCondition2);
def TT = (WCondition1+WCondition2+DCondition1+DCondition2);
def BWT = (BWCondition1+BWCondition2);
def BTT = (BWCondition1+BWCondition2+BDCondition1+BDCondition2);
def CWT = (CWCondition1+CWCondition2);
def CTT = (CWCondition1+CWCondition2+CDCondition1+CDCondition2);
def DWT = (DWCondition1+DWCondition2);
def DTT = (DWCondition1+DWCondition2+DDCondition1+DDCondition2);
def EWT = (EWCondition1+EWCondition2);
def ETT = (EWCondition1+EWCondition2+EDCondition1+EDCondition2);
#####signals
Def AXL = TT crosses above WT;
Def AXS = TT Crosses Below WT;
Def BXL = BTT crosses above BWT;
Def BXS = BTT Crosses Below BWT;
Def CXL = CTT crosses above CWT;
Def CXS = CTT Crosses Below CWT;
Def DXL = DTT crosses above DWT;
Def DXS = DTT Crosses Below DWT;
Def EXL = ETT crosses above EWT;
Def EXS = ETT Crosses Below EWT;
Def Along = TT > WT;
Def Ashort = TT < WT;
Def Blong = BTT > BWT;
Def Bshort = BTT < BWT;
Def Clong = CTT > CWT;
Def Cshort = CTT < CWT;
Def Dlong = DTT > DWT;
Def Dshort = DTT < DWT;
Def Elong = ETT > EWT;
Def Eshort = ETT < EWT;
###########Labels
#AddLabel( ALong, "Agg1 Long " , Color.Green);
#AddLabel( AXL, "Agg 1 Buy" , Color.Light_Green);
#AddLabel( AXS, "Agg 1 Sell" , Color.Light_Red);
#AddLabel( Ashort, "Agg 1 Short" , Color.Red);
#AddLabel( BLong, "Agg 2 Long " , Color.Green);
#AddLabel( BXL, "Agg 2 Buy" , Color.Light_Green);
#AddLabel( BXS, "Agg 2 Sell" , Color.Light_Red);
#AddLabel( Bshort, "Agg 2 Short" , Color.Red);
#AddLabel( CLong, "Agg3 Long " , Color.Green);
#AddLabel( CXL, "Agg 3 Buy" , Color.Light_Green);
#AddLabel( CXS, "Agg 3 Sell" , Color.Light_Red);
#AddLabel( CShort, "Agg 3 Short" , Color.Red);
#AddLabel( DLong, "Agg 4 Long " , Color.Green);
#AddLabel( DXL, "Agg 4 Buy" , Color.Light_Green);
#AddLabel( DXS, "Agg 4 Sell" , Color.Light_Red);
#AddLabel( DShort, "Agg 4 Short" , Color.Red);
#AddLabel( ELong, "Agg 5 Long " , Color.Green);
#AddLabel( EXL, "Agg 5 Buy" , Color.Light_Green);
#AddLabel( EXS, "Agg 5 Sell" , Color.Light_Red);
#AddLabel( EShort, "Agg 5 Short" , Color.Red);
###########Plots
plot R1_Dot = if IsNaN(c) then Double.NaN else 1;
R1_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
R1_Dot.SetLineWeight(DotSize);
R1_Dot.AssignValueColor(if TT < WT then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
plot R2_Dot = if IsNaN(c2) then Double.NaN else 2;
R2_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
R2_Dot.SetLineWeight(DotSize);
R2_Dot.AssignValueColor(if BTT < BWT then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
plot R3_Dot = if IsNaN(c) then Double.NaN else 3;
R3_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
R3_Dot.SetLineWeight(DotSize);
R3_Dot.AssignValueColor(if CTT < CWT then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
plot R4_Dot = if IsNaN(c4) then Double.NaN else 4;
R4_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
R4_Dot.SetLineWeight(DotSize);
R4_Dot.AssignValueColor(if DTT < DWT then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
plot R5_Dot = if IsNaN(c5) then Double.NaN else 5;
R5_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
R5_Dot.SetLineWeight(DotSize);
R5_Dot.AssignValueColor(if ETT < EWT then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
plot MTF_Dot = 6;
MTF_Dot.SetPaintingStrategy(PaintingStrategy.SQUARES);
MTF_Dot.SetLineWeight(lineWeight = 4);
MTF_Dot.DefineColor("Buy", Color.Green);
MTF_Dot.DefineColor("Sell", Color.red);
MTF_Dot.AssignValueColor ( if (ALong + BLong + CLong + DLong + ELong) >= 3 then MTF_Dot.Color("Buy") else MTF_Dot.Color("Sell"));
#assignPriceColor
assignPriceColor( if apc == 1 then if TT < WT then GlobalColor("TrendDown") else GlobalColor("TrendUp") else if apc == 2 then if BTT < BWT then GlobalColor("TrendDown") else GlobalColor("TrendUp") else if apc == 3 then if CTT < CWT then GlobalColor("TrendDown") else GlobalColor("TrendUp") else if apc == 4 then if DTT < DWT then GlobalColor("TrendDown") else GlobalColor("TrendUp") else if apc == 5 then if ETT < EWT then GlobalColor("TrendDown") else GlobalColor("TrendUp") else if apc == 6 then if (ALong + BLong + CLong + DLong + ELong) >= 3 then MTF_Dot.Color("Buy") else MTF_Dot.Color("Sell") else Color.current);