Hi,
The following code works just fine:
(i.e. :
- opens trades at designated lot sizes,
- displays opened/closed marks on the chart,
- calculates respective performance statistics etc.)
CODE:
Please log in to see this code.
However, and interestingly, the following code, although a replica of the one I presented above, doesnt function properly
(i.e.:
- does not open trades at designated amounts,
- does not show opened/closed triangular marks on the chart,
- does not trade thus does not produce any sort of performance metrics
- etc.)
CODE:
Please log in to see this code.
***
As you might have followed, the only difference between these codes is that, one gets one number as lotsize (i.e. 100 for Y and 150 for X), whereas for the latter case, respective lotsizes are first defined (as double),, then calculated and assigned, and then used as the share size for respective positions.
What is the problem here? Why do my code function properly when I use "100" as my SetShareSize input whereas it does not work when I use one "double lotSizeY"?
Other remarks:
1- when calculated, lotSizeY is something like 375968.992248062 and lotSizeX is something like 383864.341085271. Maybe the precision, or, some other pecularity I cannot understand, might have resulted in this misbehaviour of the SetShareSize method;
2- Obviously, the position size is set as "Override in script";
3- When I choose another position sizing (say, "fixed share size set as 100"), the code works fine;
4- The overall flow of the code works fine when I use these test 100 and 150 share sizes for Y and X respectively. So, I observe that my problem is contained at the SetShareSize method.
Thanks in advance for your consideration and the time,
Best regards,