Hi Eugene,
I see a problem with ApplyAutostops in the Strategy windows. if you open 2 strategies in the Strategy windows and the both of them used ApplyAutostops, the ApplyAutostops used the last parameter of your stops and not the parameter of your script.
Please test it with this simple scripts :
--> Script 1 (RUN First)
CODE:
Please log in to see this code.
--> Script 2 (RUN after the script 1)
CODE:
Please log in to see this code.
If you RUN again the script 1, you will see that all your trades is exit after 2 bars.
Does I make somethings wrong ?
Size:
Color:
Hi Alexandre,
No, I don't think you did anything wrong. The problem description looks like caused by the use of static variables and/or methods by
ApplyAutoStops in Community Components.
As a workaround, remove all links to ApplyAutoStops and paste its entire code found in thread below into each Strategy where you had ApplyAutoStops installed:
Post by thodder #6Don't forget to include
public enum AutoStopMode.
Thanks for spotting the issue.
Size:
Color:
Thank you Eugene. I will try like this
Size:
Color:
The bug will be fixed in C.Components 2017.05. However, any existing strategies will have to call a new method (at the end of the Strategy code). To be exemplified on the
AutoStops Wiki page when the updated extension is released (late April - early May).
P.S. The code must have an extra call to a new method called
OnProcessingComplete after the trading loop. To avoid the bug that abegy has brought into the spotlight, it must be added to ALL strategies that employ AutoStops in C.Components after updating the library to v2017.05:
CODE:
Please log in to see this code.
Size:
Color:
Alexandre, the fix is out. Please update C.Components to v2017.05.
Size:
Color:
Hi Eugene,
I try it with the new components but I have the same problem. To be sure, I restarted my computer after the installation. But still the same problem. Do you have an idea ?
Size:
Color:
Hi Alexandre,
The issue is fixed. I double checked that. You're doing something wrong but I don't know what since you haven't provided a detailed test case.
Size:
Color:
I start my computer, load Wealth-lab and open a new strategy from code with the code of the the script 1. I run it.
After that, I open a new strategy from code with the code of the the script 2. I run it.
I run again the script 1 and see my trades with the 2 bars (see my screen shot).
I have checked that the components dll is the last one (date : 4/30/2017). Any idea ?
Size:
Color:
Thanks, it's clear now. Please review my post #4 above. The important but overlooked point here is that you must call PositionEx.OnProcessingComplete() at the end of Execute() in each strategy that uses ApplyAutoStops from C.Components. This is where the fix is grounded.
Size:
Color:
Yes. it works. Sorry for the mistake.
Thanks a lot Eugene.
Size:
Color:
Alexandre,
That's good news to hear!
Size:
Color: