Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Updated June 18, 2020
Top Posters
looks_one
mcamilapaez
with 4 posts (0 thanks)
looks_two
rmejia
with 3 posts (0 thanks)
looks_3
meeks
with 2 posts (0 thanks)
looks_4
JayC
with 1 posts (0 thanks)
trending_up
24,608 views
thumb_up
0 thanks given
group
6 followers
forum
11 posts
attach_file
2 attachments
June 11th, 2014, 11:33 AM
San Jose, Costa Rica
Posts: 5 since May 2014
Thanks Given: 3
Thanks Received: 0
Does someone know how to change the color on TOS chart bars once two different conditions have been met?
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
June 11th, 2014, 11:39 AM
Puerto Rico
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: Options
Posts: 379 since Oct 2010
Thanks Given: 3,614
Thanks Received: 441
June 11th, 2014, 12:16 PM
San Jose, Costa Rica
Posts: 5 since May 2014
Thanks Given: 3
Thanks Received: 0
Thanks!! I have already tried those instructios unsuccessfully.
June 11th, 2014, 12:34 PM
Puerto Rico
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: Options
Posts: 379 since Oct 2010
Thanks Given: 3,614
Thanks Received: 441
Post the code you are trying to edit to see what's up.
June 11th, 2014, 03:00 PM
San Jose, Costa Rica
Posts: 5 since May 2014
Thanks Given: 3
Thanks Received: 0
What I want to do is find the price bar in which there is divergence between price and momentum (28) (over the last 60 perios). Once a divergence is present I want either the price bar to be colored (red for bear divergence/blue for bull) or highlight it somehow...
And it is not working correctly..
declare upper;
INPUT Price = CLOSE;
AssignBackgroundColor(Color.BLACK);
def mom28 = price-price[28];
def swinghigh=highest(60);
def swinglow=lowest(60);
def swingmomhigh=highest(mom28,60);
def swingmomlow=lowest(mom28,60);
def MOMBEAR=mom28<swingmomhigh;
def MOMBULL=mom28>swingmomlow;
Assignpricecolor(if swinghigh then (if MOMBEAR then color.red else color.white) else color.white);
Assignpricecolor(if swinglow then ( if MOMBULL then color.cyan else color.white) else color.white);
Thanks for your help!
June 11th, 2014, 03:48 PM
Puerto Rico
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: Options
Posts: 379 since Oct 2010
Thanks Given: 3,614
Thanks Received: 441
This is a code I have previously worked on; not sure if it is similar to what you are looking for regarding Momentum .
It is the default Momentum indicator with divergence . I set it to 28 length and bars back 60 for the image. The code is a mess, I have several experiments going on in it, have not cleaned it. Can be a starting point if similar to what you need.
Code
declare lower;
input length = 12;
input price = close;
Assert(length > 0, "'length' must be positive: " + length);
plot Momentum = price - price[length];
plot ZeroLine = 0;
#Momentum.SetDefaultColor(Color.Black);
Momentum.AssignValueColor(if Momentum > ZeroLine then Color.Green else Color.Red);
Momentum.setLineWeight(3);
#ZeroLine.SetDefaultColor(Color.Dark_Gray);
ZeroLine.AssignValueColor(if Momentum > ZeroLine then Color.Green else Color.Red);
ZeroLine.setLineWeight(2);
#AddCloud(Momentum, ZeroLine > 0, CreateColor(0, 80, 0), CreateColor(80, 0, 0));
AddCloud(Momentum, ZeroLine > 0, CreateColor(153,255,153), CreateColor(255,153,153));
input BarsBack = 60;
input MomAvgLength = 20;
input PaintBars = No;
plot MomAvg = ExpAverage(Momentum, MomAvgLength);
MomAvg.SetDefaultColor(CreateColor(51,51,51));
MomAvg.SetLineWeight(2);
MomAvg.SetStyle(Curve.Short_Dash);
plot DivergeTop = if Momentum>0 and Momentum<Momentum[1] and Momentum[1]>Momentum[2] and Momentum<highest(Momentum,BarsBack) and highest(Close,5) > highest(Close[6],BarsBack) then highest(Momentum,barsBack) else double.nan;
plot DivergeBottom = if Momentum<0 and Momentum>Momentum[1] and Momentum[1]<Momentum[2] and Momentum>lowest(Momentum,BarsBack)and lowest(Close,5) < lowest(Close[6],BarsBack) then lowest(Momentum,BarsBack) else double.nan;
DivergeTop.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
DivergeTop.SetLineWeight(5);
DivergeTop.SetDefaultColor(GetColor(5));
DivergeBottom.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
DivergeBottom.SetLineWeight(5);
DivergeBottom.SetDefaultColor(GetColor(6));
AssignPriceColor (if !PaintBars then Color.CURRENT else if Momentum > 0 and Momentum < Momentum[1] and Momentum[1] > Momentum[2] and Momentum < Highest(Momentum, BarsBack) and Highest(close, 5) > Highest(close[6], BarsBack) then color.Red else if Momentum < 0 and Momentum > Momentum[1] and Momentum[1] < Momentum[2] and Momentum > Lowest(Momentum, BarsBack) and Lowest(close, 5) < Lowest(close[6], BarsBack) then color.Cyan else Color.Current);
#AssignPriceColor (if !PaintBars then Color.CURRENT else if Momentum > 0 and Momentum < Momentum[1] and Momentum[1] > Momentum[2] and Momentum < Highest(Momentum, BarsBack) and Highest(close, 5) > Highest(close[6], BarsBack) then color.Red else if Momentum < 0 and Momentum > Momentum[1] and Momentum[1] < Momentum[2] and Momentum > Lowest(Momentum, BarsBack) and Lowest(close, 5) < Lowest(close[6], BarsBack) then color.Green else if Momentum >= 0 then if Momentum > Momentum[1] then Color.Current else Color.Current else if Momentum < Momentum[1] then Color.Current else Color.Current);
June 11th, 2014, 05:43 PM
San Jose, Costa Rica
Posts: 5 since May 2014
Thanks Given: 3
Thanks Received: 0
Thank you so much!
I will try it and Tell you then....
February 9th, 2019, 09:56 AM
Bakersfield
Posts: 7 since Feb 2019
Thanks Given: 0
Thanks Received: 0
Im looking for something similar, instead I want my price candles to turn Green when the Slow Stochastic K period crosses above the D period, & Red when the K period crosses below the D period.
June 15th, 2020, 09:08 AM
Cliffside Park, New Jersey
Posts: 2 since Jun 2020
Thanks Given: 0
Thanks Received: 0
Hello,
I'm trying to create a script where color of price bar is blue solely based on the time.
ie. on 30 min timeframe; 9:30AM - 10:00AM & 1:30PM - 2:00PM price bar is blue (regardless of price action ), all else remain green/red (depending on price action).
Can anyone help with this?
June 17th, 2020, 10:08 AM
Los Angeles (CA)
Experience: Master
Platform: ThinkOrSwim
Trading: Currency Future, Stocks
Posts: 34 since Apr 2019
Thanks Given: 1
Thanks Received: 40
rmejia
This is a code I have previously worked on; not sure if it is similar to what you are looking for regarding
Momentum .
It is the default Momentum indicator with
divergence . I set it to 28 length and bars back 60 for the image. The code is a mess, I have several experiments going on in it, have not cleaned it. Can be a starting point if similar to what you need.
Code
declare lower;
input length = 12;
input price = close;
Assert(length > 0, "'length' must be positive: " + length);
plot Momentum = price - price[length];
plot ZeroLine = 0;
#Momentum.SetDefaultColor(Color.Black);
Momentum.AssignValueColor(if Momentum > ZeroLine then Color.Green else Color.Red);
Momentum.setLineWeight(3);
#ZeroLine.SetDefaultColor(Color.Dark_Gray);
ZeroLine.AssignValueColor(if Momentum > ZeroLine then Color.Green else Color.Red);
ZeroLine.setLineWeight(2);
#AddCloud(Momentum, ZeroLine > 0, CreateColor(0, 80, 0), CreateColor(80, 0, 0));
AddCloud(Momentum, ZeroLine > 0, CreateColor(153,255,153), CreateColor(255,153,153));
input BarsBack = 60;
input MomAvgLength = 20;
input PaintBars = No;
plot MomAvg = ExpAverage(Momentum, MomAvgLength);
MomAvg.SetDefaultColor(CreateColor(51,51,51));
MomAvg.SetLineWeight(2);
MomAvg.SetStyle(Curve.Short_Dash);
plot DivergeTop = if Momentum>0 and Momentum<Momentum[1] and Momentum[1]>Momentum[2] and Momentum<highest(Momentum,BarsBack) and highest(Close,5) > highest(Close[6],BarsBack) then highest(Momentum,barsBack) else double.nan;
plot DivergeBottom = if Momentum<0 and Momentum>Momentum[1] and Momentum[1]<Momentum[2] and Momentum>lowest(Momentum,BarsBack)and lowest(Close,5) < lowest(Close[6],BarsBack) then lowest(Momentum,BarsBack) else double.nan;
DivergeTop.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
DivergeTop.SetLineWeight(5);
DivergeTop.SetDefaultColor(GetColor(5));
DivergeBottom.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
DivergeBottom.SetLineWeight(5);
DivergeBottom.SetDefaultColor(GetColor(6));
AssignPriceColor (if !PaintBars then Color.CURRENT else if Momentum > 0 and Momentum < Momentum[1] and Momentum[1] > Momentum[2] and Momentum < Highest(Momentum, BarsBack) and Highest(close, 5) > Highest(close[6], BarsBack) then color.Red else if Momentum < 0 and Momentum > Momentum[1] and Momentum[1] < Momentum[2] and Momentum > Lowest(Momentum, BarsBack) and Lowest(close, 5) < Lowest(close[6], BarsBack) then color.Cyan else Color.Current);
#AssignPriceColor (if !PaintBars then Color.CURRENT else if Momentum > 0 and Momentum < Momentum[1] and Momentum[1] > Momentum[2] and Momentum < Highest(Momentum, BarsBack) and Highest(close, 5) > Highest(close[6], BarsBack) then color.Red else if Momentum < 0 and Momentum > Momentum[1] and Momentum[1] < Momentum[2] and Momentum > Lowest(Momentum, BarsBack) and Lowest(close, 5) < Lowest(close[6], BarsBack) then color.Green else if Momentum >= 0 then if Momentum > Momentum[1] then Color.Current else Color.Current else if Momentum < Momentum[1] then Color.Current else Color.Current);
Thank you mate so much!
I will try it as well
Last Updated on June 18, 2020