arrows not painting

R

randomx

Guest
hat in hand

hi all,
i'm wondering if you guys can help me. the arrows on this script are not painting on the price chart. this is driving me craaazy. thank you in advance

what i need this script to do is
1] to paint an arrow down when there's an downward inflection on the sma line (dark red).
2] to paint an arrow up when there's an upward inflection on the sma line (cyan).

Code:
declare upper;
input price = close;
input length = 10;
input percent = 5;
input displace = 0;

def percent_deviation = percent / 100;

plot SMA = Average(price[-displace], length);

SMA.AssignValueColor(if SMA > SMA[1] and SMA[1] > SMA[2] then Color.cyan else if SMA < SMA[1] and SMA[1] < SMA [2] then Color.DARK_RED else Color.WHITE);
SMA.SetLineWeight(2);

plot five_percent_below_sma;
plot five_percent_above_sma;

five_percent_below_sma = (Average(price, length)) - (percent_deviation * Average(price, length));
five_percent_above_sma  = (Average(price, length)) + (percent_deviation * Average(price, length));

five_percent_below_sma.SetDefaultColor(Color.gray);
five_percent_below_sma.SetPaintingStrategy(PaintingStrategy.LINE);


five_percent_above_sma.SetDefaultColor(Color.gray);
five_percent_above_sma.SetPaintingStrategy(PaintingStrategy.LINE);


addCloud(five_percent_below_sma, five_percent_above_sma, color.gray, color.gray);

##trend up
def asc_sma = SMA > SMA[1] and SMA[1] > SMA[2];
def long_signal = close crosses above asc_sma;
plot trendup = asc_sma and long_signal;


##trend down
def desc_sma = SMA < SMA[1] and SMA[1] < SMA[2];
def short_signal = close crosses below desc_sma;
plot trenddown = desc_sma and short_signal;

trendup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
trenddown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);


edit: here's a picture of what i mean.
dark red arrow down at the inflection point indicating the trend is going down
cyan arrow up indicating trend is going up, just at the inflection point

oCcTy8X.png
 
Last edited by a moderator:
@randomx Part of the plot statement is stating where on the candle you want the arrow to print.
So you need a statement that says if condition = true then print at high of candle else don't print.
Therefore the plot syntax is:
Ruby:
plot trendup = if asc_sma and long_signal then low else double_nan;

plot trenddown = if desc_sma and short_signal then high else double_nan;
 

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

thank you for your reply. still no joy...not painting the arrow

Code:
##trend up
def asc_sma = SMA > SMA[1] and SMA[1] > SMA[2];
def long_signal = close crosses above asc_sma;
plot trendup = if asc_sma and long_signal then low else double.nan;


##trend down
def desc_sma = SMA < SMA[1] and SMA[1] < SMA[2];
def short_signal = close crosses below desc_sma;
plot trenddown = if desc_sma and short_signal then high else double.nan;

trendup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
trenddown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 
@randomx asc_sma and desc_sma are booleans. Your condition for signals which is close crosses asc/desc_sma is basically close crosses above 1/0 or below 1/0. You need to change asc/desc_sma to SMA or something similar. You also need to change your painting strategy to boolean arrows.
 
Last edited:
Maybe this . . . ? May or may not work
Code:
##trend up
def asc_sma = SMA > SMA[1] and SMA[1] > SMA[2];
plot trendup = asc_sma && !asc_sma[1];

##trend down
def desc_sma = SMA < SMA[1] and SMA[1] < SMA[2];
plot trenddown = desc_sma && !desc_sma[1];

trendup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
trenddown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

I see @generic already posted this above. You probably also need to eliminate or re-code the "long_signal" and "short_signal" variables. Its very hard to find a point where price crosses above or below a true/false condition. "desc_sma" and "asc_sma" are both boolean.
 
Last edited:
@randomx You already have several good suggestions. Keep in mind that we ask for the WHOLE chart because it shows the timeframe, the equity, how the inputs are set, etc... So we can recreate the same charts in our app and then can give more detailed fixes. Partial screenshots of partial charts don't provide enough data.
 
thank you all. @MerryDay my bad. i'll make sure the whole chart is uploaded next time. i zoomed in with my pic editor and i uploaded that screenshot instead

anyway, this did the trick. special thanks @Pensar && @generic

Code:
##trend up
def asc_sma = SMA > SMA[1] and SMA[1] > SMA[2];
plot trendup = asc_sma && !asc_sma[1];

##trend down
def desc_sma = SMA < SMA[1] and SMA[1] < SMA[2];
plot trenddown = desc_sma && !desc_sma[1];
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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