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  for example.
Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.
Need help? 1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first. 2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses. 3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make. 4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance. 5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers. 6) Help using the forum? Watch this video to learn general tips on using the site.
If you want to support our community, become an Elite Member.
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
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;
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 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.
The following user says Thank You to forrestang for this post: