Update profit target or trailing stop based on trade conditions - futures io
futures io



Update profit target or trailing stop based on trade conditions


Discussion in EasyLanguage Programming

Updated
    1. trending_up 6,598 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Update profit target or trailing stop based on trade conditions

(login for full post details)
  #1 (permalink)
 ShadowFox 
CO/USA
 
Experience: Intermediate
Platform: TradeStation, Multicharts
Trading: Stocks, Futures
 
ShadowFox's Avatar
 
Posts: 116 since Jun 2020
Thanks: 69 given, 156 received

Does setprofittarget, SetPercentTrailing, and setstoploss get called on each bar or is it run once per strategy? I am struggling to get the below to be able to update values. Any ideas?

If Condition1 = true then Begin
PT = Condition1PT;
TrlAmnt = Condition1TrlAmnt;
TrlPcnt = Condition1TrlPcnt;
SL = Condition1SL;
end
else if Condition2 = true then begin
PT = Condition2PT;
TrlAmnt = Condition2TrlAmnt;
TrlPcnt = Condition2TrlPcnt;
SL = Condtion2SL;
end;

setprofittarget(PT*Bigpointvalue);
SetPercentTrailing( TrlAmnt, TrlPcnt );
setstoploss(SL*Bigpointvalue);

Visit my futures io Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
How to obtain the day of year and the week of year in Ea …
EasyLanguage Programming
Market on Close data within IB
Platforms and Indicators
[helpdcan tradestation copy trades to Eightcap MT4 & MT5
TradeStation
Anyone ever use "Seasonax" website?
Trading Reviews and Vendors
Multi Time Frame High/Low/Median levels
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Is anyone actually making money?
52 thanks
An embarrassing, honest confession
40 thanks
Sierra vs. Ninja : why I chose .....
9 thanks
Demo accounts order fill
6 thanks
Rithmic vs Denali - Market Depth Difference
6 thanks
 
(login for full post details)
  #2 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,363 since Apr 2013
Thanks: 426 given, 1,580 received

jeffc1000,

when you say "I am struggling to get the below to be able to update values", what happens exactly within your code? Did you use the print statement to check if the Condition1 and Condition2 variables are actually true on separate bars and if the values for your variables are updated?

Regards,

ABCTG


jeffc1000 View Post
Does setprofittarget, SetPercentTrailing, and setstoploss get called on each bar or is it run once per strategy? I am struggling to get the below to be able to update values. Any ideas?

If Condition1 = true then Begin
PT = Condition1PT;
TrlAmnt = Condition1TrlAmnt;
TrlPcnt = Condition1TrlPcnt;
SL = Condition1SL;
end
else if Condition2 = true then begin
PT = Condition2PT;
TrlAmnt = Condition2TrlAmnt;
TrlPcnt = Condition2TrlPcnt;
SL = Condtion2SL;
end;

setprofittarget(PT*Bigpointvalue);
SetPercentTrailing( TrlAmnt, TrlPcnt );
setstoploss(SL*Bigpointvalue);


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #3 (permalink)
 ShadowFox 
CO/USA
 
Experience: Intermediate
Platform: TradeStation, Multicharts
Trading: Stocks, Futures
 
ShadowFox's Avatar
 
Posts: 116 since Jun 2020
Thanks: 69 given, 156 received



ABCTG View Post
jeffc1000,

when you say "I am struggling to get the below to be able to update values", what happens exactly within your code? Did you use the print statement to check if the Condition1 and Condition2 variables are actually true on separate bars and if the values for your variables are updated?

Regards,

ABCTG

You were right ABCTG. Looks like both conditions were false due to some other clearing logic I had going on. I have resolved the issue. Lesson learned, don't wrestle with one problem too long, sleep on it and clarity will come.

Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #4 (permalink)
 FastNCurious 
saint louis MO
 
Experience: Intermediate
Platform: TradeStation
Trading: NQ, ES, YM, CL, GC
 
FastNCurious's Avatar
 
Posts: 149 since Oct 2017
Thanks: 95 given, 177 received

I have a question for @ABCTG ,

I am trying to create a trailing stop that moves my stoploss up to a specific positive value after the trade reaches the first target. I do not want it to be a percentage because as the first target is hit my next target is 2x first target and I want the difference to be the same value
from entry to original stoploss as the 1st profit threshold to 2nd stoploss.

(entry price - stoploss 1) = (profitthreshold1-stoploss 2)

I know I am asking a very simple question but for the life of me I can't figure it out.

I thought about moving the stoploss to a negative value since it is on the opposite side of a negative loss compared to the entry price. I don't think this will work but I will give it a try.

I have also had this idea come up before because I wanted to set a breakeven stop to breakeven plus a few ticks in the positive direction so I will more than likely not eat any slippage and commissions on a breakeven trade. I was unable to figure this out before but I imagine once I have the answer for one the other would be quite easy.

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #5 (permalink)
 ABCTG   is a Vendor
 
 
Posts: 2,363 since Apr 2013
Thanks: 426 given, 1,580 received

@FastNCurious,

I am not sure I follow you correctly as you seem to have the equation laid out already. You would just have to solve it for "stoploss 2":

stoploss 2 = profitthreshold1 - (entry price - stoploss 1)

You might want to consider using an actual stop order here instead of using negative values for "setstoploss".

Regards,

ABCTG


FastNCurious View Post
I have a question for @ABCTG ,

I am trying to create a trailing stop that moves my stoploss up to a specific positive value after the trade reaches the first target. I do not want it to be a percentage because as the first target is hit my next target is 2x first target and I want the difference to be the same value
from entry to original stoploss as the 1st profit threshold to 2nd stoploss.

(entry price - stoploss 1) = (profitthreshold1-stoploss 2)

I know I am asking a very simple question but for the life of me I can't figure it out.

I thought about moving the stoploss to a negative value since it is on the opposite side of a negative loss compared to the entry price. I don't think this will work but I will give it a try.

I have also had this idea come up before because I wanted to set a breakeven stop to breakeven plus a few ticks in the positive direction so I will more than likely not eat any slippage and commissions on a breakeven trade. I was unable to figure this out before but I imagine once I have the answer for one the other would be quite easy.


Follow me on Twitter Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Update profit target or trailing stop based on trade conditions


Last Updated on March 26, 2021


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2023 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts