# Question: thinkScript entry price

##### New member
Good morning! Happy labor day! Quick question, has anybody ran into this issue with thinkscript:

I'm trying to AddOrder 1% below the daily open but when I do:

It shows that I enter at the open price instead of entering 1% below the open.

However, when I do almost the same thing in studies:

plot line = (open * 0.99); the line gets plotted at the correct price; 1% below the open.

Does anybody know what the issue is? How can I get in 1% below the open?

Solution
@rad14733 Thank you for your answer and quick response. Any many hours of research even prior to making this post, I ended up finding a work around this issue. I hope this helps somebody who comes to check on this thread in the future.

Here is the lines of code which allowed me to buy at 1% below the open:

def discount = 0.99;
def buy_price = open * 0.99;
def entry_condition = (open * discount) <= high && (open * discount) >= low;

Yes, the proper logic is to buy at the open of the next candle after the confirmation candle... You can streamline your logic to the following which requires less calculations and thus improves performance...

Ruby:
def discount =...
@SeattleTrader20 What you are seeing is an inherent flaw within the AddOrder() Strategy functionality of Thinkorswim... Orders only fill after the candle closes, not based on price action during the candles formation... This is a limitation for which there is no real remedy, unfortunately... The best we can do is to make adjustments to the conditions, entry price, and which candle that entry takes place on...

@rad14733 Thank you for your answer and quick response. Any many hours of research even prior to making this post, I ended up finding a work around this issue. I hope this helps somebody who comes to check on this thread in the future.

Here is the lines of code which allowed me to buy at 1% below the open:

def discount = 0.99;
def buy_price = open * 0.99;
def entry_condition = (open * discount) <= high && (open * discount) >= low;

@rad14733 Thank you for your answer and quick response. Any many hours of research even prior to making this post, I ended up finding a work around this issue. I hope this helps somebody who comes to check on this thread in the future.

Here is the lines of code which allowed me to buy at 1% below the open:

def discount = 0.99;
def buy_price = open * 0.99;
def entry_condition = (open * discount) <= high && (open * discount) >= low;

Yes, the proper logic is to buy at the open of the next candle after the confirmation candle... You can streamline your logic to the following which requires less calculations and thus improves performance...

Ruby:
def discount = 0.99;
def buy_price = open * discount;

@rad14733 Thank you, I added that to my code but it looks like there's an issue. The code is trying to buy and sell at a price outside of the body of the candle.. do you have any advice/ resources that can help me fix this. Attached below is my full code and a picture of what I'm talking about. Thank you so much, your help is invaluable!

Photo:
Code:
input discount = 0.99;

#Static Variables
def entry_price = EntryPrice();
def buy_price = open * 0.99;
def sell_price = entry_price * 1.01;
def exit_condition = sell_price <= high && sell_price >= low;

#Orders

Basically what I want it to do is buy when the price goes down 1% in 1 day and sell whenever it goes back up 1%.

@SeattleTrader20 Unfortunately, we can't realistically buy at a price that doesn't exist during the candle and that is what is happening... The issue is that AddOrder() won't wait for your desired price, it only trades based on the Condition provided, at the Price you state, on the candle you tell it to enter on... In order to only buy at your desired price you need to add that as part of your Condition... And that means less entry opportunities... Otherwise you need to buy at the open of the next candle... We have to live within the limitations that the platforms backtesting capabilities provide us...

@rad14733 Understood, I will work on that.

87k+ Posts
301 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
• 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?