Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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;
#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
Change the indicator type in the name of the strategy. Right now it probably says:
Change it to:
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.
#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;
//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);
}
#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
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. "
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.