NexusFi: Find Your Edge


Home Menu

 





Highest or lowest swings


Discussion in NinjaTrader

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




 
Search this Thread

Highest or lowest swings

  #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?
MC PL editor upgrade
MultiCharts
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Quant vue
Trading Reviews and Vendors
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #3 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,395



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: NT-Local-Order-Manager-LOM-Guide
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
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,395

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: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Reply With Quote




Last Updated on January 27, 2012


© 2024 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 - Privacy Policy - Downloads - Top
no new posts