Here is what I want to accomplish. I have a paint bar indicator which colors the bars red, gray, green. I want to add a 2 custom columns to a watch list showing the bars color on a daily basis and another custom column showing the bars color on a weekly basis. Actually I envision using various time frames, but if I see how you do this I should be able to change time frames myself. Below is the actual code of the indicator. Can someone help me code this. Thanks in advance.
Code:
input Trend = yes;
input Cycle = yes;
input Mom = yes;
DefineGlobalColor("UpColor", Color.GREEN);
DefineGlobalColor("DnColor", Color.RED);
DefineGlobalColor("NeutralColor", Color.LiGHT_GRAY);
script MyStdDev {
input data = close;
input length = 12;
input dataType = 2;
def divisor = if dataType == 1 then length else length - 1;
def _std = StDev(data, length);
def _sqrOfStd = _std * _std;
def _sumSqr = _sqrOfStd * length;
def _variancePS = if divisor>0 then _sumSqr / divisor else 0;
#def Value1 = VariancePS( data, Length, count, DataType ).VALUE ;
#def _std = if (Value1>0) then sqrt(value1) else 0;
#plot STD = _std ;
plot STD = If (_variancePS > 0, Sqrt(_variancePS), 0);
}
def BuyEntry = 55;
def SellEntry = 55;
def BuyExit = 20;
def SellExit = 20;
def BuyLevel = Highest(High, BuyEntry)[1];
def SellLevel = Lowest(Low, SellEntry)[1];
#{Sets Switchside to 1 for Buy Trend or -1 for Sell Trend}
def SwitchSide = CompoundValue(1, if (High > BuyLevel and Switchside[1] < 1) then 1 else if Low < SellLevel and switchside[1] > -1 then -1 else switchside[1], 0);
def Trendstatus = Switchside;
def MomLength = 12;
def SmoothLength = 21;
def Candle = (hl2 - hl2[1]);
def CSmooth = Max((ExpAverage(ExpAverage(Absvalue(Candle),MomLength),SmoothLength)),.000001);
def CMom = 100*((ExpAverage(ExpAverage(Candle,MomLength),SmoothLength))/CSmooth);
def MomB = If CMom < 0 then 0 else If CMom >= 0 then 1 else MomB[1];
def MomS = If CMom >= 0 then 0 else If CMom < 0 then -1 else MomS[1];
def FastVar5 = MovAvgExponential(hl2,5);
def SlowVar5 = Average(hl2,8);
def DiffVar5 = FastVar5 - SlowVar5;
def FastVar8 = MovAvgExponential(hl2,8);
def SlowVar8 = Average(hl2,13);
def DiffVar8 = FastVar8 - SlowVar8;
def FastVar13 = MovAvgExponential(hl2,13);
def SlowVar13 = Average(hl2,21);
def DiffVar13 = FastVar13 - SlowVar13;
def FastVar21 = MovAvgExponential(hl2,21);
def SlowVar21 = Average(hl2,35);
def DiffVar21 = FastVar21 - SlowVar21;
def FastVar35 = MovAvgExponential(hl2,35);
def SlowVar35 = Average(hl2,55);
def DiffVar35 = FastVar35 - SlowVar35;
def TotCycle = DiffVar5 + DiffVar8 + DiffVar13 + DiffVar21 + DiffVar35;
def PowerB = If TotCycle < 0 then 0 else If TotCycle >= 0 then 1 else PowerB[1];
def PowerS = If TotCycle >= 0 then 0 else If TotCycle < 0 then -1 else PowerS[1];
def Condition1 = Trend and Cycle and Mom;
def Condition2 = Trend==no and Cycle==no and Mom==no;
def Condition3 = Trend and Cycle == no and Mom==no;
def Condition4 = Trend == no and Cycle==no and Mom;
def Condition5 = Trend == no and Cycle and Mom==no;
def Condition6 = Trend and Cycle and Mom==no;
def Condition7 = Trend and Cycle==no and Mom;
def Condition8 = Trend==no and Cycle and Mom;
def Value1B = Trendstatus + MomB + PowerB;
def Value1S = Trendstatus + MomS + PowerS;
def Value6B = Trendstatus + PowerB;
def Value6S = Trendstatus + PowerS;
def Value7B = Trendstatus + MomB;
def Value7S = Trendstatus + MomS;
def Value8B = PowerB + MomB;
def Value8S = PowerS + MomS;
def Value4B = PowerB + MomB;
def Value4S = PowerS + MomS;
def C1 = Condition1 and Value1B >= 3;
def C2 = Condition1 and Value1S <= -3;
def C3 = Condition1 and Value1B < 3 and Value1S > -3;
def C4 = Condition2;
def C5 = Condition3 and Trendstatus >= 1;
def C6 = Condition3 and Trendstatus <= -1;
def C7 = Condition3 and Trendstatus < 1 and Trendstatus > -1;
def C8 = Condition4 and MomB >= 1;
def C9 = Condition4 and MomS <= -1;
def C10 = Condition4 and MomB < 1 and MomS > -1;
def C11 = Condition5 and PowerB >= 1;
def C12 = Condition5 and PowerS <= -1;
def C13 = Condition5 and PowerB < 1 and PowerS > -1;
def C14 = Condition6 and Value6B >= 2;
def C15 = Condition6 and Value6S <= -2;
def C16 = Condition6 and Value6B < 2 and Value6S > -2;
def C17 = Condition7 and Value7B >= 2;
def C18 = Condition7 and Value7S <= -2;
def C19 = Condition7 and Value7B < 2 and Value7S > -2;
def C20 = Condition8 and Value8B >= 2;
def C21 = Condition8 and Value8S <= -2;
def C22 = Condition8 and Value8B < 2 and Value8S > -2;
AssignPriceColor(
if C1 or C5 or C8 or C11 or C14 or C17 or C20 then globalColor("UpColor")
else if C2 or C6 or C9 or C12 or C15 or C18 or C21 then globalColor("DnColor")
else if C3 or C4 or C7 or C10 or C13 or C16 or C19 or C22 then globalColor("NeutralColor")
else Color.CURRENT);