Setting StopLosses and ProfitTargets without using actual dollar amounts - futures io
futures io futures trading



Setting StopLosses and ProfitTargets without using actual dollar amounts


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Alex2013 with 2 posts (0 thanks)
    2. looks_two minntabo with 2 posts (0 thanks)
    3. looks_3 LogicalTrader with 1 posts (1 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 4,579 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 5 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,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
 

Setting StopLosses and ProfitTargets without using actual dollar amounts

(login for full post details)
  #1 (permalink)
new york, ny
 
 
Posts: 5 since Sep 2013
Thanks: 1 given, 0 received

Hi all,

I'm trying to write a strategy for trading the ES emini futures contract (e.g., ESZ3), but am having trouble setting Stop Losses and Profit Targets.

Many posts I've seen on the web focus on setting Stops and Profits based on actual dollar amounts. For example, Stopping out if the trade goes $200 against me, and Taking Profit if the trade goes $800 in my favor. The typical SetStopLoss (200) and SetProfitTarget (800) would be used.

However, what if I want to set my Stop and Profit based on values of previous bars?

1. For example, what if I want to set my Stop at High[1] (i.e., high of the previous bar)?

2. Also, what if I want to set my Target at Close[1] - 8 points of the contract? (That is, I want my Target to be hit after price goes 8 points (or $400) below the close of the previous bar?

I can't seem to figure out how to set this using the SetStopLoss and SetProfitTarget functions.

Any help is appreciated!
-K

Reply With Quote

Can you help answer these questions
from other members on futures io?
Which kind of Blockvolume is visible? - order processing
Emini and Emicro Index
What blockvolume is visible? - order processing
NinjaTrader
Second Entry Indicator (Looking for testers/feedback)
NinjaTrader
SimplerOptions
Trading Reviews and Vendors
MACD line not plotting after change of plot order
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Selling Options on Futures?
109 thanks
Battlestations: Show us your trading desks!
108 thanks
Rank your Futures vs Stocks trading priority
55 thanks
Want your NinjaTrader indicator created, free?
27 thanks
Whats this confusion with margins?
21 thanks
 
(login for full post details)
  #3 (permalink)
Houston, TX
 
 
Posts: 294 since Aug 2013
Thanks: 1,420 given, 757 received


One way to do this would be to not use the setProfitTarget and setStopLoss methods. Instead just use sell next bar at n limit/stop etc. syntax.


Quoting 
1. For example, what if I want to set my Stop at High[1] (i.e., high of the previous bar)?

You could write:

 
Code
If (<your condition here, mostly the bar you entered at or whatever decides your stop>) then
Value1 = High[1];

Buy Cover next bar at Value1 stop;

Quoting 
2. Also, what if I want to set my Target at Close[1] - 8 points of the contract? (That is, I want my Target to be hit after price goes 8 points (or $400) below the close of the previous bar?

You could write:

 
Code
if (<my condition>) then
Value1 = Close[1] - 8;

Sell next bar at Value1 limit;


Of course, you would want additional checks like if you are in a position or not etc. before you direct your strategy to place an order. Hope this gives you some ideas.

There are some great free tutorials at Free Tutorials for EasyLanguage Services for TradeStation if you want to take a look.

Hope this helps.

Reply With Quote
 
(login for full post details)
  #4 (permalink)
new york, ny
 
 
Posts: 5 since Sep 2013
Thanks: 1 given, 0 received

Thanks iNeo for the tips. Everything seems to be working. I'll keep posted on results.

Reply With Quote
 
(login for full post details)
  #5 (permalink)
London
 
 
Posts: 2 since Oct 2013
Thanks: 0 given, 0 received

Hello,

I am completely new to EasyLanguage and programming in general. I am hoping someone could help me set a trailing stop loss which is not measured in $ but in %. In other words, I want to exit a long position if it falls by 1% from its highest point after entry, as opposed to it falling by 1$. Please note that it's different from 'SetPercentTrailing' as it allows you to specify a percentage stop loss only relative to a certain $ profit level. I have tried the following code to exit a long position but it doesn't work:

 
Code
[IntrabarOrderGeneration = False]
inputs: PositionBasis( false ), TrailStopPct ( 1 ) {enter in percentage points} ;

variables: StopCalc (0) ;

if PositionBasis then
    SetStopPosition
else
    SetStopShare ;

StopCalc = Close - Close * TrailStopPct * 0.01 ;

if Close < = StopCalc then
    Sell next bar at market ;
Also how would you do such a trailing stop loss to exit a short position?

Any help would be much appreciated!

Alex

Reply With Quote
 
(login for full post details)
  #6 (permalink)
London
 
 
Posts: 2 since Oct 2013
Thanks: 0 given, 0 received

Hello again!

I have managed to find an extremely powerful stop loss strategy that does offer a % trailing stop loss, including many other sophisticated features. It looks quite exciting! However, as a user of MultiCharts, I can't use this code as it's written for TradeStation, which seems to be using a more up-to-date version of EasyLanguage than MultiCharts. For example, when I compile it in MultiCharts the editor doesn't understand "Method void", "#region", etc. I have already found on Big Mike forum how to deal with the 'method void' problem (bigmiketrading.com/easylanguage-programming/14181-tradestation-9-easylanguage-multi-charts-easy-language.html), but my programming skill is so poor that I don't really understand the suggested solution.

Would there be anyone kindhearted enough to help me out here please

The description and the code for the stop loss strategy I found is here: hightick.com/Tradestation/Strategy/StopsFlexible/index.html

Cheers!
Alex

Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Setting StopLosses and ProfitTargets without using actual dollar amounts


Last Updated on October 3, 2013


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, 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