NexusFi: Find Your Edge


Home Menu

 




Coding a PercentTrail that works like %Trail, but doesn't execute Intrabar!


Discussion in EasyLanguage Programming

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




Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now, It is Free
  • 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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.

-- Big Mike, Site Administrator

Available coupon codes for premium Elite Membership:
  • If you are a researcher and pay attention to details, you qualify for our 10% discount - "CHARTIST"
  • If you are a veteran or in public/community service, you qualify for 15% discount - "PURPLECHART"
  • If you are 60+ years old, you qualify for our 20% discount - "WISDOM"
  • Discounts are based on the honor system. If we can't trust you to do the right thing, please move along.

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

 
Search this Thread

Coding a PercentTrail that works like %Trail, but doesn't execute Intrabar!

(login for full post details)
  #1 (permalink)
djvie11
Chicago, IL
 
Posts: 52 since Jul 2013
Thanks Given: 29
Thanks Received: 1

Hi Guys

So I've been going back and forth trying to get this to work. I would love to use the PercentTrailing code with my strategy but I don't want for the order to be submitted intrabar (too many fluctuations). I would like to assess the max run-up of the position and calculate how much that max run-up has come down @ the close of the bar (not intrabar).

I tried to code this multiple ways into my strategy, but everything I've tried works nothing close to adding a "PercentTrailing" to my strategy. My attempts are below. Any suggestions would be greatly appreciated!

1) make it a condition, and when said condition triggers it would exit the position

 
Code
Inputs:
DollarAmt (1),
PctTrail (.25);

Condition5 = C <  (OpenpositionProfit + DollarAmt) - (MaxpositionProfit * PctTrail) ) ;
2) Then I tried putting this at the end of my code to exit as well:
 
Code
Inputs:
DollarAmt (1),
PctTrail (.25);

IF
(OpenPositionProfit + DollarAmt) < MaxPositionProfit - (MaxPositionProfit * PctTrail) 
THEN 
SetExitOnClose  ;
Again, non of these "solutions" worked like the true SetPercentTrailing code. Any ideas of how to work this on the close of the bar?

Thanks!
Brandon

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
VIX1D
NinjaTrader
RangeDisparityMeter Indicator for NT8
Platforms and Indicators
Can Dump be caught with Algo Trade
Crypto Futures
BollingerPro discussion
The Elite Circle
Strategy: second data series for using correct entry tim …
NinjaTrader
 

(login for full post details)
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,415 since Apr 2013
Thanks Given: 437
Thanks Received: 1,611


djvie11,

when the condition for your stop is met you can send an order to close the open position, for example
 
Code
Sell ( "LX" ) next bar market ;
This would issue the order at the end of the bar and you'd get executed around the open of the next bar. Which is to be expected when you send an order at the close.

You could fool your software (and yourself as you will create results that you can't reproduce live) by using "this bar Close" for the order, but this will likely not be the fills you get live.
You could look into custom sessions that would allow you to walk around that problem or to use intrabar order generation, which would give you the ability to close out the position near the actual bar close.

Regards,

ABCTG

Follow me on Twitter Reply With Quote





NexusFi Trading Community Platforms and Indicators EasyLanguage Programming > Coding a PercentTrail that works like %Trail, but doesn't execute Intrabar!


Last Updated on September 29, 2016


© 2023 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