NexusFi: Find Your Edge


Home Menu

 





SPEAR_CCI_LABELS for TOS


Discussion in ThinkOrSwim

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




 
Search this Thread

SPEAR_CCI_LABELS for TOS

  #1 (permalink)
alagrande
glendale ca usa
 
Posts: 97 since Sep 2017
Thanks Given: 11
Thanks Received: 88

declare lower;

input price = close;
input length = 10;
input averageLength = 3;
input over_bought = 80;
input over_sold = -80;

assert(length >= 2, "'length' must be greater than or equal to 2: " + length);

def sumSqr = fold i = 0 to length with sum do
sum + Sqr((length - i) - fold j = 0 to length with rank
do rank + if GetValue(price, i, length - 1) > GetValue(price, length - j - 1) or GetValue(price, i) == GetValue(price, length - j - 1) and i <= length - j - 1 then 1 else 0);

plot Spearman = 100 * (1 - 6 * sumSqr / (length * (Sqr(length) - 1)));
plot SpearmanAverage = Average(Spearman, averageLength);
plot OverBought = over_bought;
plot ZeroLine = 0;
plot OverSold = over_sold;

AddLabel( Spearman > Spearman [1], " 1 ", color.green);
AddLabel(Spearman < Spearman [1], " 0 ", color.red);
AddLabel (yes, (("-")), if Spearman > Spearman [1] then Color.dark_green else if SpearmanAverage > SpearmanAverage [1] then Color.green else Color.white );

#AddLabel (yes, (("0-")), if Spearman > Spearman [1]and SpearmanAverage > SpearmanAverage [1] then Color.green else Color.white );
AddLabel( Spearman > Spearman [1]and SpearmanAverage > SpearmanAverage [1], " 1 ", color.green);
AddLabel( Spearman < Spearman [1]and SpearmanAverage < SpearmanAverage [1], " 0 ", color.red);

Spearman.SetDefaultColor(GetColor(9));
SpearmanAverage.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(5));
ZeroLine.SetDefaultColor(GetColor(5));
OverSold.SetDefaultColor(GetColor(5));
#################################################################

input lengthCCI = 14;

def priceCCI = close + low + high;
def linDev = lindev(priceCCI, lengthcci);
DEF CCI = if linDev == 0 then 0 else (priceCCI - Average(priceCCI, lengthcci)) / linDev / 0.015;

AddLabel( CCI > CCI [1], " CCI ", color.green);
AddLabel(CCI < CCI [1], " CCI ", color.red);
AddLabel( priceCCI > priceCCI [1], " pCCI ", color.green);
AddLabel(priceCCI < priceCCI [1], " PCCI ", color.red);
AddLabel( linDev > linDev [1], " LIN ", color.green);
AddLabel(linDev < linDev [1], "LIN", color.red);



#input price = close;
input superfast_length = 3;
input superfast_20 = 3;#20
input fast_length = 13;#50
input slow_length = 11;#200
input displace = 0;
## ## ##
#close(period = AggregationPeriod.FIVE_MIN)
def mov_avg4 = ExpAverage( close, superfast_length);
def mov_avg4_10 = ExpAverage( close(period = AggregationPeriod.five_MIN), superfast_length);
def mov_avg4_20 = ExpAverage( close(period = AggregationPeriod.ten_MIN), superfast_length);
def mov_avg4_1h = ExpAverage( close(period = AggregationPeriod.fifteen_MIN), superfast_length);

def mov_avg13 = ExpAverage(price[-displace], fast_length);

def mov_avg20 = ExpAverage( close[-displace], superfast_20);

def mov_avg21 = .5 * ExpAverage(price[-displace], slow_length);
##@@@@@@@@@@@@@@@@@@@@@@@@@@@
########################################################
plot combot22 = if mov_avg13 >= 0 then 0 else Double.NaN;
#combot2.SetPaintingStrategy (PaintingStrategy.SQUARES);
####combo3.SetDefaultColor(Color.black);
combot22.SetLineWeight (4);

combot22.AssignValueColor(if mov_avg4[1] > mov_avg4 and mov_avg13 > mov_avg13[1] then Color.PINK else if mov_avg20[1] > mov_avg20 then Color.RED else Color.GREEN);
##@@@@@@@@@@@@@

#########
plot combo10 = if mov_avg13 >= 0 then -10 else Double.NaN;
#combo3.SetPaintingStrategy (PaintingStrategy.SQUARES);
####combo3.SetDefaultColor(Color.black);
combo10.SetLineWeight (4);

combo10.AssignValueColor(if mov_avg4_10 > mov_avg4_10[10] and mov_avg4_10[10] < mov_avg13 then Color.GREEN else if mov_avg4_10 > mov_avg4_10[10] then Color.DARK_GREEN else Color.RED);

###################


###################

plot combo20 = if mov_avg13 >= 0 then -20 else Double.NaN;
#combo3.SetPaintingStrategy (PaintingStrategy.SQUARES);
####combo3.SetDefaultColor(Color.black);
combo20.SetLineWeight (4);

combo20.AssignValueColor(if mov_avg4_20 > mov_avg4_20[20] and mov_avg4_20[20] < mov_avg13 then Color.GREEN else if mov_avg4_20 > mov_avg4_20[20] then Color.DARK_GREEN else Color.RED);
###################

plot combo1h = if mov_avg13 >= 0 then -30 else Double.NaN;
#combo3.SetPaintingStrategy (PaintingStrategy.SQUARES);
####combo3.SetDefaultColor(Color.black);
combo1h.SetLineWeight (4);

combo1h.AssignValueColor(if mov_avg4_1h > mov_avg4_1h[60] and mov_avg4_1h[60] < mov_avg13 then Color.GREEN else if mov_avg4_1h > mov_avg4_1h[60] then Color.DARK_GREEN else Color.RED);

#END CODE

Reply With Quote




Last Updated on April 27, 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