Question going by tick - NinjaTrader Programming | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming

Question going by tick
Started:February 26th, 2010 (01:11 PM) by jeffbg123 Views / Replies:951 / 2
Last Reply:March 5th, 2010 (06:05 PM) Attachments:0

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • 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, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

Question going by tick

Old February 26th, 2010, 01:11 PM   #1 (permalink)
Elite Member
Futures Experience: Advanced
Platform: Other
Posts: 35 since Feb 2010
Thanks: 3 given, 1 received

Question going by tick

I am new to NinjaTrader but know C# and need some advice.

I want to run a strategy that relies on the previous 2 5000 tick bars. However I don't really want to do it by bar, I want to have a moving window of the last 5000 ticks and the 5000-10000th ticks. So what I was doing is just keeping a list of my own of these ticks.

public class scalper : Strategy
List<double> barFar = new List<double>();
List<double> barNear = new List<double>();

protected override void Initialize()
            CalculateOnBarClose = false;
            EntryHandling        = EntryHandling.UniqueEntries;

protected override void OnBarUpdate()
double curPrice = Close[0];
            while(barNear.Count > ticksTimeFrame)
            while(barFar.Count > ticksTimeFrame)
            List<double> barFarCopy = new List<double>(barFar);
            List<double> barNearCopy = new List<double>(barNear);
            if(barFar.Count == ticksTimeFrame && barNear.Count == ticksTimeFrame)
                double barNearMid = Math.Min(barNearCopy[0], barNearCopy[barNearCopy.Count - 1]) + Math.Abs(barNearCopy[0] - barNearCopy[barNearCopy.Count - 1]);

                double barFarMid = Math.Min(barFarCopy[0], barFarCopy[barFarCopy.Count - 1]) + Math.Abs(barFarCopy[0] - barFarCopy[barFarCopy.Count - 1]);
Will this just keep the last 2 windows of ticks and find their middle price?


Reply With Quote

Old February 26th, 2010, 01:11 PM   #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.


Old March 5th, 2010, 06:05 PM   #3 (permalink)
Trading for Fun
Dallas TX/USA
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: AMP/CQG
Favorite Futures: ES
Posts: 154 since Jun 2009
Thanks: 33 given, 279 received

jeffbg123 View Post
Will this just keep the last 2 windows of ticks and find their middle price?

well you generally don't need to copy and then sort 10k-sized lists on every tick when all you want is the average of their largest and smallest values. As a first step you can just scan the list and locate the high and low in O(n) time. If you'd like to do better than that, I've written up an algorithm for maintaining a sorted sliding window with expected O(n/2) performance, which is article #5 on this page: Move the Markets| Articles.

I guess I wasn't totally clear on if you wanted the median, or the midpoint. Assuming the latter, then you'd want (H+L)/2... but as far as I can tell your code doesn't do that. It seems to be calculating Min(L, L + Abs(L - H))... which would always evaluate to L.

Hope this helps.

Reply With Quote

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming > Question going by tick

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
CL question about how much per tick skyfly Traders Hideout 3 April 16th, 2011 03:10 AM
trying to make a chartinig program that goes through data tick by tick acdrew0 Platforms and Indicators 11 January 27th, 2011 12:55 PM
Tick charts question martifc Traders Hideout 3 January 21st, 2011 11:43 AM
Intrabarpersist and Historical tick data Question marketstudent EasyLanguage Programming 2 August 13th, 2010 02:07 PM
historical tick by tick market for many European mea109 Traders Hideout 2 December 7th, 2009 10:00 AM

All times are GMT -4. The time now is 04:21 PM.

Copyright © 2016 by 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 2016-10-23 in 0.09 seconds with 20 queries on phoenix via your IP