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,125 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 978,878 views
    2. thumb_up 2,948 thanks given
    3. group 613 followers
    1. forum 2,093 posts
    2. attach_file 615 attachments




 
Search this Thread

PriceActionSwing discussion

  #311 (permalink)
 marcelo_s 
BUENOS AIRES
 
Experience: Intermediate
Platform: ninja
Broker: AMP
Trading: ES
Posts: 34 since Nov 2009
Thanks Given: 0
Thanks Received: 13

Tks. Will work on this and send you feedback
Marcelo




forrestang View Post
Here you go!

I created pretty much a blank template that pulls the variables from Dorsch's Indicator. The two main one's I'm sure you need are there. You just need to add your logic which can just be 'IF' statements etc. The user inputs are coded for you already so that when you add it to a chart, you can manipulate the settings you want for the "PriceActionSwing" indicator itself. The picture should cover most of the explanation you need.

You can see the debug line in the code(green box in attached pic). This is how you can test to be sure it does what you want. For example, replace the "1" with a "-1" and you should see it will draw those arrows when the Trend is DOWN according to the "PriceActionSwing" indicator. If you replace "swingTrend" with "swingRelation" you will see it will draw the arrows only when price makes a HH/HL combination.

I'd suggest you add the "PriceActionSwing" indicator as well to your chart (with the same settings) while you test it to verify your logic is what you want. Play with it you will understand.

Only thing is that I made this as an indicator. You can get your logic straight here. Then once you do that, just turn it into a strategy, and put in the lggic for entering and exiting trades.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #312 (permalink)
 marcelo_s 
BUENOS AIRES
 
Experience: Intermediate
Platform: ninja
Broker: AMP
Trading: ES
Posts: 34 since Nov 2009
Thanks Given: 0
Thanks Received: 13


marcelo_s View Post
Tks. Will work on this and send you feedback
Marcelo

Hi, could not converted to Strategy. I attached the file so you can see. On Log Tab the error " Reference to an object ..... "
Tks for more help

Marcelo

Attached Files
Elite Membership required to download: SwingTrendX.cs
Reply With Quote
  #313 (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


I'm not on a PC that has NT on it at the moment.

What did you do exactly to change it to a strategy?

Reply With Quote
  #314 (permalink)
 marcelo_s 
BUENOS AIRES
 
Experience: Intermediate
Platform: ninja
Broker: AMP
Trading: ES
Posts: 34 since Nov 2009
Thanks Given: 0
Thanks Received: 13


forrestang View Post
I'm not on a PC that has NT on it at the moment.

What did you do exactly to change it to a strategy?

1- Added on Using Declaration using PriceActionSwing.Utility;
2- Added on Variables
private int swingSize = 2;
private SwingTypes swingType = SwingTypes.Standard;
private int dtbStrength = 15;
private IDataSeries swingRelation = null; //HH/HL or LL/LH
private IDataSeries swingTrend = null; //Trend defined by DTs/DBs too

//variables below not needed, let in for completeness
private bool seeRelation = false;
private bool useOldTrend = true;
private bool paintBars = true;
private int oldTrend = 0;
3- Added Conditions


protected override void OnBarUpdate()
{

if (CurrentBar < 1)
{
if (swingRelation == null)
swingRelation = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingRelation;

if (swingTrend == null)
swingTrend = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingTrend;
}

4- Added on Propierties the Parameters

#region Parameters
//=====================================================================
/// <summary>
/// Represents the swing size. e.g. 1 = small swings and 5 = bigger swings.
/// </summary>
#if NT7
[GridCategory("Parameters")]
#else
[Category("Parameters")]
#endif
[Description("Represents the swing size. e.g. 1 = small swings and 5 = bigger swings.")]
[Gui.Design.DisplayName("2.Swing size")]
public int SwingSize
{
get { return swingSize; }
set { swingSize = Math.Max(1, value); }
}
/// <summary>
/// Represents the swing type. Standard | Gann
/// </summary>
#if NT7
[GridCategory("Parameters")]
#else
[Category("Parameters")]
#endif
[Description("Represents the swing type. Standard | Gann")]
[Gui.Design.DisplayName("3.Swing type")]
public SwingTypes SwingType
{
get { return swingType; }
set { swingType = value; }
}
/// <summary>
/// Represents the double top/-bottom strength.
/// </summary>
#if NT7
[GridCategory("Parameters")]
#else
[Category("Parameters")]
#endif
[Description("Represents the double top/-bottom strength. Increase the value to get more DB/DT.")]
[Gui.Design.DisplayName("1.Double top/-bottom strength")]
public int DtbStrength
{
get { return dtbStrength; }
set { dtbStrength = Math.Max(1, value); }
}
[Category("Visualize")]
[Description("Indicates if the trend direction is shown or the swing relation.")]
[Gui.Design.DisplayNameAttribute("See swing relation")]
public bool SeeRelation
{
get { return seeRelation; }
set { seeRelation = value; }
}
[Category("Visualize")]
[Description("Indicates if the trend direction is changed when the old trend ends or whether a new trend must start.")]
[Gui.Design.DisplayNameAttribute("Trend change")]
public bool UseOldTrend
{
get { return useOldTrend; }
set { useOldTrend = value; }
}
#endregion


Compile OK but when adding to chart and enable, it does not works and error shows

Reply With Quote
  #315 (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

Change the indicator type in the name of the strategy. Right now it probably says:

 
Code
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Indicator
Change it to:
 
Code
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
Also make sure your 'using declaration' block has it in there. Compare against another strategy you have loaded to make sure the proper declaration is there at the very top.

Reply With Quote
  #316 (permalink)
 marcelo_s 
BUENOS AIRES
 
Experience: Intermediate
Platform: ninja
Broker: AMP
Trading: ES
Posts: 34 since Nov 2009
Thanks Given: 0
Thanks Received: 13


forrestang View Post
Change the indicator type in the name of the strategy. Right now it probably says:

 
Code
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Indicator
Change it to:
 
Code
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
Also make sure your 'using declaration' block has it in there. Compare against another strategy you have loaded to make sure the proper declaration is there at the very top.

******************************************************************************

That is what I did, see below

#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
using PriceActionSwing.Utility;
#endregion

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class SwingTrendX : Strategy
{
#region Variables
//Variables for PriceActionSwing
private int swingSize = 2;
private SwingTypes swingType = SwingTypes.Standard;
private int dtbStrength = 15;
private IDataSeries swingRelation = null; //HH/HL or LL/LH
private IDataSeries swingTrend = null; //Trend defined by DTs/DBs too

//variables below not needed, let in for completeness
private bool seeRelation = false;
private bool useOldTrend = true;
private bool paintBars = true;
private int oldTrend = 0;
#endregion

/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{

if (CurrentBar < 1)
{
if (swingRelation == null)
swingRelation = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingRelation;

if (swingTrend == null)
swingTrend = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingTrend;
}

//MARCELO ----- This IF statement is just used for debugging, so that you can see what values are
//in the two main variables you want that are referenced above.
if(swingTrend[0] == 1)
{
DrawArrowUp("arrow"+CurrentBar, true, 0, Low[0]-12*TickSize, Color.Green);
}


if(swingTrend[0] == -1)
{
DrawArrowDown("arrow"+CurrentBar, true, 0, High[0]+12*TickSize, Color.Red);
}





}
#region Properties

#region Parameters
//=====================================================================
/// <summary>
/// Represents the swing size. e.g. 1 = small swings and 5 = bigger swings.
/// </summary>
#if NT7
[GridCategory("Parameters")]
#else
[Category("Parameters")]
#endif
[Description("Represents the swing size. e.g. 1 = small swings and 5 = bigger swings.")]
[Gui.Design.DisplayName("2.Swing size")]
public int SwingSize
{
get { return swingSize; }
set { swingSize = Math.Max(1, value); }
}
/// <summary>
/// Represents the swing type. Standard | Gann
/// </summary>
#if NT7
[GridCategory("Parameters")]
#else
[Category("Parameters")]
#endif
[Description("Represents the swing type. Standard | Gann")]
[Gui.Design.DisplayName("3.Swing type")]
public SwingTypes SwingType
{
get { return swingType; }
set { swingType = value; }
}
/// <summary>
/// Represents the double top/-bottom strength.
/// </summary>
#if NT7
[GridCategory("Parameters")]
#else
[Category("Parameters")]
#endif
[Description("Represents the double top/-bottom strength. Increase the value to get more DB/DT.")]
[Gui.Design.DisplayName("1.Double top/-bottom strength")]
public int DtbStrength
{
get { return dtbStrength; }
set { dtbStrength = Math.Max(1, value); }
}
[Category("Visualize")]
[Description("Indicates if the trend direction is shown or the swing relation.")]
[Gui.Design.DisplayNameAttribute("See swing relation")]
public bool SeeRelation
{
get { return seeRelation; }
set { seeRelation = value; }
}
[Category("Visualize")]
[Description("Indicates if the trend direction is changed when the old trend ends or whether a new trend must start.")]
[Gui.Design.DisplayNameAttribute("Trend change")]
public bool UseOldTrend
{
get { return useOldTrend; }
set { useOldTrend = value; }
}
#endregion



#endregion
}
}

Reply With Quote
  #317 (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

I just tried running it.

There is a problem somewhere, definetely some reference somewhere. I'm not sure where at the moment.

I'll play around with it, not sure why the strategy is giving problems when the indie is not. You may want to start a thread in programming.

Reply With Quote
  #318 (permalink)
 marcelo_s 
BUENOS AIRES
 
Experience: Intermediate
Platform: ninja
Broker: AMP
Trading: ES
Posts: 34 since Nov 2009
Thanks Given: 0
Thanks Received: 13


forrestang View Post
I just tried running it.

There is a problem somewhere, definetely some reference somewhere. I'm not sure where at the moment.

I'll play around with it, not sure why the strategy is giving problems when the indie is not. You may want to start a thread in programming.

Tks, let me know if you can solve it.
I will post it on programming also to ask for help

Reply With Quote
  #319 (permalink)
 marcelo_s 
BUENOS AIRES
 
Experience: Intermediate
Platform: ninja
Broker: AMP
Trading: ES
Posts: 34 since Nov 2009
Thanks Given: 0
Thanks Received: 13


marcelo_s View Post
Tks, let me know if you can solve it.
I will post it on programming also to ask for help

I asked support to NT, and they answered as follow

" The issue likely is that indicator and strategies work different with your assignment of the data series return of the SwingRelation indicator as an object.
I would suggest working with the supported .Set approach here to add doubles to a series. You can likely just call the indicator plot directly in the strategy without needed to create additional series here first. "

Do you know how to do what is suggested ?

tks for help

Reply With Quote
  #320 (permalink)
 
Serninja's Avatar
 Serninja 
Germany
 
Experience: Intermediate
Platform: NinjaTrader
Posts: 55 since Mar 2010
Thanks Given: 87
Thanks Received: 31


dorschden,

I would like to ask you if it's possible for you to add a relative volume swing value in percent?

For example: Imagine a down swing in price with 100K volume and then a 30% up swing in price with 50K volume. When I set to show me the swing percentage, I can see the 30% print which is referring to the price swing but I still have to make mental math regarding the relative volume swing in percent of the last swing which would be 50%.

In this case price retraced 30% up but needed 50% of the last swing volume.

I believe it's helpful to have an 'at a glance - effort vs. result' view, so one can see if the price move is accompanied with high or low volume relative to the last price swing.

Thank you very much in advance!

Kind regards,
Serninja

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