NexusFi: Find Your Edge


Home Menu

 





SwingRay2 for strategy


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one EDGE with 12 posts (9 thanks)
    2. looks_two BankRobberNT with 12 posts (3 thanks)
    3. looks_3 Eubie with 10 posts (11 thanks)
    4. looks_4 Trader.Jon with 2 posts (0 thanks)
      Best Posters
    1. looks_one pam421 with 4 thanks per post
    2. looks_two DarrenH with 1.5 thanks per post
    3. looks_3 Eubie with 1.1 thanks per post
    4. looks_4 EDGE with 0.8 thanks per post
    1. trending_up 15,626 views
    2. thumb_up 34 thanks given
    3. group 18 followers
    1. forum 40 posts
    2. attach_file 8 attachments




 
Search this Thread

SwingRay2 for strategy

  #1 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184

Ryanb posted a version of the SwingRay indicator recently:

He hasnt been able to offer a solution to my question.

I am looking at the the code to access the values of the swings so that if Close[1] > SwingRayHiValue[1] == try to go long etc. Nothing is displayed in the DataBox: can someone please take a look at the code to see what can be exposed for that strategy input? There are already DataSeries that are 'public' but they dont show in the DataBox.

 
Code
  protected override void Initialize()
        {
            DisplayInDataBox 	= false;
            CalculateOnBarClose	= true;
            Overlay				= true;
            PriceTypeSupported	= false;
			
			lastHighCache = new ArrayList();  // used to identify swing points; from default Swing indicator
			lastLowCache = new ArrayList();
			swingHighRays = new Stack();   // LIFO buffer; last entry contains the nearest swing high
			swingLowRays = new Stack();
        }
I tried moving the arraycode from the Initialize to the OnBarUpdate but that didnt help.

Assist is very apprecaited,
Jon

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Deepmoney LLM
Elite Quantitative GenAI/LLM
Futures True Range Report
The Elite Circle
Exit Strategy
NinjaTrader
NexusFi Journal Challenge - April 2024
Feedback and Announcements
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
Battlestations: Show us your trading desks!
26 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
The Program
18 thanks
  #3 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


Did you try with making lastSwingLowValue and lastSwingHighValue public ?

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184


sam028 View Post
Did you try with making lastSwingLowValue and lastSwingHighValue public ?

sam,

Not yet ... but I will ... but I am guessing that it will only expose the very last hi and lo in the array, not all the values being drawn on the chart?! hhhmmmm ... guess that means I will have to try MRO(whatever I need to do here)etc; .. this will be interesting!


Thanks,
Jon

Started this thread Reply With Quote
  #5 (permalink)
 pam421 
Florida
 
Experience: Intermediate
Platform: Ninjatrader
Posts: 12 since May 2010
Thanks Given: 34
Thanks Received: 12

Jon,

I just downloaded and installed the indicator you referenced.

There are no DataSeries definitions in the indicator. Thus none can display in the DataBox.

And the only places in the SwingRay2 indicator where it says "DataSeries" are not definitions of a DataSeries, they are properties that referencesthe Values array of DataSeries that NinjaTrader provides. The indicator also has no code to set values into these DataSeries either as Values[0], Values[1], etc. or by using the property names (HighRay, LowRay, etc.) Usually properties of this sort are accompanied by Add statements in the Initialize method (for example, see below.)

In an indicator I wrote recently, I found that the only things I could get to display in the NinjaTrader DataBox were dataseries values in dataseries that were added in the Initialize method. Apparently it's not enough for a DataSeries to just be public ... they have to be Add'ed too.

Something like this...

 
Code
protected override void Initialize()
{
   Add(new Plot( new Pen( Color.White), "HighRay" ));
}
I colored them white so they wouldn't mess up the scaling of other dataseries which I wanted to display (making them Transparent seemed to prevent display in the DataBox.)

I also found that if more than 10 dataseries were added in Initialize, only the first 10 would display in the DataBox.

A better place for the array initialization code would probably be in OnStartUp() but it won't help the issue of displaying in the DataBox.

If you want to display in the DataBox, I think you're going to have to "Add" a dataseries and then populate it for each bar so when you mouse-over a bar, you can see the values you set into the Added dataseries in the DataBox. In the indicator I made last week, I added 10 dataseries Add statements to its Initialize method and then filled in values from OnBarUpdate - for debugging purposes.

Good Luck.

Reply With Quote
Thanked by:
  #6 (permalink)
 BankRobberNT 
NYC
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Interactive Brokers
Trading: forex
Posts: 38 since Aug 2011

Best way to use swing rays is to modify the code as a function in your strategy.
In my strategy for example, the code has been completely rewritten and at any given time i have all the swing highs and lows for 28 forex currency pairs!!!

Reply With Quote
  #7 (permalink)
 Taddypole 
Phoenix, Arizona
 
Experience: Advanced
Platform: Ninja Trader
Trading: Oil
Posts: 54 since Jul 2009
Thanks Given: 1
Thanks Received: 7

I use the SwingRay indicator and would like to do a project using it. I would like to create dymanic trendlines connecting the previous high/lows of an indicator (like Macd) with those of price. The other thought is to have the slope displayed on each trendline (one for price and one for the indicator). This would give a constant update of potential divergences.

Any sharing of previous work would be appreciated. Of course I would share the code during and on completion of any progress/solutions I come up with.

regards,
taddypole...

Reply With Quote
  #8 (permalink)
 BankRobberNT 
NYC
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Interactive Brokers
Trading: forex
Posts: 38 since Aug 2011


Taddypole View Post
I use the SwingRay indicator and would like to do a project using it. I would like to create dymanic trendlines connecting the previous high/lows of an indicator (like Macd) with those of price. The other thought is to have the slope displayed on each trendline (one for price and one for the indicator). This would give a constant update of potential divergences.

Any sharing of previous work would be appreciated. Of course I would share the code during and on completion of any progress/solutions I come up with.

regards,
taddypole...

If you are referring to my post, the code has been already shared in form of the indicator. If you want to work on a new project you gotta be able to extract, and modify that simple code for your needs. I don't see how could mine completely rewritten code help you, which is btw far more complex and advanced, written in special way and much harder to understand.

Reply With Quote
  #9 (permalink)
 
DarrenH's Avatar
 DarrenH 
Cotswolds UK
 
Experience: Intermediate
Platform: NT7, Multicharts
Broker: Mirus,Amp,ZenFire
Trading: Fdax
Posts: 64 since Mar 2010
Thanks Given: 95
Thanks Received: 23

Hi Jon

Just wondered if you got it figured out, i would like to also use the LastSwingHighValue as a target.

ProfitTarget1 == SwingRay().LastSwingHighValue

I changed these 2 lines from private to public.
public double lastSwingHighValue = double.MaxValue;
public double lastSwingLowValue = double.MinValue;

If anybody has any ideas, programming newbie!
Thanks



Trader.Jon View Post
Ryanb posted a version of the SwingRay indicator recently:

He hasnt been able to offer a solution to my question.

I am looking at the the code to access the values of the swings so that if Close[1] > SwingRayHiValue[1] == try to go long etc. Nothing is displayed in the DataBox: can someone please take a look at the code to see what can be exposed for that strategy input? There are already DataSeries that are 'public' but they dont show in the DataBox.

 
Code
  protected override void Initialize()
        {
            DisplayInDataBox     = false;
            CalculateOnBarClose    = true;
            Overlay                = true;
            PriceTypeSupported    = false;
 
            lastHighCache = new ArrayList();  // used to identify swing points; from default Swing indicator
            lastLowCache = new ArrayList();
            swingHighRays = new Stack();   // LIFO buffer; last entry contains the nearest swing high
            swingLowRays = new Stack();
        }
I tried moving the arraycode from the Initialize to the OnBarUpdate but that didnt help.

Assist is very apprecaited,
Jon


Reply With Quote
Thanked by:
  #10 (permalink)
 Eubie 
Prague, Czech republic
 
Experience: Beginner
Platform: NinjaTrader/ZF
Trading: ES, TF
Posts: 133 since Jul 2010
Thanks Given: 273
Thanks Received: 81


Hello guys,

I noticed a little glitch in SwingRays and as ryanb has been off the forum for some months, I decided to write here. Im including a screenshot of what happens sometimes. Does anybody have any hints on how to fix this?

The issue is that sometimes, when a swingray is broken, it is displayed still as unbroken. An example of a such a swingray is included.

Any helps is appreciated,
Daniel

Attached Thumbnails
Click image for larger version

Name:	SwingRaysProblem.PNG
Views:	549
Size:	26.7 KB
ID:	66430  
Reply With Quote




Last Updated on February 1, 2022


© 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