Thrust: close vs prior close

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;


#ADX Wilders#
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
@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"...

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

@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);
 
Solution
In the code, converted <RTHPriorClose[15]>, just only actually wondering what that will indicate, and also reversed the direction to plot the <below, above> to show direction change perhaps, and moved the thrust to .087 for a quicker arrow over the 15 periods?

Help.


Code:
#Guidance Indicator


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

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

#input crossingType = {default above, below};
input crossingType = {default below, above};

plot signal = Crosses(Thrust, .087, 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);
 
In the code, converted <RTHPriorClose[15]>, just only actually wondering what that will indicate, and also reversed the direction to plot the <below, above> to show direction change perhaps, and moved the thrust to .087 for a quicker arrow over the 15 periods?

Help.


Code:
#Guidance Indicator


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

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

#input crossingType = {default above, below};
input crossingType = {default below, above};

plot signal = Crosses(Thrust, .087, 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);
This arrow appears atop the plotted candle stick just as a top is met. reading just alone without a confirmation would result in a losing trade. Do you own diligence
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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