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)
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.
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
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
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;
#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
Pepperdog,
you have to add this lines in your strategy
#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
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.
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.
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 )
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.
Elite Membership required to download: swingTrendX.cs