set different stop loss
Forums › ProRealTime English forum › ProOrder support › set different stop loss
- This topic has 7 replies, 2 voices, and was last updated 4 years ago by stefou102.
-
-
07/18/2019 at 11:59 AM #102821
Hello,
I’m working with stop orders in order to open new positions in my automated strategies. I have an issue with my SL however. My idea is to:
- set a first stop once the position is open, just below the previous candle low/high
- For the next bars, I would like to use another stop, a bit further, which is then fixed through the trade
The issue I have is that when used separately the code for point 1 and 2 works fine, but when combined only point 1 is working. So in the code the instruction “set stop loss” seems to prevail over “sell/existshort at stop”.
Does someone know why?
1234567891011121314151617If long=1 thenbuy positionSize contracts at buyLevel STOPstopbougieL=Lowest[7](low)-2*pipsizeset stop loss abs((close-low))+2*pipsizeendifif short=1 thensellshort positionSize contracts at SellLevel STOPstopbougieS=highest[7](high)+2*pipsizeset stop loss abs((close-high))+2*pipsizeendifif longonmarket thensell at stopbougieL stopgraph closeelsif shortonmarket thenexitshort at stopbougieS stopendif07/18/2019 at 2:18 PM #102831Whenever LONG = 1 or SHORT = 1 then the STOP LOSS order will be read and placed. The following should work as long as you are not wanting to use accumulating positions:
12345678910111213141516171819202122If long=1 thenbuy positionSize contracts at buyLevel STOPstopbougieL=Lowest[7](low)-2*pipsizeif not onmarket thenset stop loss abs((close-low))+2*pipsizeendifendifif short=1 thensellshort positionSize contracts at SellLevel STOPstopbougieS=highest[7](high)+2*pipsizeif not onmarket thenset stop loss abs((close-high))+2*pipsizeendifendifif longonmarket thensell at stopbougieL stopgraph closeelsif shortonmarket thenexitshort at stopbougieS stopendif07/18/2019 at 2:30 PM #10283507/18/2019 at 3:03 PM #102838Sorry my mistake. A SET STOP LOSS order need only be sent once and is then on the market until it is either cancelled or the value changed. Setting it to zero is supposed to cancel them but it did not use to work (maybe it does now?) An alternative is to use SET STOP %LOSS 100.
123456789101112131415161718192021222324If long=1 thenbuy positionSize contracts at buyLevel STOPstopbougieL=Lowest[7](low)-2*pipsizeif not onmarket thenset stop loss abs((close-low))+2*pipsizeendifendifif short=1 thensellshort positionSize contracts at SellLevel STOPstopbougieS=highest[7](high)+2*pipsizeif not onmarket thenset stop loss abs((close-high))+2*pipsizeendifendifif longonmarket thenset stop ploss 0sell at stopbougieL stopgraph closeelsif shortonmarket thenset stop ploss 0exitshort at stopbougieS stopendif07/18/2019 at 3:10 PM #102840An alternative is to just use pending stop orders and not use SET STOP orders.
12345678910111213141516171819202122If long=1 thenbuy positionSize contracts at buyLevel STOPstopbougieL=Lowest[7](low)-2*pipsizeif not onmarket thensell at close - abs((close-low))+2*pipsize stopendifendifif short=1 thensellshort positionSize contracts at SellLevel STOPstopbougieS=highest[7](high)+2*pipsizeif not onmarket thenexitshort at close + abs((close-high))+2*pipsize stopendifendifif longonmarket thensell at stopbougieL stopgraph closeelsif shortonmarket thenexitshort at stopbougieS stopendif07/18/2019 at 6:32 PM #102854Thx very much Vonasi ,
your trick with SET STOP %LOSS 100 seems to be working! Testing the code on my strategy, it improves a bit the profit factor, which was the goal, as I noticed that sometimes, the market moves directly against you (meaning in the same bar when you took the trade), and it’s best to cut directly.
07/18/2019 at 7:14 PM #10285607/18/2019 at 10:02 PM #102867 -
AuthorPosts
Find exclusive trading pro-tools on