• Get $40 off VIP by signing up for a free account! Sign Up

Can I plot momentum on the upper chart? and set an arrow up and down when it break 0?

lguides

New member
Code:
def ml = 12;
plot Mom = price - price[ml];
def zline = 0;

plot mm1 = if Mom > zline then zline else double.nan;
mm1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
mm1.SetDefaultColor(Color.GREEN);
mm1.SetLineWeight(4);
plot mm2 = if Mom < zline then zline else double.nan;
mm2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
mm2.SetDefaultColor(Color.GREEN);
mm2.SetLineWeight(4);
 
Some very minor fixes, changs.

Ruby:
input ml = 12;
def Mom = close - close[ml];
plot mm1 = Mom > 0;
mm1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
mm1.SetDefaultColor(Color.GREEN);
mm1.SetLineWeight(4);
plot mm2 = Mom < 0;
mm2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
mm2.SetDefaultColor(Color.RED);
mm2.SetLineWeight(4);
 

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

Some very minor fixes, changs.

Ruby:
input ml = 12;
def Mom = close - close[ml];
plot mm1 = Mom > 0;
mm1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
mm1.SetDefaultColor(Color.GREEN);
mm1.SetLineWeight(4);
plot mm2 = Mom < 0;
mm2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
mm2.SetDefaultColor(Color.RED);
mm2.SetLineWeight(4);
I think it really doesn't work to have it on the upper chart, I hope there's an admin, moderator, or staff that can answer my question.
 
@lguides
When creating plots in thinkscript you not only have to define the logic of what you want plotted but you must also state WHERE on the candle or line that you want it plotted. (IE the low, high, open, close, of the candle).
So an example syntax is if mycondition is true then low else double.Nan (print nothing)
Ruby:
input ml = 12;
def Mom = close - close[ml];
plot mm1 = if Mom > 0 then low else double.NaN;
mm1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_up);
mm1.SetDefaultColor(Color.GREEN);
mm1.SetLineWeight(4);
plot mm2 = if Mom < 0 then high else double.NaN;;
mm2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
mm2.SetDefaultColor(Color.RED);
mm2.SetLineWeight(4);
This script is now correct syntax-wise but is probably not what you want.
a2.png

Just for future reference, it is not unusual for us to fix the 1st mistake we see and call it fixed. Especially if we are not in front of a computer to test. While I can provide guidance on simple fixes, I am not half as smart as @Joshua.
 
Last edited:
Just for future reference, it is not unusual for us to fix the 1st mistake we see and call it fixed. Especially if we are not in front of a computer to test. While I can provide guidance on simple fixes, I am not half as smart as @Joshua.

Oh believe me, I was not calling it fixed by any stretch of the imagination, perhaps just no longer totally broken. :ROFLMAO:

Don't know why I am even doing this still, but I think what he wants is more similar to something like this:

Ruby:
declare lower;
input ml = 12;
plot Mom = close - close[ml];
plot zline = 0;
plot mm1 = if Mom crosses above zline then mom else double.nan;
mm1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
mm1.SetDefaultColor(Color.GREEN);
mm1.SetLineWeight(4);
plot mm2 = if mom crosses below zline then mom else double.nan;
mm2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
mm2.SetDefaultColor(Color.GREEN);
mm2.SetLineWeight(4);
 
I tried something like this but it doesn't works it flatten my candles
Code:
def ml = 12;
plot Mom = close - close[ml];

plot mm1 = if Mom crosses below 0 then close else double.nan;
mm1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
mm1.SetDefaultColor(Color.GREEN);
mm1.SetLineWeight(4);
plot mm2 = if Mom crosses above 0 then close else double.nan;
mm2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
mm2.SetDefaultColor(Color.GREEN);
mm2.SetLineWeight(4);
 
Oh believe me, I was not calling it fixed by any stretch of the imagination, perhaps just no longer totally broken. :ROFLMAO:

Don't know why I am even doing this still, but I think what he wants is more similar to something like this:

Ruby:
declare lower;
input ml = 12;
plot Mom = close - close[ml];
plot zline = 0;
plot mm1 = if Mom crosses above zline then mom else double.nan;
mm1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
mm1.SetDefaultColor(Color.GREEN);
mm1.SetLineWeight(4);
plot mm2 = if mom crosses below zline then mom else double.nan;
mm2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
mm2.SetDefaultColor(Color.GREEN);
mm2.SetLineWeight(4);
Not totally Josh I do appreciate it but as I have said above I want this to plot on the upper (chart or candlestick) not on lower because it was obviously possible when declaring it on lower.
 
Last edited:
@lguides
When creating plots in thinkscript you not only have to define the logic of what you want plotted but you must also state WHERE on the candle or line that you want it plotted. (IE the low, high, open, close, of the candle).
So the syntax is if mycondition is true then low else double.Nan (print nothing)
Ruby:
input ml = 12;
def Mom = close - close[ml];
plot mm1 = if Mom > 0 then low else double.NaN;
mm1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_up);
mm1.SetDefaultColor(Color.GREEN);
mm1.SetLineWeight(4);
plot mm2 = if Mom < 0 then high else double.NaN;;
mm2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
mm2.SetDefaultColor(Color.RED);
mm2.SetLineWeight(4);
This script is now correct syntax-wise but is probably not what you want.
View attachment 742
Just for future reference, it is not unusual for us to fix the 1st mistake we see and call it fixed. Especially if we are not in front of a computer to test. While I can provide guidance on simple fixes, I am not half as smart as @Joshua.
Would you mind sharing your code doing that? that was exactly what I want. However, I believe that you used "> 0" instead of "crosses above/below" that's why arrows are placing all around. thanks @MerryDay I appreciate it!
 
I think it really doesn't work to have it on the upper chart
Not totally Josh, as I have said above I want this to plot on the upper
⁉️

This should be incredibly simple, the reason your candles are being squished in that other example is probably because your plotting "mom" on the upper chart with "fit studies" enabled in options. Change "plot mom" to "def mom" or uncheck that box.
 
Not sure if this helps, but with squishness, I use this-

input offset = 5;
plot hiz = if zscore > z then high + offset * ticksize() else double.nan;
plot lowz = if zscore < -z then low - offset * ticksize() else double.nan;
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
415 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