NexusFi: Find Your Edge


Home Menu

 





Nested Loop


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 478 since Jun 2009
Thanks Given: 1,419
Thanks Received: 404

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.

 
Code
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){
							BoolPush1Up.Set((j+i),true);//
						}
						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){
								BoolPush2Up.Set((j+i),true);//
							}
						}
						if (BoolPush1Up[j+i+1]==true && BoolPush2Up[i+j+0] == true){
							if (BoolPush3Up[j+i+1]){
								BoolPush3Up.Set((j+i),true);
							}
						
						}
					}
				}
				//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.
Kirk


Attached Thumbnails
Click image for larger version

Name:	Nested_Loop_for_identifying_Swing_touches.png
Views:	183
Size:	148.3 KB
ID:	147924  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Bookmap Global Plus Lifetime + Lifetime Addons For Sale
Platforms and Indicators
One Wallet Made $200K in Hours: AP Probes Polymarket Cea …
Prediction Markets & Event Contracts
Saylors 41-Month HODL Breaks: Strategy Sells 32 BTC as $ …
Prediction Markets & Event Contracts
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
Kharg Island at 6%, Regime Fall at 1.5% -- The Black Swa …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,971 since Jun 2009
Thanks Given: 534
Thanks Received: 3,711


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

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

 
Code
counter++;
until the swing high changes, then

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

 
Code
if (counter == 3)
   doStuff();
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).


Follow me on X Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on May 28, 2014


© 2026 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 - Downloads - Top
no new posts