I am stuck and need helps on debugging

Questions about MultiCharts and user contributed studies.
Spikehog
Posts: 39
Joined: 09 Dec 2013
Has thanked: 26 times
Been thanked: 1 time

I am stuck and need helps on debugging

Postby Spikehog » 26 Apr 2016

I have a strategy(let's say strategy A) in which there are about 50 lines of coding I want to reuse them again in other strategies. So I created few custom functions based on these lines and used these newly created functions instead of the 50 lines of coding in strategy B(everything remains the same as strategy A except without the 50 lines of coding). Then I made a comparison between strategy B with custom functions and strategy A to see if they gave the same result on the performance report. Obviously the results are the same, so I spent few days in reading the codes line by line and finding out where the bugs are and what made the discrepancy between them. Unfortunately I can't locate where the problems are. For example the stop orders in strategy A were working the way I wanted to. However these stop orders in strategy B had very different prices (although I used the reserved word "stop" in the coding, but it seems to me that these stop orders became market order instead) which gave a very different result compared to strategy A.

I understand that without showing you the codes you can not tell me what the problems are. I would be grateful if you could tell where the problems normally lies in and give some general guideline in debugging as well as creating custom functions which I should pay attention to.

Best regards,
Stephen

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: I am stuck and need helps on debugging

Postby arnie » 27 Apr 2016

You don't need to post your strategy code but it would be preferable to code some example that generate the same problem you're seeing on your strategy so the guys could easily see what is happening and help you.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: I am stuck and need helps on debugging

Postby JoshM » 27 Apr 2016

Then I made a comparison between strategy B with custom functions and strategy A to see if they gave the same result on the performance report. Obviously the results are the same, so I spent few days in reading the codes line by line and finding out where the bugs are and what made the discrepancy between them.
I'm slightly confused by this part; you say that 'obviously the results are the same' but also that there's a discrepancy between them. So is there's a difference between Strategy A and Strategy B, or are you talking about Strategy A without functions and Strategy A with functions, or some other comparison?
However these stop orders in strategy B had very different prices (although I used the reserved word "stop" in the coding, but it seems to me that these stop orders became market order instead) which gave a very different result compared to strategy A.
Stop orders become a market order when triggered, yes. Did you meant to use a stop-limit order?

Spikehog
Posts: 39
Joined: 09 Dec 2013
Has thanked: 26 times
Been thanked: 1 time

Re: I am stuck and need helps on debugging

Postby Spikehog » 28 Apr 2016

JoshM, it's stop order I want, not stop limit order. Thanks for your help anyway.

I have emailed the all the details to Henry to have a look. Hopefully, Henry will give me positive feedback.

Best regards!


Return to “MultiCharts”