Nested Loop - NinjaTrader Programming | futures trading

Go Back

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

Nested Loop
Started:May 28th, 2014 (03:55 PM) by zeller4 Views / Replies:298 / 2
Last Reply:May 28th, 2014 (04:15 PM) Attachments:1

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

Nested Loop

Old May 28th, 2014, 03:55 PM   #1 (permalink)
Elite Member
Futures Experience: Intermediate
Platform: NT7
Favorite Futures: CL, NQ, NG
Posts: 449 since Jun 2009
Thanks: 1,342 given, 376 received

Nested Loop

Hello All,

I'm trying to identify some line touches that don't always occur simultaneously.

The attached screenshot shows three touches on the Swing indicator.
I've attempted to use a nested for loop with BoolSeries but I'm not sure I'm doing the indexing correctly to identify which bar touched and then how to proceed to touch#2 and touch #3. Also, not sure if making them false within the loops is correct or only when the SwingDots shift.
Also, if there's some obvious ways to do the BackColorSeries[i] or [0] better , I'd appreciate your thoughts.

for (int i = 0; i <= 2; i++){
				double high = High[i];
				if(high == SwingHighPlot[i]){
					for (int j = 0; j <= 5; j++){
						if (BoolPush1Up[j+i+1]==false){
						if (BoolPush1Up[j+i+1]) BoolPush1Up.Set((j+i),true);
						if (BoolPush1Up[j+i+1]==true){// && BoolPush2Up[i+j+0] == false){
							if (BoolPush2Up[j+i+1] == false){
						if (BoolPush1Up[j+i+1]==true && BoolPush2Up[i+j+0] == true){
							if (BoolPush3Up[j+i+1]){
				//else BoolPush1Up.Set(i,false);
				if (BoolPush1Up[0]) BackColorSeries[0]=Color.Yellow;
				if (BoolPush2Up[0]) BackColorSeries[0]=Color.Green;
				if (BoolPush3Up[0]) BackColorSeries[0]=Color.Red;
Hope this makes sense. Thanks in advance for any help you can offer.

Attached Thumbnails
Nested Loop-nested_loop_for_identifying_swing_touches.png  

Last edited by zeller4; May 28th, 2014 at 04:11 PM.
Reply With Quote

Old May 28th, 2014, 03:55 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 May 28th, 2014, 04:15 PM   #3 (permalink)
OC, California, USA
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
shodson's Avatar
Posts: 1,827 since Jun 2009
Thanks: 470 given, 3,155 received

I'm not sure if what you're doing will work or not. I'd approach it more simply: just use a

int counter = 0;
and ever time a top is touched

until the swing high changes, then

counter = 0;
Otherwise, while the swing high has not changed, and

if (counter == 3)
then do whatever it is you plan to do on the 3rd touch.

Seems simpler, and will perform better too (no extra series collections to maintain and traverse on every bar).

Reply With Quote
The following 3 users say Thank You to shodson for this post:

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming > Nested Loop

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
Rationality And Trading Found In Nested Knot ratfink Psychology and Money Management 1 March 18th, 2014 03:43 AM
Conditional Nested Boolean Statements serac NinjaTrader Programming 4 November 27th, 2011 06:44 PM
OODA Loop and Trading...... tradersam Psychology and Money Management 1 May 18th, 2011 02:36 PM
foreach loop problem gomad NinjaTrader Programming 14 May 17th, 2011 07:40 PM
Complete noob programming MTF and nested indicator nirajkrishna Traders Hideout 2 March 26th, 2011 07:17 AM

All times are GMT -4. The time now is 03:52 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-22 in 0.09 seconds with 20 queries on phoenix via your IP