NexusFi: Find Your Edge


Home Menu

 





Highest or lowest swings


Discussion in NinjaTrader

Updated
    1. trending_up 3,600 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?
Datafeed for Atas
Platforms and Indicators
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Ninjatrader users - good CONNECTIONs post and article fr …
NinjaTrader
Czechia Live at 52.5% as England Rides 4-2 Wave to Co-Fa …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Want your NinjaTrader indicator created, free?
5 thanks
Afternoon-close session
1 thanks
Franks Trading Journey
1 thanks
Denied 20K payouts: Alpha Futures
1 thanks
FootPrintV2 Chart for NT8
1 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,959 since Dec 2010
Thanks Given: 3,053
Thanks Received: 2,412



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,959 since Dec 2010
Thanks Given: 3,053
Thanks Received: 2,412

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