NexusFi: Find Your Edge


Home Menu

 





PriceActionSwing discussion


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Silvester17 with 177 posts (570 thanks)
    2. looks_two dorschden with 99 posts (1,124 thanks)
    3. looks_3 Big Mike with 52 posts (90 thanks)
    4. looks_4 jmont1 with 51 posts (23 thanks)
      Best Posters
    1. looks_one dorschden with 11.4 thanks per post
    2. looks_two Silvester17 with 3.2 thanks per post
    3. looks_3 Big Mike with 1.7 thanks per post
    4. looks_4 sudhirc with 1.7 thanks per post
    1. trending_up 975,541 views
    2. thumb_up 2,947 thanks given
    3. group 613 followers
    1. forum 2,093 posts
    2. attach_file 615 attachments




 
Search this Thread

PriceActionSwing discussion

  #281 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047


dorschden View Post
Pepperdog,

you have to add this lines in your strategy

 
Code
#region Using declarations
...
using PriceActionSwing.Utility;
#endregion 

#region Variables
...
private SwingMode pAS_SwingMode = SwingMode.Standard; 
private int pAS_DtbStrength = 15; 
private int pAS_Span = 8; 
#endregion

protected override void Initialize()
{
   …
   // Add the indicator to the chart - not necessary
   Add(PriceActionSwing(pAS_SwingMode, pAS_DtbStrength, pAS_Span));
}

protected override void OnBarUpdate()
{
   …
   // If the last high and  low was higher high and higher low and a short sma cross above the long sma enter long
   if (PriceActionSwing(pAS_SwingMode, pAS_DtbStrength, pAS_Span).PriceSwingRelation[0] == 1 && CrossAbove(SMA(3), SMA(7), 1))
   (
      EnterLong(DefaultQuantity, "");
   )
   ...
}

#region Properties
[Category("Parameters")]
public SwingMode PAS_SwingMode
{
   get { return pAS_SwingMode; }
   set { pAS_SwingMode = value; }
}

[Category("Parameters")]
public int PAS_DtbStrength
{
   get { return pAS_DtbStrength; }
   set { pAS_DtbStrength = Math.Max(1, value); }
}

[Category("Parameters")]
public int PAS_Span
{
   get { return pAS_Span; }
   set { pAS_Span = Math.Max(1, value); }
}
#endregion
For the 1 in "PriceSwingRelation[0] == 1" you can set the following values
-2 for double top
-1 for lower high and lower low
0 nothing
1 for higher high and higher low
2 for double bottom

Hope this helps.


Howdy.

I am trying to reference some things in your study. Basically just the swing relation, i.e. price making a HH and HL or LL and LH.

When I try to add this code snippet here, I get an error shown in the picture. I don't know if something has changed, but I am using the latest version from the download section. Is this still the proper code snippet to insert into my indicator?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
Exit Strategy
NinjaTrader
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
26 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #282 (permalink)
 dorschden 
Germany
 
Experience: Master
Platform: NinjaTrader
Posts: 112 since Jun 2009
Thanks Given: 59
Thanks Received: 1,143

You have to replace in your post in the bold line the "PriceSwingRelation" with "SwingRelation" and then it should work. You can also take a look in the PriceActionSwingTrend indicator as an example how to access the swing relation values.
 
Code
                            
// HH and HL

if (PriceActionSwing(pAS_DtbStrengthpAS_SpanpAS_SwingMode).SwingRelation[0] == 1)
// if (PriceActionSwing(15, 7, SwingTypes.Standard).SwingRelation[0] == 1)
{
  
// Do something


Started this thread Reply With Quote
Thanked by:
  #283 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047



dorschden View Post
You have to replace in your post in the bold line the "PriceSwingRelation" with "SwingRelation" and then it should work. You can also take a look in the PriceActionSwingTrend indicator as an example how to access the swing relation values.
 
Code
                            
// HH and HL
if (PriceActionSwing(pAS_SwingModepAS_DtbStrengthpAS_Span).SwingRelation[0] == 1)
{
  
// Do something


I just couldn't seem to get that to work no matter what I tried. I kept getting an error having to do with the 'swingmode.'

So I just copied that entire "PriceActionSwingTrend" and I will start from there by modifying that.

But can you tell me which data series, or variable I would need to use just to know when a HH/HL or LL/LH is being made?

Just basically,

 
Code
if (price makes a HH/HL)
{
    Do this
}


-----EDIT---------
Looks like "swingRelation" is what I need.

Reply With Quote
Thanked by:
  #284 (permalink)
 dorschden 
Germany
 
Experience: Master
Platform: NinjaTrader
Posts: 112 since Jun 2009
Thanks Given: 59
Thanks Received: 1,143


forrestang View Post
I just couldn't seem to get that to work no matter what I tried. I kept getting an error having to do with the 'swingmode.'

The parameters were interchanged. Try the edited code above.
And in the "using" region in the top of your indicator/strategy you have to add "using PriceActionSwing.Utility;".
Check for the SwingRelation value.
SwingRelation[0] == 1 is equal to HH/HL
SwingRelation[0] == -1 is equal to LL/LH

Started this thread Reply With Quote
Thanked by:
  #285 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047


dorschden View Post
The parameters were interchanged. Try the edited code above.
And in the "using" region in the top of your indicator/strategy you have to add "using PriceActionSwing.Utility;".
Check for the SwingRelation value.
SwingRelation[0] == 1 is equal to HH/HL
SwingRelation[0] == -1 is equal to LL/LH

Thanks..... I just edited my post above that I found that swingRelation dataseries.

Just plotting arrows to confirm it is doing what I want(on a HH/HL).

Attached Thumbnails
Click image for larger version

Name:	testing.jpg
Views:	665
Size:	224.7 KB
ID:	43540  
Reply With Quote
  #286 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047

@dorschden

I had everything working mostly the way I wanted it to. And this was mainly by taking the "PriceActionSwingTrend" indie, and deleting most of it, then adding in the things I needed. It worked fine.

Then I reloaded everything, then all of a sudden I get errors and the chart won't load. It is an error pertaining to not initializing, or checking for a null reference. I have been at it for a while and cannot seem to figure it out. I am wondering if you had run into a similar problem with the indicator before?

The error is pertaining to THIS i believe?

Running several iterations, commenting out various lines of code, I get the errors shown in the picture (there are only 3, but I've run it many times trying to figure out what was wrong).

Here is a code snippet. You don't have to comb over it entirely, but if you've seen this before, is there something OBVIOUSLY wrong that jumps out at you in the 'Initialize()' or 'OnBarUpdate()" blocks?

 
Code
//#region Variables
        //#####################################################################
        //Variables for PriceActionSwing
	private int swingSize = 2;
        private SwingTypes swingType = SwingTypes.Standard;
        private int dtbStrength = 15;
        private IDataSeries swingRelation;
        private IDataSeries swingTrend;
        private bool seeRelation = false;
        private bool useOldTrend = true;
        private bool paintBars = true;
        private int oldTrend = 0;
        private Color upTrendColour = Color.Green;
        private Color dnTrendColour = Color.Red;
        private Color noTrendColour = Color.Gray;
		
	//Variables for IchiCloud
	private int periodFast = 9;			// Default setting for PeriodFast
        private int periodMedium = 26;		// Default setting for PeriodMedium
        private int periodSlow = 52;		// Default setting for PeriodSlow
		
	//Variables independant to FPCJTrend
	private bool blueCloud = false;
	private bool redCloud = false;
	private int ichiBuffer = 6;
		
        //#####################################################################
        //#endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
            
	    //Add(new Plot(new Pen(Color.Firebrick, 20), PlotStyle.Square, "DoubleTop"));
            Add(new Plot(new Pen(Color.Red, 20), PlotStyle.Square, "DownTrend"));
            Add(new Plot(new Pen(Color.Gold, 20), PlotStyle.Square, "NoWhere"));
            Add(new Plot(new Pen(Color.Green, 20), PlotStyle.Square, "UpTrend"));
            //Add(new Plot(new Pen(Color.Lime, 20), PlotStyle.Square, "DoubleBottom"));
			
            CalculateOnBarClose = true;
            Overlay				= true;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {	
			
			
		if (CurrentBar < swingSize)		
                        return;							//Do we have enough bars for PriceActionSwing
			
		if ((CurrentBar < periodMedium) || (CurrentBar < periodFast))
			return;							// Do we have enough bars for Ichi Calculation
			

		if (CurrentBar < 1)
               {
                     if (swingRelation == null && seeRelation)
                              swingRelation = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingRelation;
                     if (swingTrend == null && !seeRelation)
                              swingTrend = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingTrend;
                }
			
		double spanA = IchiCloud(Input, periodFast, periodMedium, periodSlow).SenkouSpanA[0];
		double spanB = IchiCloud(Input, periodFast, periodMedium, periodSlow).SenkouSpanB[0];
						
		if(spanA > spanB)
			{
				blueCloud = true;	
				redCloud = false;
			}
			
		if(spanA < spanB)
			{
				redCloud = true;
				blueCloud = false;
			}
			
		if(redCloud == true)
			{
				DrawArrowDown("arrow"+CurrentBar, true, 0, Low[0]+12*TickSize, Color.Red);	
			}
			
			
			///*
                if (swingTrend[0] == 1 && blueCloud == true && Low[0] > spanA-ichiBuffer*TickSize)
			{
				UpTrend.Set(1);
				//DrawArrowUp("arrow"+CurrentBar, true, 0, Low[0]-12*TickSize, Color.Green);
				//Print("hi");
			}
            
		else if (swingTrend[0] == -1 && redCloud == true && High[0] < spanA+ ichiBuffer*TickSize)
			{
				DownTrend.Set(1);
				//DrawArrowDown("arrow"+CurrentBar, true, 0, Low[0]+12*TickSize, Color.Red);
			}
			
		else
			{
				NoWhere.Set(1);	
			}

Attached Thumbnails
Click image for larger version

Name:	Prime2011-07-16_225051.jpg
Views:	255
Size:	472.9 KB
ID:	43555  
Reply With Quote
  #287 (permalink)
 ticnau 
Buderim Queensland Australia
 
Experience: Advanced
Platform: ninja
Broker: AMP/Zenfire
Trading: 6E, 6B, YM
Posts: 89 since Jul 2009
Thanks Given: 121
Thanks Received: 25


forrestang View Post
Thanks..... I just edited my post above that I found that swingRelation dataseries.

Just plotting arrows to confirm it is doing what I want(on a HH/HL).


Where can i find the trend indicator on the bottom of your chart??

Thanks a million

Reply With Quote
  #288 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047


ticnau View Post
Where can i find the trend indicator on the bottom of your chart??

Thanks a million



I'm not sure what you mean? Are you referring to the one called "PriceActionTrend?" That's in the download section, created by the OP of this post. In there, are two studies. One is called "PriceActionSwing" and the other is called "PriceActionSwingTrend."

If you are referring to the indie at the VERY bottom, that's my indicator I'm working on and at the momement isn't working.

Reply With Quote
Thanked by:
  #289 (permalink)
 futuretrader 
Como Italy
 
Experience: Intermediate
Platform: Ninjatrader, customized
Trading: ES
Posts: 525 since Feb 2010
Thanks Given: 471
Thanks Received: 643

Looks like the "if CurrentBar < 1 " section should come first. otherwise swingTrend and swingRelation have no value set.

We're working along similar lines....

Reply With Quote
  #290 (permalink)
 
forrestang's Avatar
 forrestang 
Chicago IL
 
Experience: None
Platform: Ninja, MT4, Matlab
Broker: CQG, AMP, MB, DTN
Trading: E/U, G/U
Posts: 1,329 since Jun 2010
Thanks Given: 354
Thanks Received: 1,047



futuretrader View Post
Looks like the "if CurrentBar < 1 " section should come first. otherwise swingTrend and swingRelation have no value set.

We're working along similar lines....

I dunno....... I actually have that first the way my script sits now. I still get the same error.



-----EDIT------
I commented out the first portion in void onBarUpdate. See this code snippet and my indie is now working. I'm not sure what those where there for, but they must have a purpose I am failing to understand.
 
Code
if (CurrentBar < 1)
       {
              //if (swingRelation == null && seeRelation)
               swingRelation = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingRelation;
				
              //if (swingTrend == null && !seeRelation)
              swingTrend = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingTrend;
       }

Reply With Quote




Last Updated on January 7, 2024


© 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