Calculations Performed Only at Close of Bar??

KarlWolff

Member
I'd like to adjust an indicator to not have intrabar calculations. For example, a buy/sell should only occur when a line is convincingly crossed, meaning the close of the bar. I don't want an indicator bouncing around a decision line; this can be done with a tab selection in TS. Any suggestions for TOS?
 

horserider

Well-known member
VIP
Might depend on how the study is coded. If it includes a "data" selection input. It allows a selection of variables.
Seems your basic choices are open, high, low, close. Pick " close".

If it is set to something other than close in the code then the code may need to be edited and set to "close"
 
Last edited:

KarlWolff

Member
Thanks for your reply! Yup, using "DATA." How would I go about adjusting it? Here's the code:
------------------------------------------------------------------------------------------------------------------------------
declare lower;
def agg = AggregationPeriod.FIVE_MIN;
plot data = close(period = agg);

data.SetDefaultColor(Color.WHITE);
data.SetLineWeight(3);
data.SetPaintingStrategy(PaintingStrategy.LINE);
data.SetStyle(Curve.LONG_DASH);
data.HideBubble();
data.HideTitle();

plot BDfastEMA=ExpAverage(DATA,8);

BDfastEMA.SetDefaultColor(Color.VIOLET);
BDfastEMA.SetLineWeight(5);
BDfastEMA.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
BDfastEMA.SetStyle(Curve.FIRM);
BDfastEMA.HideBubble();
BDfastEMA.HideTitle();

plot BDslowEMA=ExpAverage(DATA,40);

BDslowEMA.SetDefaultColor(Color.YELLOW);
BDslowEMA.SetLineWeight(3);
BDslowEMA.SetPaintingStrategy(PaintingStrategy.LINE);
BDslowEMA.SetStyle(Curve.FIRM);
BDslowEMA.HideBubble();
BDslowEMA.HideTitle();

def UpCross = if BDfastEMA > BDslowEma AND BDfastEMA[1] < BDslowEMA then 1 else 0;
Plot BDup = if UpCross then high else double.nan;

BDup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BDup.SetLineWeight(5);
BDup.SetDefaultColor(color.WHITE);
BDup.HideBubble();
BDup.HideTitle();

def DnCross = if BDfastEMA < BDslowEma AND BDfastEMA[1] > BDslowEMA then 1 else 0;
Plot BDdn = if DnCross then low else double.nan;

BDdn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
BDdn.SetLineWeight(5);
BDdn.SetDefaultColor(color.WHITE);
BDdn.HideBubble();
BDdn.HideTitle();

# END
 

horserider

Well-known member
VIP
plot data = close(period = agg); Already specifies close in your code so looks like you have what you want.

If you wish to be able to choose the data type insert the line below into the code.
input data = close;
 

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.
Top