duration of a stoploss
Forums › ProRealTime English forum › ProOrder support › duration of a stoploss
- This topic has 5 replies, 3 voices, and was last updated 7 years ago by
immo_vienna.
-
-
07/16/2018 at 2:12 PM #76083
hi guys!
i read in some articles that an stoploss has an duration of 1 candle.
so if i have the following code for automatic trading – the stoploss is only for 1 minute, 10 minutes, (depends on the timeframe)?
12345678910111213141516171819202122232425262728293031323334//trailing stop functiontrailingstart = 20 //trailing will start @trailinstart points profittrailingstep = 5 //trailing step to move the "stoploss"//reset the stoploss valueif not onmarket thennewSL=0endif//manage long positionsif longonmarket then//first move (breakeven)if newSL=0 and close-tradeprice(1)>=trailingstart*pipsize thennewSL = tradeprice(1)+trailingstep*pipsizeendif//next movesif newSL>0 and close-newSL>=trailingstep*pipsize thennewSL = newSL+trailingstep*pipsizeendifendif//manage short positionsif shortonmarket then//first move (breakeven)if newSL=0 and tradeprice(1)-close>=trailingstart*pipsize thennewSL = tradeprice(1)-trailingstep*pipsizeendif//next movesif newSL>0 and newSL-close>=trailingstep*pipsize thennewSL = newSL-trailingstep*pipsizeendifendif//stop order to exit the positionsif newSL>0 thensell at newSL stopexitshort at newSL stopendif@ this point: thx to nicolas for this system
07/16/2018 at 2:22 PM #76084STOP LOSS does not expire if you set it with ProOrder instructions (SET STOP LOSS,…..).
PENDING ORDERS expire each bar (be it 1 second or 1 week) and need to be placed again if needed. Thus if you set your SL with a pending order (like Nicolas did in his code) it must be placed again if you still need it after each bar. Nicolas’code does this with lines 31-34.
1 user thanked author for this post.
07/16/2018 at 2:22 PM #76085Correct. LIMIT and STOP orders last for one bar only. So on a ten minute time frame it is for ten minutes. If you want the order kept on the market then reissue it at each candle close or use a SET instruction to place a stop or limit on the market at a set distance from the position price. A SET instrution only has to be issued once and keeps the order on the market until the position is closed. The SET distance can be changed at any bar close by placing a new SET instruction if you want to change the value.
1 user thanked author for this post.
07/16/2018 at 2:30 PM #76086how to write such SET instruction?
07/16/2018 at 2:36 PM #7608807/16/2018 at 2:40 PM #76089thx! all of u out there are amazing and i love this forum because u all are here!
1 user thanked author for this post.
-
AuthorPosts