NexusFi: Find Your Edge


Home Menu

 





Advanced Strategy Writing


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one zeller4 with 4 posts (1 thanks)
    2. looks_two gregid with 2 posts (0 thanks)
    3. looks_3 traderwerks with 1 posts (0 thanks)
    4. looks_4 midasman with 1 posts (0 thanks)
    1. trending_up 5,297 views
    2. thumb_up 1 thanks given
    3. group 6 followers
    1. forum 8 posts
    2. attach_file 0 attachments




 
Search this Thread

Advanced Strategy Writing

  #1 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 477 since Jun 2009
Thanks Given: 1,416
Thanks Received: 404

Hello all,

I've been reading (and re-reading) the sections in the NT support helpguide in the Advance Event Driven Programming Section. ie: http://ww25.ninjatrader-support.com/HelpGuideV6/helpguide.html?OnExecution&subid1=20240327-2027-37c8-9954-80990f2af532

Does anyone have a comprehensive sample strategy that you could share which incorporates the various functions:

IOrder
IExecution
IPosition
OnOrderUpdate

Here's a snippet from the NT website which tells me I need to understand the use of these advanced functions together:
Quoting 

/*CRITICAL: If you want to drive your strategy logic based on order fills
you must use OnExecution() instead of OnOrderUpdate().
OnExecution() is always triggered after OnOrderUpdate().
There is internal strategy logic that is triggered after
OnOrderUpdate() is called but before OnExecution()
that can adversely affect your strategy if you are relying on
tracking fills within OnOrderUpdate(). */

The samples on the NT fileshare are the "Lite" version which typically only include the small sample of the syntax with the tie-in to the OnBarUpdate main section. Finding the "Needle In The Haystack" of how orders flow in one file is what i'm hoping someone will share. I understand there is an order flow with priorities of the internal workings of NT that are not revealed.

Any help or reference you can provide is much appreciated.

Regards,
Kirk

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
Build trailing stop for micro index(s)
Psychology and Money Management
Are there any eval firms that allow you to sink to your …
Traders Hideout
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
37 thanks
NexusFi site changelog and issues/problem reporting
23 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #2 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623

I definitely wouldn't seek advice from myself in this matter, but have you checked some sample strategies here at nexusfi.com (formerly BMT)?:



If I remember it correctly they include OnOrderUpdate and OnPositionUpdate but they are not really well commented (and most of the comments are in Italian anyway)

Good luck and if you would find anything helpful please post!

Reply With Quote
  #3 (permalink)
 
gabga100's Avatar
 gabga100 
New York
 
Experience: Advanced
Platform: NT
Posts: 147 since Nov 2009
Thanks Given: 44
Thanks Received: 72


Hey let me know if this helps ....

#region Variables
private IOrder myLongorder = null;
private IOrder myShortorder = null;

#endregion


protected override void OnExecution(IExecution execution) //
{
//oderhandling(IOrder order);



if (execution.MarketPosition == MarketPosition.Long )
{

CancelOrder(myAskorder);
}

else
{

CancelOrder(myBidorder);
}



}

Reply With Quote
  #4 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 477 since Jun 2009
Thanks Given: 1,416
Thanks Received: 404

thanks gregid,
all of those files (from the Italian connection!) had some good script on IPosition and one had an IOrder section -i'll check them out further... I did a quick market replay and didn't have any orders placed so I'm not sure how to get some results to verify....

The other thing that makes me wonder is if IExecution were added to any of these files, what would be the manner to tie them all together???

Any other leads or assistance is greatly appreciated.
kz

Started this thread Reply With Quote
  #5 (permalink)
 
gregid's Avatar
 gregid 
Wrocław, Poland
 
Experience: Intermediate
Platform: NinjaTrader, Racket
Trading: Ockham's razor
Posts: 650 since Aug 2009
Thanks Given: 320
Thanks Received: 623

Hi Kirk

Were you able to find any other sample strategies with IOrders? I still struggle trying to making these work as I need them.

Reply With Quote
  #6 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 477 since Jun 2009
Thanks Given: 1,416
Thanks Received: 404

Hi gregid,

Not yet - nothing new with IOrder....

I've been working with a trailing stop strat that actually moves the trailing stop with a visual marker and now i'm trying to emulate the breakeven feature of ATMs.

hope to be able to share more soon.

kz

Started this thread Reply With Quote
Thanked by:
  #7 (permalink)
 midasman 
lexinton, sc
 
Experience: Intermediate
Platform: ninjatrader
Broker: mirus/zen-fire
Trading: ES
Posts: 5 since Oct 2009
Thanks Given: 4
Thanks Received: 3

Hello, interested in trailing stop in ninja strategy... i have been struggling with it for awhile, is there a way to set a trailing stop that adjusts with an indicator, say parabolicSAR +/- 1 tick on ES. I can't seem to get trailing stop to reset after the first order is executed. Also, you mentioned a visual way to see trailing stop, where or how do you track a trailing stop while order is running? I looked at ninja support/help but just don't get it, not a programmer, just trying to simulate/test my strategy performance.
thanks

Reply With Quote
  #8 (permalink)
 traderwerks   is a Vendor
 
Posts: 692 since Jun 2009
Thanks Given: 436
Thanks Received: 465

IOrder, IExecution, IPosition, OnOrderUpdate

These are all great for advanced risk management. Just work through the examples, and it will get pretty easy.

I have written crazy risk management stuff using the advanced features so there is a lot of flexibility there.

Reply With Quote
  #9 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 477 since Jun 2009
Thanks Given: 1,416
Thanks Received: 404


traderwerks View Post
IOrder, IExecution, IPosition, OnOrderUpdate

These are all great for advanced risk management. Just work through the examples, and it will get pretty easy.

I have written crazy risk management stuff using the advanced features so there is a lot of flexibility there.

Thanks traderwerks

If I remember right, you're a programmer from Chicago??? . I spoke to you about a project last year....

I guess the thing that would eliminate the confusion for me is if a template including all four of these in basic form is available. for example, is the sequence critical? Do I need to use return statements within the different functions? Does OnBarUpdate include only a couple lines with the bulk of the code going in the other I...xyz functions?
thanks for any basic format you could offer.
Kirk

Started this thread Reply With Quote




Last Updated on December 27, 2009


© 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