Help with TTM_Trend & FW_MOBO_Basic()

David45

Active member
2019 Donor
Hi Folks,

I am trying to get the study below to plot in the lower chart pane. In it's form below, it does what I want it to do (although in the upper chart pane) which is paint the bars green when TTM TrendUp is true and close is greater than FW_MOBO_Basic()."UpperBandP" and paint them red when the opposite is true. The preceding bars are grayed out to allow for focus on the current trend only.

def bar = barNumber();
def StateUp = 1;
def StateDn = 2;

def State = if TTM_Trend()."TrendUp" is true and close is greater than FW_MOBO_Basic()."UpperBandP" then StateUp
else if TTM_Trend()."TrendDown" is true and close is less than FW_MOBO_Basic()."LowerBandP" then StateDn
else State[1];
def newState = HighestAll(if State <> State[1] then bar else 0);

AssignPriceColor(if bar >= newState
then if State == StateUp then Color.DARK_GREEN
else if State == StateDn then Color.RED
else Color.GRAY
else Color.GRAY);

I tried modifying the code above to the code below so that it plots in the lower chart pane but it gives me an error message that says:
AssignValueColor should be called on a IBasePlot at 11:1
At least one plot should be defined
AssignValueColor should be called on a IBasePlot at 11:1

declare lower;

def bar = barNumber();
def StateUp = 1;
def StateDn = 2;

def State = if TTM_Trend()."TrendUp" is true and close is greater than FW_MOBO_Basic()."UpperBandP" then StateUp
else if TTM_Trend()."TrendDown" is true and close is less than FW_MOBO_Basic()."LowerBandP" then StateDn
else State[1];
def newState = HighestAll(if State <> State[1] then bar else 0);


AssignValueColor(if bar >= newState
then if State == StateUp then Color.DARK_GREEN
else if State == StateDn then Color.RED
else Color.GRAY
else Color.GRAY);

I am just trying to get the code to plot in the lower chart pane in the form of vertical bars that are green when TTM_Trend()."TrendUp" is true and close is greater than FW_MOBO_Basic()."UpperBandP", red when TTM_Trend()."TrendDown" is true and close is less than FW_MOBO_Basic()."LowerBandP", and all previous bars are grayed out to allow focus on the current trend only.

Thanks in advance for any assistance!
 
Solution
Hi Folks,

I am trying to get the study below to plot in the lower chart pane. In it's form below, it does what I want it to do (although in the upper chart pane) which is paint the bars green when TTM TrendUp is true and close is greater than FW_MOBO_Basic()."UpperBandP" and paint them red when the opposite is true. The preceding bars are grayed out to allow for focus on the current trend only.

def bar = barNumber();
def StateUp = 1;
def StateDn = 2;

def State = if TTM_Trend()."TrendUp" is true and close is greater than FW_MOBO_Basic()."UpperBandP" then StateUp
else if TTM_Trend()."TrendDown" is true and close is less than FW_MOBO_Basic()."LowerBandP" then StateDn
else State[1];
def newState...
Hi Folks,

I am trying to get the study below to plot in the lower chart pane. In it's form below, it does what I want it to do (although in the upper chart pane) which is paint the bars green when TTM TrendUp is true and close is greater than FW_MOBO_Basic()."UpperBandP" and paint them red when the opposite is true. The preceding bars are grayed out to allow for focus on the current trend only.

def bar = barNumber();
def StateUp = 1;
def StateDn = 2;

def State = if TTM_Trend()."TrendUp" is true and close is greater than FW_MOBO_Basic()."UpperBandP" then StateUp
else if TTM_Trend()."TrendDown" is true and close is less than FW_MOBO_Basic()."LowerBandP" then StateDn
else State[1];
def newState = HighestAll(if State <> State[1] then bar else 0);

AssignPriceColor(if bar >= newState
then if State == StateUp then Color.DARK_GREEN
else if State == StateDn then Color.RED
else Color.GRAY
else Color.GRAY);

I tried modifying the code above to the code below so that it plots in the lower chart pane but it gives me an error message that says:
AssignValueColor should be called on a IBasePlot at 11:1
At least one plot should be defined
AssignValueColor should be called on a IBasePlot at 11:1

declare lower;

def bar = barNumber();
def StateUp = 1;
def StateDn = 2;

def State = if TTM_Trend()."TrendUp" is true and close is greater than FW_MOBO_Basic()."UpperBandP" then StateUp
else if TTM_Trend()."TrendDown" is true and close is less than FW_MOBO_Basic()."LowerBandP" then StateDn
else State[1];
def newState = HighestAll(if State <> State[1] then bar else 0);


AssignValueColor(if bar >= newState
then if State == StateUp then Color.DARK_GREEN
else if State == StateDn then Color.RED
else Color.GRAY
else Color.GRAY);

I am just trying to get the code to plot in the lower chart pane in the form of vertical bars that are green when TTM_Trend()."TrendUp" is true and close is greater than FW_MOBO_Basic()."UpperBandP", red when TTM_Trend()."TrendDown" is true and close is less than FW_MOBO_Basic()."LowerBandP", and all previous bars are grayed out to allow focus on the current trend only.

Thanks in advance for any assistance!

See if this helps you make it the way you want.

Screenshot-2023-04-22-125902.png
Code:
declare lower;

def bar = barNumber();
def StateUp = 1;
def StateDn = 2;

def State = if TTM_Trend()."TrendUp" is true and close is greater than FW_MOBO_Basic()."UpperBandP" then StateUp
else if TTM_Trend()."TrendDown" is true and close is less than FW_MOBO_Basic()."LowerBandP" then StateDn
else State[1];
def newState = HighestAll(if State <> State[1] then bar else 0);

plot line0 = 0;
plot line1 = 1;
line0.setdefaultColor(color.black);
line1.setdefaultColor(color.black);

plot line = between(state,1,2);
line.setpaintingStrategy(paintingStrategy.HISTOGRAM);

line.AssignValueColor(if State == StateUp then Color.DARK_GREEN
else if State == StateDn then Color.RED
else Color.GRAY);
#
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
459 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top