NexusFi: Find Your Edge


Home Menu

 





Trying to set trailing stop to be two ticks below the low>> HELP!


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one djvie11 with 11 posts (0 thanks)
    2. looks_two kevinkdog with 8 posts (7 thanks)
    3. looks_3 budfox with 3 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 5,771 views
    2. thumb_up 8 thanks given
    3. group 3 followers
    1. forum 22 posts
    2. attach_file 0 attachments




 
Search this Thread

Trying to set trailing stop to be two ticks below the low>> HELP!

  #1 (permalink)
 budfox 
Toronto
 
Experience: Beginner
Platform: Sierra
Broker: MB
Trading: ES
Posts: 313 since Jun 2013

Hi there,

I am hoping more experienced futures.io (formerly BMT) members such as @Beljevina @bukkan @ratfink @sam028 @vvhg @KennyK @vantojo @ would be kind enough to provide some assistance.

I am brand new to the world of coding, so please be a bit patient with me.

My objective is to have a profit target that is 1 ATR below the low of the entry candle (Short).

I developed the bulk of the strategy in the wizard , but I was informed by NT staff, the wizard does not have the ability to subtract the ATR, and has to be manually coded.

If someone could be so kind as to show me how to manually alter the code I would greatly appreciate it.

I would be more than happy to PM you my code.

Thank You,

BF.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Futures True Range Report
The Elite Circle
 
  #3 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


Not compiled nor tested but something like this :
 
Code
                            
int AtrPeriod=14;

SetProfitTarget(CalculationMode.Price,Low[0]-ATR(AtrPeriod)[0]); 

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
 budfox 
Toronto
 
Experience: Beginner
Platform: Sierra
Broker: MB
Trading: ES
Posts: 313 since Jun 2013


sam028 View Post
Not compiled nor tested but something like this :
 
Code
                            
int AtrPeriod=14;

SetProfitTarget(CalculationMode.Price,Low[0]-ATR(AtrPeriod)[0]); 

Hello Sam, @sam028

Thank you so much for providing me with this code. I am trying my best to learn C#.

Just curious, have you ever experienced a situation where there was a particular model, that you could not code/backtest?

Have a great day!

BF

Started this thread Reply With Quote
  #5 (permalink)
djvie11
Chicago, IL
 
Posts: 52 since Jul 2013
Thanks Given: 29
Thanks Received: 1

So this thread seems to be on a similar topic ...

I'm looking to use the "Percent Trailing" code for easylanguage and turn it into a "point trailing" code. This is what the % trailing looks like:

 
Code
inputs: 
	PositionBasis( true ), 
	FloorAmt( 1 ), 
	TrailingPct( 20 ) ;                              

if PositionBasis then
	SetStopPosition
else
	SetStopShare ;

SetPercentTrailing( FloorAmt, TrailingPct ) ;
Now what I'm looking to do is substitute "FloorAmt" with something like "PointAmt" (<-- not a reserved word) and "SetPercentTrailing" with "SetPointTrailing" (<--- also not a reserved word).

I've looked at the reserved words and can't seem to find a solution to this. Does anyone have an idea of how I could go about coding this? ANY info would be very much appreciated!

thanks,
brandon

Reply With Quote
  #6 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338


djvie11 View Post
So this thread seems to be on a similar topic ...

I'm looking to use the "Percent Trailing" code for easylanguage and turn it into a "point trailing" code. This is what the % trailing looks like:

 
Code
inputs: 
	PositionBasis( true ), 
	FloorAmt( 1 ), 
	TrailingPct( 20 ) ;                              

if PositionBasis then
	SetStopPosition
else
	SetStopShare ;

SetPercentTrailing( FloorAmt, TrailingPct ) ;
Now what I'm looking to do is substitute "FloorAmt" with something like "PointAmt" (<-- not a reserved word) and "SetPercentTrailing" with "SetPointTrailing" (<--- also not a reserved word).

I've looked at the reserved words and can't seem to find a solution to this. Does anyone have an idea of how I could go about coding this? ANY info would be very much appreciated!

thanks,
brandon

Try SetDollarTrailing. But, both of the trailing functions will give overly optimistic results, unless you use LIBB at the 1 tick level. Personally, I'd avoid both of them.

Follow me on Twitter Reply With Quote
  #7 (permalink)
djvie11
Chicago, IL
 
Posts: 52 since Jul 2013
Thanks Given: 29
Thanks Received: 1


kevinkdog View Post
Try SetDollarTrailing. But, both of the trailing functions will give overly optimistic results, unless you use LIBB at the 1 tick level. Personally, I'd avoid both of them.

Gotcha, thanks for the suggestion!

I also just got the below code to work too, if anyone needs it


Quoting 
PositionBasis( true ),
TrailingPts ( 1 ),
TrailingPct ( 50 ) ;


Reply With Quote
  #8 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338


djvie11 View Post
Gotcha, thanks for the suggestion!

I also just got the below code to work too, if anyone needs it

Just don't believe the results. Once you see them, you will certainly want to believe them.

Follow me on Twitter Reply With Quote
Thanked by:
  #9 (permalink)
djvie11
Chicago, IL
 
Posts: 52 since Jul 2013
Thanks Given: 29
Thanks Received: 1


kevinkdog View Post
Just don't believe the results. Once you see them, you will certainly want to believe them.

Kevin -

I agree with you - in my past experience these results were much, muuuuch better than how the strategy actually performed in the live market. What's your opinion of this occurrence? Slippage? The trailingPct not actually being able to see the fluctuations of the market in real-time?

If so, wouldn't using the back-testing resolution of "Use look-inside-bar Back Testing" be of use in this situation?

thanks
-brandon

Reply With Quote
  #10 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338



djvie11 View Post
Kevin -

I agree with you - in my past experience these results were much, muuuuch better than how the strategy actually performed in the live market. What's your opinion of this occurrence? Slippage? The trailingPct not actually being able to see the fluctuations of the market in real-time?

If so, wouldn't using the back-testing resolution of "Use look-inside-bar Back Testing" be of use in this situation?

thanks
-brandon

Yes, as I previously mentioned, you can get accurate results if you use Look Inside Bar Backtesting at the 1 tick level. But that usually means you can only test 6 months back, unless you have a tick database stored on your PC.

Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on September 26, 2016


© 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