Is it possible to get a price when a specific study becomes true?

PlusEVTrades

New member
I'm attempting to get a price at the time when my study becomes true. For example, when macd crosses over, can I assign the current "mark" to a variable?

I'd like to use that price for an addorder on a later bar.

I'm not quite sure where to start on code, but lets say for example

:
Code:
def macdsignal = value crosses above signal line;
def entrytargetprice = price when macdsignal is true;

AddOrder(OrderType.BUY_TO_OPEN, price crosses below entrytargetprice,entrytargetprice,
100,tickcolor = GetColor(0), arrowcolor = GetColor(0), name = "BuyOrder100");

Something to that effect seems like the logic I'd be using but I'm not sure if I can obtain price.
 
@PlusEVTrades Maybe try something like def entrytargetprice = if macdsignal then close else entrytargetprice[1];? That may or may not work, but its an idea. If I have it correct, the variable entrytargetprice should hold each value until the next time the value line crosses above the signal line.
 

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

@PlusEVTrades You can do it with either AddLabel() or AddChartBubble() using the same logic as you would when creating AddOrder()... However, AddLabel() would only display until the next candle that doesn't meet your criteria paints... I'm pretty sure the entry price of AddOrder() can be had using EntryPrice(), but it would be easier to use the price the logic provides...
 
@PlusEVTrades You can do it with either AddLabel() or AddChartBubble() using the same logic as you would when creating AddOrder()... However, AddLabel() would only display until the next candle that doesn't meet your criteria paints... I'm pretty sure the entry price of AddOrder() can be had using EntryPrice(), but it would be easier to use the price the logic provides...
Yeah I basically need the entryprice (), but without the addorder. Is that possible? I want to use that price for a different add order at a later bar.
 
Yeah I basically need the entryprice (), but without the addorder. Is that possible? I want to use that price for a different add order at a later bar.

In that case you would just use the logic that would trigger AddOrder() but use it to paint AddChartBubble() and use the price at the time of the trigger... That should give a more accurate price than the standard of open[+1] (open of next candle after trigger) used in most Strategies... You'd have to play with it...
 
In that case you would just use the logic that would trigger AddOrder() but use it to paint AddChartBubble() and use the price at the time of the trigger... That should give a more accurate price than the standard of open[+1] (open of next candle after trigger) used in most Strategies... You'd have to play with it...
Can I get that price with "mark" or does it have to be something arbitrary like open/close/hl2 ?
 
@PlusEVTrades No, MARK is not available in Studies as a price choice, nor is Bid or Ask which is what MARK is derived from... But during the painting of a bar Close is usually the same as Last, which also is not available in and of itself... So you could use Open, High, Low, Close or HL2...
 
Interesting so addorder creates a entryprice() variable is that the only to get a specific price from a study then? The reason why is I'd like to get the price at the time the study procs, and use it as a buy entry at a later time. But I can't seem to capture that price, even though I know TOS is holding it as a variable in entryprice().
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
352 Online
Create Post

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