Trailing stop by point
Forums › ProRealTime English forum › ProOrder support › Trailing stop by point
- This topic has 6 replies, 4 voices, and was last updated 3 years ago by GraHal.
-
-
03/11/2021 at 9:53 AM #163800
Hi all
I would like to set a trailing stop by point.
Such as, DJI, open at 30000 point, target 100 pt and loss 100 pt.
Sometimes, only 95 pt then drop to stop loss.
I want to set the openprice + 80 pt = trailing stop to guarantee the point to avoid these situation occur.
And the stop loss 100pt is unchange. Anyone can help?
12345set target profit 100set stop ploss 100//%trailing stop functionSET stop pTRAILING [????] + 80Thanks.
03/11/2021 at 10:30 AM #16381003/11/2021 at 11:41 AM #163822Here’s a few options for you, Trailing by Points, by % or by MFE, as Jebus has suggested – take your pick.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143//points trailing stop functiontrailingstart = tst //trailing will start @trailinstart points profittrailingstep = st //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//************************************************************************// % trailing stop functiononce trailingstop = 1if trailingstop thentrailingpercentlong = tsl // %trailingpercentshort = tss // %stepPercentlong = stlstepPercentshort = ststssensitivity=2 // 1 = close 2 = High/Low 3 = Low/High 4 = typicalpriceif onmarket thentrailingstartlong = tradeprice(1)*(trailingpercentlong/100) //trailing will start @trailingstart points profittrailingstartshort = tradeprice(1)*(trailingpercentshort/100) //trailing will start @trailingstart points profittrailingsteplong = tradeprice(1)*(stepPercentlong/100) //% step to move the stoplosstrailingstepshort = tradeprice(1)*(stepPercentshort/100) //% step to move the stoplossendif//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIFif tssensitivity=1 thentssensitivitylong=closetssensitivityshort=closeelsif tssensitivity=2 thentssensitivitylong=hightssensitivityshort=lowelsif tssensitivity=3 thentssensitivitylong=lowtssensitivityshort=highelsif tssensitivity=4 thentssensitivitylong=typicalpricetssensitivityshort=typicalpriceendif//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND tssensitivitylong-tradeprice(1)>=trailingstartlong THENnewSL = tradeprice(1)+trailingsteplongENDIF//next movesIF newSL>0 AND tssensitivitylong-newSL>trailingsteplong THENnewSL = newSL+trailingsteplongENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-tssensitivityshort>=trailingstartshort THENnewSL = tradeprice(1)-trailingstepshortENDIF//next movesIF newSL>0 AND newSL-tssensitivityshort>trailingstepshort THENnewSL = newSL-trailingstepshortENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIFendif//************************************************************************//MFE trailing stoptrailingstop = 20//resetting variables when no trades are on marketif not onmarket thenMAXPRICE = 0MINPRICE = closepriceexit = 0endif//case SHORT orderif shortonmarket thenMINPRICE = MIN(MINPRICE,close) //saving the MFE of the current tradeif tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price levelendifendif//case LONG orderif longonmarket thenMAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current tradeif MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop thenpriceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price levelendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPendif1 user thanked author for this post.
03/11/2021 at 3:27 PM #163849I personally am the most fan of the MFE modified to start after XX pips in profit!
So if you are +50 pips in profit = no trailing stop loss
but if that same trade goes +100 pips in profit = actiavte a MFE trailing stop loss.
03/11/2021 at 3:51 PM #16385003/11/2021 at 4:54 PM #16386003/11/2021 at 5:32 PM #163868Should be able to find a lind for that by searching.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on