Indicator Code - Guidance

JPD1

New member
Evening,

I've developed a Target Condition that involves coding a new ThinkScript indicator. My target is to have a visual signal (green arrow) populate on my TOS screen when a set of OHLC conditions/calculations are met. Think "ADX Wilders" for very basic calculations.

I call the signal "thrust," and it compares the OHLC characteristics of a 15m bar to "yesterday's close."
The goal is that when the "thrust" of a 15m bar is greater than 33%, a green arrow (or some other very noticeable visual management signal) will populate the TOS price graph.

In excel, the calculation reads as follows:
((15m close - 15m open) / 15m open) / ((15m close - Yesterday's Close) / Yesterday's Close)) = Thrust
More or less, how much of the %gain is the current bar responsible for?

When this calculation yields >33%, poof, green arrow.

I've made some ground by borrowing code, but the output isn't producing a visual signal on appropriate bars.
Here's where I'm at thus far:

For reference, on 8/1/2022, TXMD should populate a green arrow under the very first 15m bar of the day.
___________________________________________________________________________________________________
def RTHPriorClose = if GetTime() crosses above RegularTradingEnd(GetYYYYMMDD())
then close[1]
else RTHPriorClose[1];

def Thrust = (((close - open) / open) / ((close - RTHPriorClose) / RTHPriorClose);

input crossingType = {default above, below};
#input threshold = 20;
#input averageType = AverageType.WILDERS;
#input length = 1;

plot signal = (Thrust) >=.33;

signal.DefineColor("Above", GetColor(0));
signal.DefineColor("Below", GetColor(1));
signal.AssignValueColor(if crossingType == CrossingType.above then signal.color("Above") else signal.color("Below"));

signal.SetPaintingStrategy(if crossingType == CrossingType.above
then PaintingStrategy.BOOLEAN_ARROW_UP
else PaintingStrategy.BOOLEAN_ARROW_DOWN);

Solution
@JPD1 try changing this line in your code:
Ruby:
``plot signal = (Thrust) >=.33;``
with this:
Ruby:
``plot signal = Crosses(Thrust, .33, crossingType == CrossingType.above);``
@JPD1 try changing this line in your code:
Ruby:
``plot signal = (Thrust) >=.33;``
with this:
Ruby:
``plot signal = Crosses(Thrust, .33, crossingType == CrossingType.above);``

@Svanoy, input the code change but do not see the correct output on the graph.
Wondering if the RTHpriorclose code is correct for grabbing yesterday's close?

@Svanoy, input the code change but do not see the correct output on the graph.
Wondering if the RTHpriorclose code is correct for grabbing yesterday's close?
Played around with some code from other threads and corrected for the incorrect RTHPriorClose code and the arrows plotted as they should.
Here's what I'm running with now. Appreciate your help @Svanoy.

def RTHPriorClose = if GetDay() == GetLastDay() then RTHPriorClose[1] else close;

def Thrust = (((close - open) / open) / ((close - RTHPriorClose) / RTHPriorClose));

input crossingType = {default above, below};

plot signal = Crosses(Thrust, .33, crossingType == CrossingType.above);

signal.DefineColor("Above", GetColor(0));
signal.DefineColor("Below", GetColor(1));
signal.AssignValueColor(if crossingType == CrossingType.above then signal.color("Above") else signal.color("Below"));

signal.SetPaintingStrategy(if crossingType == CrossingType.above
then PaintingStrategy.BOOLEAN_ARROW_UP
else PaintingStrategy.BOOLEAN_ARROW_DOWN);

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
384 Online

The Market Trading Game Changer

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

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?