Advanced managed orders ninjascript with intrabar granularity - NinjaTrader Programming | futures io social day trading
futures io futures trading


Advanced managed orders ninjascript with intrabar granularity
Updated: Views / Replies:1,457 / 7
Created: by iPipper427 Attachments:2

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Advanced managed orders ninjascript with intrabar granularity

  #1 (permalink)
Elite Member
Atlanta + GA/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Forex
 
iPipper427's Avatar
 
Posts: 34 since Jul 2012
Thanks: 57 given, 14 received

Advanced managed orders ninjascript with intrabar granularity

I have searched already for a definitive solution to no avail... Help or a point in the right direction appreciated..

I have coded a simple strat that subtracts xpips from the previous close to enter a long..opposite for shorts.

Instrument: EURUSD;
Primary Time Frame: 60min;
Granularity 1min;
Price based on last;

All works well when limit and stop are not in same Primary Time Frame, however when the stop and limit fall within the primary price range it enters and exits same bar irregardless of which should have hit in proper order..

Example:

Open is the high of the bar and close is the low... no price zig zag intrabar just down I am filled on long trade yet profit target is hit same bar...no way could have happened...

Very inaccurate test..

I have browsed futures.io (formerly BMT) and also NT forums...
It appears others have had same issue yet I haven't found a viable solution..
If anyone knows how to work around this with more of an accurate way to BACKTEST Please inform!!!

I am Using OnOrderUpdate() and OnExecution().
It seems this should be a simple thing to do.

Albeit I am a novice programmer

If needed I could post code

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
McKinney, TX
 
Futures Experience: Intermediate
Platform: Think or Swim, NinjaTrade
Favorite Futures: The indexes, ES, YM, NQ & RTY
 
Posts: 152 since Aug 2012
Thanks: 213 given, 125 received



iPipper427 View Post
I have searched already for a definitive solution to no avail... Help or a point in the right direction appreciated..

I am Using OnOrderUpdate() and OnExecution().
It seems this should be a simple thing to do.

Albeit I am a novice programmer

Hi, I'll first start by saying if you're a novice programmer you're taking on a fairly complex set of code. I'm an experienced programmer and have done several of my latest strategies using the OnOrderUpdate/Execution events. If you want to see an example of my use of those events, check out the battle of the bots and do a search for non-image attachments and grab my strategy. Even with the complexities that I've put into my strategy, I still think there are a couple of additional items that I'm missing in my code. For example, when I get an event, I change values of variables that on the next tick update the code of the previous tick update may not have fully executed.

As an alternative use the managed orders. This should simplify your code. Otherwise, hopefully my code will help give you some answers.

Reply With Quote
The following user says Thank You to dynoweb for this post:
 
  #4 (permalink)
Elite Member
Atlanta + GA/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Forex
 
iPipper427's Avatar
 
Posts: 34 since Jul 2012
Thanks: 57 given, 14 received

@dynoweb

Thanks so much for this...

One thing when I loaded it into vs2012 it immediately flagged this

 
Code
// Change short close order to close if stop trigger (closed above channel)
    		if (null != closeOrderShortStop)
			{
				if (closeOrderShort == null
					&& High[0] > channelHigh
					&& barNumberSinceFilled != barNumberSinceFilled
					)


barNumberSinceFilled != barNumberSinceFilled.....is a comparison to the same variable which will always be false

Reply With Quote
 
  #5 (permalink)
Elite Member
Atlanta + GA/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Forex
 
iPipper427's Avatar
 
Posts: 34 since Jul 2012
Thanks: 57 given, 14 received

While perusing your code..
In one of your if statements can't remember which as I changed then later thought to post it..

if(null != someEntryOrder)

I changed to

if(someEntryOrder != null)

Never tested in code the reverse order of the null check...
Not sure if it makes a difference..

Also I am using managed orders not unmanaged...
However am considering using unmanaged as it removes certain limitations.

Will post code and screenshot this evening of my problem..Hard to move forward without knowledge of accurate(as possible) backtesting.

Reply With Quote
 
  #6 (permalink)
Elite Member
Atlanta + GA/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Forex
 
iPipper427's Avatar
 
Posts: 34 since Jul 2012
Thanks: 57 given, 14 received

This is some sample code I put together to demonstrate....What I feel is a known issue...
All I am Looking for is proper way to get accurate test using this simple idea..
A Base workaround if you will for backtesting purposes...ie no Live trading!!!

Primary is 60 min EURUSD;

Screenshot and Code zip;



Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Attached Files
Register to download File Type: zip LongEntryTest.zip (1.7 KB, 22 views)
Reply With Quote
The following 2 users say Thank You to iPipper427 for this post:
 
  #7 (permalink)
Elite Member
McKinney, TX
 
Futures Experience: Intermediate
Platform: Think or Swim, NinjaTrade
Favorite Futures: The indexes, ES, YM, NQ & RTY
 
Posts: 152 since Aug 2012
Thanks: 213 given, 125 received


iPipper427 View Post
While perusing your code..
In one of your if statements can't remember which as I changed then later thought to post it..

if(null != someEntryOrder)

I changed to

if(someEntryOrder != null)

Never tested in code the reverse order of the null check...
Not sure if it makes a difference..

the order doesn't make any difference in this case. In a prior programming language using the null first avoided a null pointer error. It's been so long ago, that I don't remember when it mattered.

Reply With Quote
 
  #8 (permalink)
Elite Member
McKinney, TX
 
Futures Experience: Intermediate
Platform: Think or Swim, NinjaTrade
Favorite Futures: The indexes, ES, YM, NQ & RTY
 
Posts: 152 since Aug 2012
Thanks: 213 given, 125 received


iPipper427 View Post
This is some sample code I put together to demonstrate....What I feel is a known issue...
All I am Looking for is proper way to get accurate test using this simple idea..
A Base workaround if you will for backtesting purposes...ie no Live trading!!!

Primary is 60 min EURUSD;

Screenshot and Code zip;



Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

I haven't spent a lot of time looking at this, but first impressions are that the exits are happening because the stops are 150 which is within the range on the bar they open the position. On back testing data I think the tick price movement within the bar is summarized so it knows it's open, high and low and close, but not when within that bar it was at a particular price. That being the case on back testing, assume the worse, it triggers the long buy on the high price and the short got hit when the price was at the lower portion of the bar. If you use market orders, the approximate entry price on back testing is the bar open price and close price is the open of the next bar. When you add multi-time frame bar data, you need to make sure which bar triggered the on bar update and ignore code based on the other time frame.

Just for fun, extend your longStopLoss to 750 and see how it changes the results.

Reply With Quote
The following user says Thank You to dynoweb for this post:

Reply



futures io > > > > > Advanced managed orders ninjascript with intrabar granularity

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Webinar Sept 28th, 4:30pm Eastern: Advanced Ninjascript Strategy Programming @shodson shodson The Elite Circle 68 October 1st, 2017 08:05 PM
Unmanaged vs Managed orders Xeno NinjaTrader Programming 34 March 6th, 2015 01:30 PM
Looking for a managed account freddy250 Currency Futures 1 March 16th, 2013 11:08 AM
Managed vs Unmanaged approach Merlin997 NinjaTrader Programming 3 October 21st, 2011 06:32 AM


All times are GMT -4. The time now is 01:42 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-16 in 0.12 seconds with 20 queries on phoenix via your IP 23.22.136.56