NexusFi: Find Your Edge


Home Menu

 





Ninjatrader 8: straegy with 2 stop orders help!


Discussion in NinjaTrader

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




 
 

Ninjatrader 8: straegy with 2 stop orders help!

 
 endystrike 
Turin Italy
 
Experience: Master
Platform: MultiCharts, NinjaTrader
Broker: Interactive Brokers + TradeStation
Trading: CL, FDAX, ES, NG, GC, ZS, GF, RB, HO, NQ, FGBL, US, TY
Posts: 8 since Apr 2013
Thanks Given: 2
Thanks Received: 2

Hello everybody!
I coded a sample strategy in NinjaTrader 8 that would be the base for many breakout strategies (changing order type from "stop" to "limit" also for reversals) and I also coded Alert part in this script to receive email for entries and exits...
The sample strategy would be quiet simple to be coded in mc because there's no problem to send more than 1 stop/limit pending order at the same time for entries, while in NinjaTrader it seems that would be required to use "Unmanaged Approach" instead of "Managed Approach" to send more that 1 stop/limit entry order simultaneously... In fact in this code short entry order in most cases is skipped because there's yet a long entry order written before into the script...

Can anyone help me please to transform this code from "Managed Approach" to "Unmanaged Approach"?

The rules of the strategy are quiet simple:
- maximum 1 trade long + 1 trade short a day
- entries: long buy stop on high of yesterday, sell short on low of yesterday during TimeWindow and respecting "dayofweek" and "month to skip" inputs;
- stoploss: the nearest price level between technical stop and max points stop from entryprice (for long I set lowd1 and 100 points, for short highd1 and 100 points);
- breakeven: if Breakeven input>0 set breakeven stop to 150 points;
- Take profit: if takeprofit input>0 set profit to 200 points;

Note1: previous day OHLC levels are calculated when day changes (like in mc if d<>d[1] then begin.... ) from DataSeries[1] (= data2 of MC) as 1440 mins, to take those values from intraday data...
Note2: you can set additional techical filters (like those in PtnbaseSA) changing longcondition, shortcondition, longfalsecondition and shortfalsecondition, there you can set dailyfactor and any other pattern.
Note3: I coded alert part of the script taking parts from NT Guide and from a previous code I created for NinjaTrader 7 that worked fine, but haven't sill tested it in NT8. Anyway different functions between the different versions of NT have been changed in the script.

I coded the script so that for other users would be easy to filter dayofweek and month and set a time windows with pauses, all those parameteres are visible into the input mask and grouped for categories...
In this way, once stop/limit order problem will be solved, other users who want to code using NinjaTrader 8 would have a good sample to start taking confidence with the platform language...

Note4: Another alternative solution would be to convert stop/limit entry orders to market orders when stop/limit price is touched (eg. in MC language "if high>highd1 then buy next bar market" instead of "buy next bar highd1 stop"), but for now I'd prefer to use stop/limit orders and anyway there's the possibility that breakeven orders would give problems too...

Thanks a lot to anyone who would help me!!!

Attached Files
Elite Membership required to download: Sample2EntryOrdersNT8.cs
Started this thread

 



Last Updated on December 9, 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