NexusFi: Find Your Edge


Home Menu

 





Help changing bar color in script


Discussion in ThinkOrSwim

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




 
Search this Thread

Help changing bar color in script

  #1 (permalink)
tozwp
Milwaukee WI/US
 
Posts: 7 since Feb 2012
Thanks Given: 2
Thanks Received: 1

Trying to change the color of candlestick in TOS based on condition of 3 indicators. I've done it in Easylanguage/Tradestation but having brain freeze trying to script it in TOS. Essentially I'm trying to flip the color from green to red on a change in all three indicators. In Easylanguage it looks like this:

Condition1 = (Indicator1 > value1) and (Indicator2 > value2) and (Indicator3 > value3);
Condition2 = (Indicator1 < value1) and (Indicator2 < value2) and (Indicator3 < value3);
If Condition1 then plotcolor = green;
If Condition2 then plotcolor = red;

In Easylanguage this will start plotting green when condition1 is true and continue to plot green until condition2 is true. Then it will plot red bars until condition1 is true again. I have the script written for the indicators and they work fine. I'm experiencing brain freeze regarding the logic for changing the color of the bars in TOS. Probably pretty easy if someone could point me in the right direction. Probably involves AssignPriceColor but so far I can't seem to create the logical equivalent of the Condition1 and Condition2 from Easylanguage.

Thanks!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Quant vue
Trading Reviews and Vendors
What broker to use for trading palladium futures
Commodities
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
About a successful futures trader who didnĀ“t know anyth …
Psychology and Money Management
ZombieSqueeze
Platforms and Indicators
 
  #2 (permalink)
jjjann
Bangkok
 
Posts: 5 since Jan 2016
Thanks Given: 0
Thanks Received: 1

def Condition1 = (Indicator1 > value1) and (Indicator2 > value2) and (Indicator3 > value3);
def Condition2 = (Indicator1 < value1) and (Indicator2 < value2) and (Indicator3 < value3);

AssignPriceColor
(if Condition1 then Color.green
else if Condition2 then Color.red
else Color.CURRENT);

you can use "CreateColor(0,222,0)" instead of "Color.green" to create more specific color in RGB

Reply With Quote
  #3 (permalink)
tozwp
Milwaukee WI/US
 
Posts: 7 since Feb 2012
Thanks Given: 2
Thanks Received: 1


Thank you! My problem was that I was trying to use an IF statement in the def statement like this:

def Condition1 = IF (Indicator1 > value1) and (Indicator2 > value2) and (Indicator3 > value3);

That doesn't work! Trying to think in Easylanguage but trying to write in TOS script causes my brain to short circuit.

Reply With Quote
  #4 (permalink)
Drive
Bakersfield
 
Posts: 7 since Feb 2019
Thanks Given: 0
Thanks Received: 0

Im looking for something similar, I want my candles to turn green when the Slow Stochastic K period crosses over the D period & Red when the K period crosses below the D period.

Reply With Quote




Last Updated on February 9, 2019


© 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