NexusFi: Find Your Edge


Home Menu

 





Highest or lowest swings


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
luitom
Firenze, Italy
 
Posts: 4 since Mar 2011
Thanks Given: 0
Thanks Received: 0

I am trying to write a code that will able to find the lowest of the last X swing lows and the highest of the X swing lows by using the Swing indicator in Ninjatrader.

This is how I did it

MIN(Swing(BarsArray[1], 1).SwingLow, X)[0];

MAX(Swing(BarsArray[1], 1).SwingHigh, X)[0];

For some reason it does seem to be working. My impression is these functions find the highest swing high of the the last X days and not the highest of the last X swing highs (which may be useful too but it is not what I am looking for).

I have been told that I need to use ArrayLists but I have not idea how to go about it; it goes beyond my programming skills and I found nothing on Ninjascript. Can anybody help please?


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Topstep Acquires The Futures Desk -- Prop Firm Consolida …
Funded Trading Evaluation Firms
CME Lists U.S. Election Event Contracts as 2028 Democrat …
Prediction Markets & Event Contracts
Asia Equities Crash Overnight -- Nikkei -5.2%, KOSPI -6. …
Traders Hideout
Peace Deal Forward Curve: May 22%, June 51%, December 81 …
Prediction Markets & Event Contracts
The Feds Stagflation Trap -- Negative Payrolls, $91 Oil, …
Traders Hideout
 
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
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Legendary Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,951 since Dec 2010
Thanks Given: 3,042
Thanks Received: 2,397



luitom View Post
I am trying to write a code that will able to find the lowest of the last X swing lows and the highest of the X swing lows by using the Swing indicator in Ninjatrader.

This is how I did it

MIN(Swing(BarsArray[1], 1).SwingLow, X)[0];

MAX(Swing(BarsArray[1], 1).SwingHigh, X)[0];

For some reason it does seem to be working. My impression is these functions find the highest swing high of the the last X days and not the highest of the last X swing highs (which may be useful too but it is not what I am looking for).

I have been told that I need to use ArrayLists but I have not idea how to go about it; it goes beyond my programming skills and I found nothing on Ninjascript. Can anybody help please?

Hi,

My quick impression, if the approach is valid (didn't spend the time), is the problem might be the BarsArray[1]. Try BarsArray[0] here to see if it does what you expect. I think you need to have a multi-series strategy/indicator to us [1].

Hope that helps.


Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: [wiki=NT-Local-Order-Manager-LOM-Guide][/wiki]
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
luitom
Firenze, Italy
 
Posts: 4 since Mar 2011
Thanks Given: 0
Thanks Received: 0

Sorry I did not explain why I have BarsArray[1] in the indicator. The reason is just that I am working on multi time frame and I created a BarsArray of daily bars in Initialize section

Add(PeriodType.Day,1);

That has nothing to do with what I am looking for; the code could easily be

MIN(Swing(1).SwingLow, X)[0];

MAX(Swing(1).SwingHigh, X)[0];


Sorry about the confusion




Reply With Quote
  #5 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Legendary Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,951 since Dec 2010
Thanks Given: 3,042
Thanks Received: 2,397

Okay,

I think Swing might have "missing values". I don't know if MIN/MAX ignore these values. YOu might need to scan the array yourself with a for/next loop and ignore missing values.


Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: [wiki=NT-Local-Order-Manager-LOM-Guide][/wiki]
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Reply With Quote




Last Updated on January 27, 2012


© 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