NexusFi: Find Your Edge


Home Menu

 





Limit Order and Trailing Stop


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Tiger45 with 2 posts (0 thanks)
    2. looks_two MXASJ with 2 posts (8 thanks)
    3. looks_3 Trader.Jon with 1 posts (0 thanks)
    4. looks_4 mariolmb with 1 posts (0 thanks)
    1. trending_up 5,937 views
    2. thumb_up 8 thanks given
    3. group 3 followers
    1. forum 7 posts
    2. attach_file 1 attachments




 
Search this Thread

Limit Order and Trailing Stop

  #1 (permalink)
 
Tiger45's Avatar
 Tiger45 
San Diego, CA, USA
 
Experience: Intermediate
Platform: Sierra Chart
Trading: CL, ES
Posts: 309 since Sep 2010
Thanks Given: 203
Thanks Received: 422

Hi,
I'd like to create a strategy where a stop limit order is placed after a condition is met, then cancel this order X bars later if not filled. If it is filled, I'd like to trail the stop based upon the previous bar's close.

For example, on a long trade, after the condition is met, I'd like an order placed below the market. After X bars and not filled, cancel the order. If the order is filled, I'd like the stop to be set on the low of the previous bar, then trail up on the close with each bar.

Can someone give me a push in the right direction?

Thanks.

Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Deepmoney LLM
Elite Quantitative GenAI/LLM
ZombieSqueeze
Platforms and Indicators
NexusFi Journal Challenge - April 2024
Feedback and Announcements
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
27 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #3 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184



Tiger45 View Post
Hi,
I'd like to create a strategy where a stop limit order is placed after a condition is met, then cancel this order X bars later if not filled. If it is filled, I'd like to trail the stop based upon the previous bar's close.

For example, on a long trade, after the condition is met, I'd like an order placed below the market. After X bars and not filled, cancel the order. If the order is filled, I'd like the stop to be set on the low of the previous bar, then trail up on the close with each bar.

Can someone give me a push in the right direction?

Thanks.

I hope someone more experienced can jump in here: I have seen conditions where the limit order was not accepted by the broker because it was too outside the bounds of the market activity, but, I cant recall the exact details. Thi is just offered for discussion, sorry I cant be more specific: I felt it might have a consideration in your design.

TJ

Reply With Quote
  #4 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

Ironically I just got a strat that uses BuyStopLimit and SellStopLimit working overnight! I was getting order rejections but I think that is solved.

Let me have a coffee and I'll post some code here.

Reply With Quote
Thanked by:
  #5 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

I have a strategy that uses a custom indicator. That indicator plots levels at which I want to enter with either a EnterLongStop() or a EnterShortStop(). I was having issues if Close[0] was above the Long level, for example.

I did two things. The first got rid of 90% of the errors. Sample code:

 
Code
                            
 
if (GoLongOK && Close[0]<MyTradeLogic().LongEntryLevel[0])
{
    
EnterLongStop(DefaultQuantityMyTradeLogic().LongEntryLevel[0], "MyLong")

The logic being if price has already moved above my LongEntryLevel, I don't want to submit a EnterLongStop order (though I might want a Limit order, which would require other code).

Alas 90% isn't good enough so I went back to the custom indicator and added a variable that I could access in the Strategy so that BOTH the indicator and the strategy were better hard wired to unambiguosly allow a long or a short. I tracked that issue through using print statements and found the indicator would sometimes allow the opposite of what I wanted and that would result in rejected orders.

The basis for the indicator upgrade code can be found here:

Indicator: Exposing indicator values that are not plots - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

Hope that helps.

EDIT: Attached the SampleCancelOrder example from the Ninja forum that shows how to cancel or amend an order after n bars. It uses IOrders though.

Attached Files
Elite Membership required to download: SampleCancelOrder.zip
Reply With Quote
  #6 (permalink)
 
Tiger45's Avatar
 Tiger45 
San Diego, CA, USA
 
Experience: Intermediate
Platform: Sierra Chart
Trading: CL, ES
Posts: 309 since Sep 2010
Thanks Given: 203
Thanks Received: 422


MXASJ View Post

Hope that helps.

EDIT: Attached the SampleCancelOrder example from the Ninja forum that shows how to cancel or amend an order after n bars. It uses IOrders though.

Thanks for this. I'll play with it tonight.

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #7 (permalink)
 
Vikings1's Avatar
 Vikings1 
Minneapolis, MN, USA
 
Experience: Master
Platform: ninjatrader, TOS
Trading: Weekly Options
Posts: 188 since Sep 2011
Thanks Given: 26
Thanks Received: 418

Good afternoon to everyone who uses Ninja,

I am a very experienced trader, but not in using the Ninja format. Can you Autotrade in Ninja using a "ATR Trailing Stop" If so, can someone help me out and show me how to do it? I have searched all over the place and just can seem to find how, but I know it must be possible.

My set-up is just a onder thing and I have no problem programming that part of it, just want to be able to add an ATR Trailing stop as my stop out instead of a standard trailing stop.

Thanks.

Vikings

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
 mariolmb 
Montreal
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Stocks
Posts: 2 since Jan 2012
Thanks Given: 0
Thanks Received: 0

Hello Vicking1,

just seen your question.
May be very late,
I tried to find about the same as you,
an ATR volatility stop.
Did you receive answer to your question.
If yes, did you receive it from BigMike forum.
And is it possible for me to get it.

If you didn't get answer.
I tried to find it on my side and can't.

But I found something could help you.
It's on ninjacators site.
Cost little buck, (around 97$)but if you can't find it free,
and if it's what you want.
They call "ATR trailing stop"

I got an indicator from them who work as promise.


Thanks

Mariolmb

Reply With Quote




Last Updated on May 9, 2013


© 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