Changing bar colors on TOS charts, when conditions met. - futures io
futures io futures trading



Changing bar colors on TOS charts, when conditions met.


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one mcamilapaez with 4 posts (0 thanks)
    2. looks_two rmejia with 3 posts (0 thanks)
    3. looks_3 meeks with 2 posts (0 thanks)
    4. looks_4 JayC with 1 posts (0 thanks)
    1. trending_up 16,004 views
    2. thumb_up 0 thanks given
    3. group 6 followers
    1. forum 11 posts
    2. 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)

 
Search this Thread
 

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?

Reply With Quote

Can you help answer these questions
from other members on futures io?
Indicators for pair trading MES and M2K
Platforms and Indicators
Which kind of Blockvolume is visible? - order processing
Emini and Emicro Index
Help Needed: TOS Options Chain IV & IMPL MOVE Calcul …
ThinkOrSwim
Short Interest Ratio indicator?
ThinkOrSwim
OFA (Order Flow Analytics) Licence
NinjaTrader
 
 
(login for full post details)
  #2 (permalink)
Puerto Rico
 
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: ES
 
rmejia's Avatar
 
Posts: 377 since Oct 2010
Thanks: 3,600 given, 432 received

The candle color?

AssignPriceColor
https://tlc.thinkorswim.com/center/charting/thinkscript/reference/Functions/Look---Feel/AssignPriceColor

Reply With Quote
 
(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.

Reply With Quote
 
(login for full post details)
  #4 (permalink)
Puerto Rico
 
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: ES
 
rmejia's Avatar
 
Posts: 377 since Oct 2010
Thanks: 3,600 given, 432 received

Post the code you are trying to edit to see what's up.

Reply With Quote
 
(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!

Reply With Quote
 
(login for full post details)
  #6 (permalink)
Puerto Rico
 
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: ES
 
rmejia's Avatar
 
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);


Reply With Quote
 
(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....

Reply With Quote
 
(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.

Reply With Quote
 
(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?

Reply With Quote
 
(login for full post details)
  #10 (permalink)
Los Angeles (CA)
 
Experience: Master
Platform: ThinkOrSwim
Trading: Currency Future, Stocks
 
lukeskywalker1's Avatar
 
Posts: 29 since Apr 2019
Thanks: 0 given, 19 received



rmejia View Post
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

Visit my futures io Trade Journal Reply With Quote
 
(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 View Post
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);

Reply With Quote
 
(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!!!

Reply With Quote


futures io Trading Community Platforms and Indicators ThinkOrSwim > Changing bar colors on TOS charts, when conditions met.


Last Updated on June 18, 2020


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts