Sell Based on a Price Increase

Tomahawk6117

Member
Plus
Hi @halcyonguy I hope you are doing well and thank you again for all of your help. In the think script below, it works very well for identifying a 5% price gain from the market open, thank you very much for your help with this. If I wanted to alter the think script so that it sold when the price increased by $0.01 from the market open price, instead of on a percentage basis, may you please help me with this? Thank you again for your time and your help @halcyonguy.

Code:
input sell_percent_gain = 5.0;
input price1 = high;
input start = 0930;
def daystart = secondstillTime(start) == 0;
def dayopen = if daystart then open else dayopen[1];
def daydiff = round(price1 - dayopen,2);
def pergain = round(100*daydiff/dayopen,1);

input trigger_on_all_prices_below_stop = yes;
def sell1 = if (daystart or trigger_on_all_prices_below_stop) and pergain >= sell_percent_gain then 1 else if pergain crosses above sell_percent_gain then 1 else 0;

plot z1 = sell1;
 
Hi @halcyonguy I hope you are doing well and thank you again for all of your help. In the think script below, it works very well for identifying a 5% price gain from the market open, thank you very much for your help with this. If I wanted to alter the think script so that it sold when the price increased by $0.01 from the market open price, instead of on a percentage basis, may you please help me with this? Thank you again for your time and your help @halcyonguy.

Code:
input sell_percent_gain = 5.0;
input price1 = high;
input start = 0930;
def daystart = secondstillTime(start) == 0;
def dayopen = if daystart then open else dayopen[1];
def daydiff = round(price1 - dayopen,2);
def pergain = round(100*daydiff/dayopen,1);

input trigger_on_all_prices_below_stop = yes;
def sell1 = if (daystart or trigger_on_all_prices_below_stop) and pergain >= sell_percent_gain then 1 else if pergain crosses above sell_percent_gain then 1 else 0;

plot z1 = sell1;

i think this will do it. on my cell , outside, hard to see screen.

Code:
input sell_percent_gain = 5.0;
input price1 = high;
input price2 = close;
input start = 0930;
input day_gain_to_sell = 0.01;
input trigger_on_all_prices_below_stop = yes;

def daystart = secondstillTime(start) == 0; def dayopen = if daystart then open else dayopen[1];
def daydiff = round(price1 - dayopen,2);
def daydiff2= round(price2 - dayopen,2);
 
def pergain = round(100*daydiff/dayopen,1);

#def sell1 = if (daystart or trigger_on_all_prices_below_stop) and pergain >= sell_percent_gain then 1 else if pergain crosses above sell_percent_gain then 1 else 0;
#plot z1 = sell1;

def sell2 = if (daystart or trigger_on_all_prices_below_stop) and price2 >= day_gain_to_sell then 1 else if price2 crosses above day_gain_to_sell  then 1 else 0;

plot z2 = sell2;
 

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

i think this will do it. on my cell , outside, hard to see screen.

Code:
input sell_percent_gain = 5.0;
input price1 = high;
input price2 = close;
input start = 0930;
input day_gain_to_sell = 0.01;
input trigger_on_all_prices_below_stop = yes;

def daystart = secondstillTime(start) == 0; def dayopen = if daystart then open else dayopen[1];
def daydiff = round(price1 - dayopen,2);
def daydiff2= round(price2 - dayopen,2);
 
def pergain = round(100*daydiff/dayopen,1);

#def sell1 = if (daystart or trigger_on_all_prices_below_stop) and pergain >= sell_percent_gain then 1 else if pergain crosses above sell_percent_gain then 1 else 0;
#plot z1 = sell1;

def sell2 = if (daystart or trigger_on_all_prices_below_stop) and price2 >= day_gain_to_sell then 1 else if price2 crosses above day_gain_to_sell  then 1 else 0;

plot z2 = sell2;
Thank you very much for your help @halcyonguy, I really appreciate it. I made some minor adjustments and I think this will be good. Thank you again for all of your help.

Code:
input day_gain_to_sell = 0.01;
input price1 = high;
input start = 0930;
input trigger_on_all_prices_below_stop = yes;

def daystart = secondstillTime(start) == 0;
def dayopen = if daystart then open else dayopen[1];
def daydiff = round(price1 - dayopen,2);

def sell2 = if (daystart or trigger_on_all_prices_below_stop) and daydiff >= day_gain_to_sell then 1 else if daydiff crosses above day_gain_to_sell then 1 else 0;

plot z2 = sell2;
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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