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,163 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

  #301 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,440 since Jun 2009
Thanks Given: 33,215
Thanks Received: 101,599

From a quick look at your code (which you should attach as a file next time please), the problem is you aren't referencing a bar index at the end of the line... like [0] for example.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Increase in trading performance by 75%
The Elite Circle
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
36 thanks
Tao te Trade: way of the WLD
24 thanks
Spoo-nalysis ES e-mini futures S&P 500
21 thanks
Bigger Wins or Fewer Losses?
19 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #302 (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 Mike

find attached the code. I did not exported yet as a NT file as it is not working. Even can be openned by wordpad

Error on Log tab comes up still " Error on calling 'OnBarUpdate' method for strategy 'SwingTrend/5a5dbe23f8024e478a15d85fea1eb33d': Referencia a objeto no establecida como instancia de un objeto.

If you can help I think this strategy could be profitable for all Big Mike members

Tks
Marcelo

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



marcelo_s View Post
Hi Mike

find attached the code. I did not exported yet as a NT file as it is not working. Even can be openned by wordpad

Error on Log tab comes up still " Error on calling 'OnBarUpdate' method for strategy 'SwingTrend/5a5dbe23f8024e478a15d85fea1eb33d': Referencia a objeto no establecida como instancia de un objeto.

If you can help I think this strategy could be profitable for all Big Mike members

Tks
Marcelo

Do me a favor and try this out. It compiles at least. There was an error with that 'Log' command you put in there which I think you were using for debugging.

So look @ lines 62-65 and 82-89 and check those.

I'm obviously not smart enough to figure out how to disable 'ChartTrader' for some reason so I didn't add this to my chart, but it compiles.

Attached Files
Elite Membership required to download: SwingTrendx.cs
Reply With Quote
  #304 (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
Do me a favor and try this out. It compiles at least. There was an error with that 'Log' command you put in there which I think you were using for debugging.

So look @ lines 62-65 and 82-89 and check those.

I'm obviously not smart enough to figure out how to disable 'ChartTrader' for some reason so I didn't add this to my chart, but it compiles.

Hi,
I deleted @lines 62-65 , but @lines 82-89 I copy/paste them from the forum. Can not be deleted . Does not compiles .
We need to work with a variable that contains the trend ( ==1 Long, ==-1 Short , ==2 neutral ) but I can not find it in the PriceActionSwingTrend code
What do you suggest ?
Tks for help
Marcelo

Reply With Quote
  #305 (permalink)
no111
NED
 
Posts: 34 since May 2010
Thanks Given: 7
Thanks Received: 8


dorschden View Post
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 

Thanks, I think I get it almost working.
When I add that code to the indicator and then I change my strategy.. I'm getting this error:
OnBarUpdate method for strategy: Object reference not set to an instance of an object.

I think it needs a null reference, like this:
if (swingRelation == null)
swingRelation = PriceActionSwing(Input, dtbStrength, swingSize, swingType).SwingRelation;

But how do I make that for swingHlLh?

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

Cannot complile, error shows up on line where

#region Variables
....
private SwingMode pAS_SwingMode = SwingMode.Standard;
.....
#endregion


and on line

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

The type or namespace name 'SwingMode' could not be found (are you missing a using directive or an assembly reference?)


Any idea why?

tks for help
Marcelo





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.


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


marcelo_s View Post
Hi,
I deleted @lines 62-65 , but @lines 82-89 I copy/paste them from the forum. Can not be deleted . Does not compiles .
We need to work with a variable that contains the trend ( ==1 Long, ==-1 Short , ==2 neutral ) but I can not find it in the PriceActionSwingTrend code
What do you suggest ?
Tks for help
Marcelo

In the 'PriceActionSwingTrend' the variables you are looking for are shown highlighted in the pic.

'swingRelation' tells you if you have a HH/HL or LL/LH in relation to the last swing.

'swingTrend' tells you what the trend is based on that.

These two dataSeries are either -1,0 or +1.

Attached Thumbnails
Click image for larger version

Name:	Prime2011-07-29_042818.png
Views:	250
Size:	6.8 KB
ID:	45005  
Reply With Quote
  #308 (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

Also, I would suggest copying the entire "PriceActionSwingTrend" indicator, renaming it, setting the property to 'strategy' and starting from there. This is what I did. At least this way you will have the references you need to build your strategy.

Then delete the things you don't need one at a time.

If you need help with this let me know and we can get you started with that blank template so to speak so that you can begin building the logic you need based on those references.

Reply With Quote
  #309 (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
Also, I would suggest copying the entire "PriceActionSwingTrend" indicator, renaming it, setting the property to 'strategy' and starting from there. This is what I did. At least this way you will have the references you need to build your strategy.

Then delete the things you don't need one at a time.

If you need help with this let me know and we can get you started with that blank template so to speak so that you can begin building the logic you need based on those references.

I will apritiate a lot if you can send me the blank template , so I can add only the strategy conditions and actions where Trend == 1 ( Long ) , Trend == -1 ( Short )

Tks for help
Marcelo

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



marcelo_s View Post
I will apritiate a lot if you can send me the blank template , so I can add only the strategy conditions and actions where Trend == 1 ( Long ) , Trend == -1 ( Short )

Tks for help
Marcelo

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.

Attached Thumbnails
Click image for larger version

Name:	Prime2011-07-29_115400.png
Views:	703
Size:	84.1 KB
ID:	45051  
Attached Files
Elite Membership required to download: swingTrendX.cs
Reply With Quote
Thanked by:




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