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,880 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!

  #11 (permalink)
djvie11
Chicago, IL
 
Posts: 52 since Jul 2013
Thanks Given: 29
Thanks Received: 1

hi Kevin

So to reignite this thread -- With % trailing, we know the trailing stops are executed intrabar. My question is - Is there a way to only execute % trailing at the end of the bar, and NOT intrabar?

(even with [Intrabarordergeneration = False] it'll still trigger the order)

thanks in advance for any info!
-Brandon

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
Increase in trading performance by 75%
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
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
24 thanks
Diary of a simple price action trader
21 thanks
My NQ Trading Journal
14 thanks
GFIs1 1 DAX trade per day journal
9 thanks
  #12 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,662 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,350


djvie11 View Post
hi Kevin

So to reignite this thread -- With % trailing, we know the trailing stops are executed intrabar. My question is - Is there a way to only execute % trailing at the end of the bar, and NOT intrabar?

(even with [Intrabarordergeneration = False] it'll still trigger the order)

thanks in advance for any info!
-Brandon

If you wrote code that calculated the price you wanted, you could.

Say you were long, and you calculate a price of XXXX to exit. Then it is simply:

if close<XXXX sell this bar at close;

This won't work on last bar of day though.

You could also do something like:

sell next bar at XXXX stop;

where XXXX is calculated based on a percent trailing or whatever you want.

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



kevinkdog View Post
If you wrote code that calculated the price you wanted, you could.

Say you were long, and you calculate a price of XXXX to exit. Then it is simply:

if close<XXXX sell this bar at close;

This won't work on last bar of day though.

You could also do something like:

sell next bar at XXXX stop;

where XXXX is calculated based on a percent trailing or whatever you want.

Thank you for the response, Kevin!

I'm now trying to make it a condition, but when I try to compile it it's saying "expression expected here." Obviously I'm coding this wrong.

 
Code
Condition1 = C[1] of data2 < SetPercentTrailing( FloorAmt, TrailingPct ) ;

Reply With Quote
  #14 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,662 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,350


djvie11 View Post
Thank you for the response, Kevin!

I'm now trying to make it a condition, but when I try to compile it it's saying "expression expected here." Obviously I'm coding this wrong.

 
Code
Condition1 = C[1] of data2 < SetPercentTrailing( FloorAmt, TrailingPct ) ;

You've got to create your own trailing stop expression. MaxpositionProfit and OpenPositionProfit could be useful.

Maybe if MaxpositionProfit-OpenPositionProfit>1000 //means when your current profit is $1000 less than the maximum profit the position hit at one time...

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


kevinkdog View Post
You've got to create your own trailing stop expression. MaxpositionProfit and OpenPositionProfit could be useful.

Maybe if MaxpositionProfit-OpenPositionProfit>1000 //means when your current profit is $1000 less than the maximum profit the position hit at one time...

Great idea, Kevin.

I came up with this, but I'm having trouble figuring out the command to cover the position at the end. I used SetStopPosition but that's not correct.

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

Condition1 = MaxpositionProfit > DollarAmt ;
Condition2 = MaxpositionProfit < MaxpositionProfit - (MaxPositionProfit * PctTrail);

IF Condition1 AND Condition2
THEN 
SetStopPosition  ;

Reply With Quote
  #16 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,662 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,350


djvie11 View Post
Great idea, Kevin.

I came up with this, but I'm having trouble figuring out the command to cover the position at the end. I used SetStopPosition but that's not correct.

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

Condition1 = MaxpositionProfit > DollarAmt ;
Condition2 = MaxpositionProfit < MaxpositionProfit - (MaxPositionProfit * PctTrail);

IF Condition1 AND Condition2
THEN 
SetStopPosition  ;



If you want to exit right when this is evaluated as true, then

sell this bat at close;

would work (except for last bar of day)

or

sell next bar at market;

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


kevinkdog View Post
If you want to exit right when this is evaluated as true, then

sell this bat at close;

would work (except for last bar of day)

or

sell next bar at market;

Understood.

Is there a command though that would exit both LONG (sell this bar at close) and SHORT (buy to cover at close) positions?

Reply With Quote
  #18 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,662 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,350


djvie11 View Post
Understood.

Is there a command though that would exit both LONG (sell this bar at close) and SHORT (buy to cover at close) positions?


setexitonclose;

but remember it will not work with real money on last bar of day. It works in backtest though.

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


kevinkdog View Post
setexitonclose;

but remember it will not work with real money on last bar of day. It works in backtest though.

your knowledge is much appreciated, Kevin!

happy trading.

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



kevinkdog View Post
setexitonclose;

but remember it will not work with real money on last bar of day. It works in backtest though.

And for what it's worth - that last bit of code I posted didn't work (It didn't understand the variables). This new code below works.

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

IF
(OpenPositionProfit + DollarAmt) < MaxPositionProfit - (MaxPositionProfit * PctTrail) 
THEN 
SetExitOnClose  ;

Reply With Quote




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