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 965,554 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

  #291 (permalink)
 dorschden 
Germany
 
Experience: Master
Platform: NinjaTrader
Posts: 112 since Jun 2009
Thanks Given: 59
Thanks Received: 1,143

Use the following code, which is a good way to access the public DataSeries from the PriceActionSwing indicator within other indicators/strategies.
 
Code
                            
#region Using declarations

...
using PriceActionSwing.Utility;
#endregion

#region Variables
...
private 
int dtbStrength 15;
private 
int swingSize 7;
private 
SwingTypes swingType SwingTypes.Standard;
private 
IDataSeries swingRelation;
private 
IDataSeries swingTrend;
#endregion

protected override void OnStartUp()
{
  if (
swingRelation == null)
    
swingRelation PriceActionSwing(InputdtbStrengthswingSizeswingType).SwingRelation;
  if (
swingTrend == null)
    
swingTrend PriceActionSwing(InputdtbStrengthswingSizeswingType).SwingTrend;
  
// Assign other DataSeries here
}

protected 
override void OnBarUpdate()
{
  
// If HH and HL draw an arrow
  
if (swingRelation[0] == 1)
    
DrawArrowUp("MyArrow" CurrentBartrue0Low[0] - TickSizeColor.Lime);
  ...

Forrestang,

Like futuretrader mention, it is important, that the assignment of the "SwingRelation" dataseries comes before any other return statement, while the "if (CurrentBar < 1)" part is a leftover from NT 6.5. Or you can use the above code and every thing should work. You can do the same with the data series from the IchiCloud indicator.

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Exit Strategy
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Deepmoney LLM
Elite Quantitative GenAI/LLM
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
37 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #292 (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

Thanks a bunch! My script is working with the changes you mentioned.

I am trying to get my indicator to display in MA (Market Analyzer) now. My signal is basically in 1 of 3 positions.

I have been staring at the template you provided in the thread while I was going through it for YOUR MA, trying to figure out which variables you have exposed and how you did it. But I can't get it to do what I want.

What's weirder, is that as you can see in that column "WT_Up" on my MA template, it has the closing price. Which isn't what I want there.

What is it that I need to make sure my script has so that I can print it to MA? I can change the cell conditions, but where does it look in my script for that information?

-----EDIT------

I created a new data series called "trendState." Each time I perform my calculations (which have 3 different states), I have been putting a 1,0, -1 into that data series on each bar. I tried to then expose this variable.

Now, it shows up in MA as a selectable option in the 'plot' field. But the output is still just the close of the last bar on my chart, instead of the output of that dataSeries.

Here is what I mean by what I added. And it is in fact printing the proper output to my test window. I just haven't gotten it to work properly with MA.

 
Code
if (swingTrend[0] == 1 && blueCloud == true && Low[0] > spanA-ichiBuffer*TickSize)
			{
				UpTrend.Set(1);
				trendState[0] = 1;
			}
            
			else if (swingTrend[0] == -1 && redCloud == true && High[0] < spanA+ichiBuffer*TickSize)
			{
				DownTrend.Set(1);
				trendState[0] = -1;
			}
			
			else
			{
				NoWhere.Set(1);	
				trendState[0] = 0;
			}
			
			Print(trendState[0]);

Attached Thumbnails
Click image for larger version

Name:	Prime2011-07-17_093014.jpg
Views:	469
Size:	399.7 KB
ID:	43566  
Reply With Quote
  #293 (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'm such a newb!!! I finally got it working.

It was the way I was defining that new data series in the 'properties' section. I now have it returning the data series instead of whatever it was before.

Glad I had your script to reference.

Thanks again Dorschden!

Attached Thumbnails
Click image for larger version

Name:	FINALLY.jpg
Views:	389
Size:	416.6 KB
ID:	43568  
Reply With Quote
  #294 (permalink)
no111
NED
 
Posts: 34 since May 2010
Thanks Given: 7
Thanks Received: 8

With these numbers you can get swingrelation:
-2 = DT
-1 = LL and LH
0 = price is nowhere
1 = HH and HL
2 = DB

But is it also possible to get HL and LH?

Reply With Quote
  #295 (permalink)
 Ralph07 
London UK
 
Experience: Advanced
Platform: NinjaTrader, TT
Broker: Mirus
Trading: CL, Dax, ES, Eurostoxx50
Posts: 121 since Oct 2010
Thanks Given: 23
Thanks Received: 46

Hi Dorschden,

Thanks again for this fantastic work on PAS.
Just a question please : is it possible to have sound alerts with the market analyser template you did? If yes, how do you set it up?

Thanks a lot for your help.

Raphael

Reply With Quote
  #296 (permalink)
 evancds 
PA
 
Experience: Beginner
Platform: Sierra, Ninja, MD
Broker: Optimus/Rithmic & IQ
Trading: currency futures
Posts: 27 since Apr 2011
Thanks Given: 13
Thanks Received: 19

Does anyone have the time and skill to add an email alert in addition to the sound?

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


no111 View Post
...you can get swingrelation... But is it also possible to get HL and LH?

no111,

This isn't possible but you can add a dataseries and calculate it by yourself. Add this code to the indicator.
 
Code
                            
#region Variables

private DataSeries swingHlLh;
#endregion

// Add to the Initialize() method
swingHlLh = new DataSeries(this);

// Add in the end of OnBarUpdate() method
// HL and LH
if (curHighRelation == Relation.Lower && curLowRelation == Relation.Higher
  
swingHlLh.Set(1);
else
  
swingHlLh.Set(0);

#region Properties
[Browsable(false)]
public 
DataSeries SwingHlLh
{
  
get { return swingHlLh; }
}
#endregion 

rdaune View Post
is it possible to have sound alerts with the market analyser template you did?

Raphael,

Yes, this is possible. Just add an alert condition to it. For more details look here.


evancds View Post
Does anyone have the time and skill to add an email alert in addition to the sound?

evancds,

Sorry I can't help you here, I don't have time for this. But on this site are enough scripts with an email alert, just copy and paste the code.

Started this thread Reply With Quote
Thanked by:
  #298 (permalink)
 evancds 
PA
 
Experience: Beginner
Platform: Sierra, Ninja, MD
Broker: Optimus/Rithmic & IQ
Trading: currency futures
Posts: 27 since Apr 2011
Thanks Given: 13
Thanks Received: 19

Ok, I've attempted to add the email alert. Can some one compile this and see if it works? I don't have the full version of Ninjatrader

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


evancds View Post
Ok, I've attempted to add the email alert. Can some one compile this and see if it works? I don't have the full version of Ninjatrader

I think you can always put your SIM key back in NT, restart, so that you can mess with scripting if you wish.

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


Hi,
I am trying to use the code to build a strategy but an error on the Log tab comes up showing " Reference to oject .... )

This is the way I am starting to write code. May be you can help me how to use this indicator correctly

#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 CLSwing : Strategy
{
#region Variables
// Wizard generated variables

private int swingSize = 3;
private SwingTypes swingType = SwingTypes.Standard;
private int dtbStrength = 15;
private IDataSeries swingTrend;
private IDataSeries swingRelation;

// User defined variables (add any user defined variables below)
#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()
{
// SetStopLoss("", CalculationMode.Ticks, SaftyStopLoss, false);
//SetProfitTarget("", CalculationMode.Ticks, Profit);
//SetTrailStop("", CalculationMode.Ticks, Stop, false);
// SetStopLoss("", CalculationMode.Ticks, Stop, false);

CalculateOnBarClose = true;

}


/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar < 1)
{
if (swingTrend == null)
swingTrend = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingTrend;
if (swingRelation == null)
swingRelation = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingRelation;
}
int trend = Convert.ToInt32(swingTrend[0]);
switch (trend)
{
case -1:
// Down trend - do something
EnterShort(DefaultQuantity, "Sh");
break;
case 1:
// Up trend - do something
EnterLong(DefaultQuantity, "Lg");
break;
default:
// No trend - do something or nothing
break;
}

// Or alternative
//if (swingRelatioin[0] == 2)
// Double bottom - do something
}
#region Properties

#endregion
}
}

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