transfer the current price at the moment the condition is triggered

Max911

Member
Hi, I developed an strategy that use audible alerts when current volume bar is greater than previous bar.

Buy1 = close > close[1] and volume > volume[1];
Sell1 = close < close[1] and volume < volume[1];

alert(Buy1, " Buy " + " " + close, Alert.BAR, Sound.Ring);
alert(Sell1, " Sell " + " " + close, Alert.BAR, Sound.Ring);

I need to run a backtest for that, so my question is pretty simple:

How can I get the exact price that the alert triggers in the message?


def buySig = close and Buy1;
def buyPrice = if open[-1] and Buy1 then open[-1] else XXX[-1]; (XXX is where I need the real price that appears in message center)
AddOrder(OrderType.BUY_TO_OPEN, buySig[-1], price = buyPrice, tradeSize = 1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Buy");

I need the 'message center price' to add into the 'strategy script', cos price triggered when volume > volume[1] is variable.
 
Last edited:
Solution
How can I put the real price of the condition into the AddOrder? Using EntryPrice(), I don't know. Thx for ur help!

This may give you some ideas as to how to display price on the strategy chart through addchartbubble.

Capture.jpg
Ruby:
def Buy1 = close > close[1] and volume > volume[1];
def Sell1 = close < close[1] and volume < volume[1];

Alert(Buy1, " Buy " + " " + close, Alert.BAR, Sound.Ring);
Alert(Sell1, " Sell " + " " + close, Alert.BAR, Sound.Ring);


def buySig = close and Buy1;
def sellSig = close and Sell1;
#def buyPrice = if open[-1] and Buy1 then open[-1] else XXX[-1];# (XXX is where I need the real price that appears in message center)
AddOrder(condition = buySig[-1], name = "Buy");
AddOrder(type =...
How can I put the real price of the condition into the AddOrder? Using EntryPrice(), I don't know. Thx for ur help!

This may give you some ideas as to how to display price on the strategy chart through addchartbubble.

Capture.jpg
Ruby:
def Buy1 = close > close[1] and volume > volume[1];
def Sell1 = close < close[1] and volume < volume[1];

Alert(Buy1, " Buy " + " " + close, Alert.BAR, Sound.Ring);
Alert(Sell1, " Sell " + " " + close, Alert.BAR, Sound.Ring);


def buySig = close and Buy1;
def sellSig = close and Sell1;
#def buyPrice = if open[-1] and Buy1 then open[-1] else XXX[-1];# (XXX is where I need the real price that appears in message center)
AddOrder(condition = buySig[-1], name = "Buy");
AddOrder(type = OrderType.SELL_AUTO, condition = sellSig[-1]);
AddChartBubble(buySig, low*.998, EntryPrice(), Color.LIGHT_GREEN, no);
AddChartBubble(sellSig, high*1.002, EntryPrice(), Color.LIGHT_RED);
 
Solution
Thanks @SleepyZ but your scripts work as usual, printing the open as entry or exit price, not the real condition price.

def Buy1 = close > close[1] and volume > volume[1];
def buySig = close and Buy1;
def buyPrice = if open[-1] and Buy1 then open[-1] else XXX[-1]; (XXX is where I need the real price that appears in message center when condition triggers)
AddOrder(OrderType.BUY_TO_OPEN, buySig[-1], price = buyPrice, tradeSize = 1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Buy");
 
Thanks @SleepyZ but your scripts work as usual, printing the open as entry or exit price, not the real condition price.

def Buy1 = close > close[1] and volume > volume[1];
def buySig = close and Buy1;
def buyPrice = if open[-1] and Buy1 then open[-1] else XXX[-1]; (XXX is where I need the real price that appears in message center when condition triggers)
AddOrder(OrderType.BUY_TO_OPEN, buySig[-1], price = buyPrice, tradeSize = 1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Buy");

I was basically answering how to show the price on the chart as it is not part of the addorder so you could better do your analyzis. I added the strategy report as in my review of it, the entryprice(), which was independent of the addorder function seemed to basically match the price in that report. I didn't run the strategy to see if price from the message alert matched the strategy report. If the alert message price does not match the bubble or the strategy report, I am not aware of any way to retrieve the alert message price other than a manual process.
 
Yes, I understand you and I appreciate it, but if there's no way to match alert price with report price, any backtest result is unreal, false.

I have not read that this topic is something relevant in this forum but it seems to me a serious problem in the attempt to develop any strategy.

Thinkorswim is a very powerful platform, I can't believe there isn't a way to transfer the current price at the moment the condition is triggered to the order strategy. (eg price when current bar volume is higher than previous bar volume)
 
Last edited:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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