How to override Stoploss generated by a strategy in Superdom
Hi everyone, I have created a strategy which sets my stop automatically (using setstoploss). I want to be able to change my stop manually in superdom while the strategy is still running. The problem is whenever I change my stop in superdom manually, my stop will automatically change back to the level defined in setstoploss() in the strategy.
I understand that instead of using iorder related procedures (such as enterlonglimit), I can use AtmStrategyCreate() which will allow me to change my stop or profit target manually in superdom. But my strategy requires iorder functions.
Is there a way which I can manually change my stop and override setstoploss() in a strategy while it is still running?
Thanks in advance.
Last edited by puppeye; February 27th, 2010 at 12:16 AM.
I have been working on this recently, and can post some examples next week when I get back from vacation. What you need to do, is monitor the stop and target orders as they change state. As the state changes to pending change, you can capture the new stop/limit price and store it in a var, and then use that var to set your new stop/target on the next tick in OnBarUpdate().
The following 2 users say Thank You to aslan for this post:
by the way, this forum is far better than ninja support forum!
This is the "standard answer" i've got from them ---- "puppeye, unfortunately not - to be able to manage strategy generated orders manually on ChartTrader and the DOM's you would need need work with calling ATM templates for exit management."
The following 3 users say Thank You to puppeye for this post:
Isn't that hilarious, not. They don't even know how to use their own platform. I started working on this for similar reasons that you did. In the past I used ATM strategies live because I could manage them from the DOM, but that has a major disadvantage in that you can not back test with ATM. I had searched the forums, and I found nothing. So, I started working on a generic strategy that was like the ATM strategy. The one useful thing I found in the forum recently was a nice example to add a button to the toolbar, which you can use to set a var to enable/disable the strategy on the fly or to flatten a position.
This behavior is because you continuously make a call to setstoploss, you can add some bool to the initial statement just to ensure your code only manipulate the stop once, then afterward you can manipulate manual.
Maybe similar to this:
if( your condition && !Breakeven)
set your stop in here
Breakeven = true;
Attached is an example which I have created to allow you to manually change the stop controlled by a strategy. You will see that I have also added a button to the chart to switch between "auto mode" and "manual mode".
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).
The following 6 users say Thank You to puppeye for this post: