How StopLoss to triger placing new order?

 

Hi,


I want to place a new order when a StopLoss is triggered. How to do this?


thanks

 
Open two orders at the time, and make a price of the second order equal stoploss first.
 
jordan62:

Hi,


I want to place a new order when a StopLoss is triggered. How to do this?


thanks



If you calculate what value the stoploss is when you set the order, you can fire an order if your current one does not exist anymore on the next loop and the price reaches that level.


You'd need conditions of course, such as the fact it existed 5 minutes ago or last tick etc.


NB I should add, you will hopefully of also considered the many other factors as to why the values will not always line up exactly on the stoploss.

 
Onyx:


If you calculate what value the stoploss is when you set the order, you can fire an order if your current one does not exist anymore on the next loop and the price reaches that level.


You'd need conditions of course, such as the fact it existed 5 minutes ago or last tick etc.


NB I should add, you will hopefully of also considered the many other factors as to why the values will not always line up exactly on the stoploss.


The problem is that I don't know at what level the order with StopLoss will be opened because this is in if{ } . So, I want to have a script that will catch the execution of the StopLoss on fly and will open a new order at this moment.

 
jordan62:

The problem is that I don't know at what level the order with StopLoss will be opened because this is in if{ } . So, I want to have a script that will catch the execution of the StopLoss on fly and will open a new order at this moment.



If you have an order open you can get its stoploss from OrderStopLoss( ) and add or take that from the order open price but quite apart from that, when you first make the order you will know what the stoploss is.


If you mean you modify it afterwards, with a trailing stop or another system, then simply modify the variable or array your using to hold the stoploss too.


Whenever you make an order you tell the order what the stoploss is, be it an if, for, while, whatever, thats when you can record it.

Reason: