NexusFi: Find Your Edge


Home Menu

 





Trailing-stop-limit


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ABCTG with 3 posts (1 thanks)
    2. looks_two Gonzo78 with 3 posts (1 thanks)
    3. looks_3 sujiroy with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 5,572 views
    2. thumb_up 2 thanks given
    3. group 4 followers
    1. forum 8 posts
    2. attach_file 0 attachments




 
Search this Thread

Trailing-stop-limit

  #1 (permalink)
 Gonzo78 
Dortmund + Germany
 
Experience: Beginner
Platform: TradeStation
Trading: Crude CL
Posts: 8 since Sep 2017
Thanks Given: 1
Thanks Received: 1

Hi,


Tradestation has the built-in function/reserved word:

SetStopPosition;
SetPercentTrailing(FloorAmnt, Amount);


I would like to have all the features of this trailing-stop-function included, only with the difference that the exit occurs with a limit-order.

For example:

SetStopPosition;
SetPercentTrailing(200, 25);

this means:

at 200$-position-profit the TrailingStop is activated, when the current position profit sinks to 150$ a market order is sent to the exchange to exit the position.


I would like to modify this, and exit with a limit-order.

When the current profit sinks to the (as in the above example) +150$-mark, I would like my strategy to send a limit-order to the exchange, so if the limit-order gets filled, I cash in pretty close to the 150$-profit (without commissions).


Also, the Tradestation-built-in function :

SetStopPosition;
SetPercentTrailing(FloorAmnt, Amount);

this function can execute an exit-order on the same bar as the entry occured, I would like to keep this feature in the new stop-limit-trailing stop:

example with 15-min.-bars:
if Entry at 0600pm, and at 0604pm profit >=200$, get out with a profit on the same bar, when necessary.

Is it possible to code this in EasyLanguage ?

Thank you in advance
Gonzo

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Increase in trading performance by 75%
The Elite Circle
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
27 thanks
Tao te Trade: way of the WLD
23 thanks
Diary of a simple price action trader
22 thanks
My NQ Trading Journal
14 thanks
GFIs1 1 DAX trade per day journal
9 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627


Gonzo78,

unfortunately you can't change the behavior of the reserved words. What you can do is to write your own code to send a limit order when your conditions are met and up the limit price thus creating the trailing. If you want your code to be able to update during the bar (or exit during the entry bar), you will need to use intrabar order generation.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
 tr8er 
Europe
Market Wizard
 
Experience: Advanced
Platform: TradeNavigator, BookMap
Trading: ES, CL, 6E, 6B
Posts: 704 since Jan 2017
Thanks Given: 220
Thanks Received: 709

Hi Gonzo,

I've no idea how to program that, but a Stop-Limit is the worst you can do.

Reply With Quote
  #5 (permalink)
 Gonzo78 
Dortmund + Germany
 
Experience: Beginner
Platform: TradeStation
Trading: Crude CL
Posts: 8 since Sep 2017
Thanks Given: 1
Thanks Received: 1

Hello ABCTG,

sorry for my late reply.

I was trying to write such a trailing-stop on my own, the „IntrabarOrderGeneration“ works fine, but I gave up on the rest of the code.

May I ask you to write a few lines of code for me?

Trailingstop Conditions on 15-min.-bars:

Long Trailingstop:

If CurrentHigh >= (EntryPrice + $0.1) then trail with fixed amount of $0.03.

When the exit conditions are met, get out with a limit order.

Or in other words:
$0.1 (or better) profit is the level for the stop to take effect, the trade is closed when $0.03 of the maximum profit are lost, analogous for shorts.


Short Trailingstop:

If CurrentLow <= (EntryPrice - $0.1) then trail with fixed amount of $0.03.



Thank you in advance and best regards
Gonzo

Started this thread Reply With Quote
Thanked by:
  #6 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

Gonzo78,

if you post your code attempt someone might be able to direct you in the right direction. For coding requests you might want to post within the thread.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
  #7 (permalink)
 Gonzo78 
Dortmund + Germany
 
Experience: Beginner
Platform: TradeStation
Trading: Crude CL
Posts: 8 since Sep 2017
Thanks Given: 1
Thanks Received: 1

Hello ABCTG,

ok, thank you.

Gonzo

Started this thread Reply With Quote
  #8 (permalink)
sujiroy
Vancouver
 
Posts: 14 since Aug 2017
Thanks Given: 12
Thanks Received: 4


tr8er View Post
Hi Gonzo,

I've no idea how to program that, but a Stop-Limit is the worst you can do.

Yes, have been a victim of this before Stop has to be a market order imho.

Reply With Quote
  #9 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

Gonzo78,

in order not to hijack the "Want your EasyLanguage indicator..." thread, I am posting this in here.
Based on the code modification you posted here , it appears that you don't need the variables EP and MP in your code anymore at all.

What values does MP_prev hold other than the one you used in the initialization? I am thinking along the lines of what this values does with the way you wrote your code and especially what this results in.

You could use the print reserved word to check what values the variable holds.

Regards,

ABCTG


Gonzo78 View Post
Hello ABCTG,



I did some corrections to my code above.


I really don't know how to proceed furher, my EasyLanguage-skills are limited at this point.


best regards
Gonzo


Follow me on Twitter Reply With Quote




Last Updated on September 15, 2017


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts