Trading Articles
Article Categories
Article Tools
Changing bar colors on TOS charts, when conditions met.
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
16,004 views
thumb_up
0 thanks given
group
6 followers
forum
11 posts
attach_file
2 attachments
Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
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 and simple.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Changing bar colors on TOS charts, when conditions met.
(login for full post details)
#1 (permalink )
San Jose, Costa Rica
Posts: 5 since May 2014
Thanks: 3 given,
0
received
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 futures io?
Best Threads (Most Thanked) in the last 7 days on futures io
(login for full post details)
#2 (permalink )
Puerto Rico
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: ES
Posts: 377 since Oct 2010
Thanks: 3,600 given,
432
received
(login for full post details)
#3 (permalink )
San Jose, Costa Rica
Posts: 5 since May 2014
Thanks: 3 given,
0
received
Thanks!! I have already tried those instructios unsuccessfully.
(login for full post details)
#4 (permalink )
Puerto Rico
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: ES
Posts: 377 since Oct 2010
Thanks: 3,600 given,
432
received
Post the code you are trying to edit to see what's up.
(login for full post details)
#5 (permalink )
San Jose, Costa Rica
Posts: 5 since May 2014
Thanks: 3 given,
0
received
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!
(login for full post details)
#6 (permalink )
Puerto Rico
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: ES
Posts: 377 since Oct 2010
Thanks: 3,600 given,
432
received
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);
(login for full post details)
#7 (permalink )
San Jose, Costa Rica
Posts: 5 since May 2014
Thanks: 3 given,
0
received
Thank you so much!
I will try it and Tell you then....
(login for full post details)
#8 (permalink )
Bakersfield
Posts: 7 since Feb 2019
Thanks: 0 given,
0
received
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.
(login for full post details)
#9 (permalink )
Cliffside Park, New Jersey
Posts: 2 since Jun 2020
Thanks: 0 given,
0
received
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?
(login for full post details)
#10 (permalink )
Los Angeles (CA)
Experience: Master
Platform: ThinkOrSwim
Trading: Currency Future, Stocks
Posts: 29 since Apr 2019
Thanks: 0 given,
19
received
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
(login for full post details)
#11 (permalink )
San Diego, CA
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
Posts: 31 since Mar 2019
Thanks: 4 given,
19
received
meeks
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?
@meeks ,
I think you're looking for something like this. You can add this study multiple times and configure different time windows.
JayC
Code
input startTime = 0900;
input endTime = 1100;
def timeWindow = SecondsFromTime(startTime) >= 0 and SecondsFromTime(endTime) < 0;
AssignPriceColor(if timeWindow then Color.BLUE else Color.CURRENT);
(login for full post details)
#12 (permalink )
Cliffside Park, New Jersey
Posts: 2 since Jun 2020
Thanks: 0 given,
0
received
That's perfect! Thank you!!!
Last Updated on June 18, 2020
Right now
Ongoing
Right now
March
Register to Attend
Elite only
Coming soon
April