NexusFi: Find Your Edge


Home Menu

 





Help to create custom column in watchlist to reflect indicator color


Discussion in ThinkOrSwim

Updated
    1. trending_up 1,366 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread

Help to create custom column in watchlist to reflect indicator color

  #1 (permalink)
 smartguy 
ohio
 
Experience: Intermediate
Platform: tradestation
Trading: es
Posts: 30 since Feb 2010
Thanks Given: 28
Thanks Received: 9

I know the old saying "give a man a fish ...." vs "teach a man to fish ..." but I still seem to be too stupid to code this indicator into a color coded custom watch list column. The code for the indicator is a paint bar indicator that paints the bar red, green, or gray. I want to be able to have a custom colored watch column that shows what color the current bar is. I want to be able to use 2 different custom columns each using a different time frame i.e daily and weekly, daily and 60 min, etc. If someone would be kind enough to actually code this rather then give "hints" I would be very appreciative. Thanks in advance. Here is the code for the paint bar indicator-
 
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);

Started this thread Reply With Quote




Last Updated on January 22, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts