money management AND trailing stop function
Forums › ProRealTime English forum › ProOrder support › money management AND trailing stop function
- This topic has 8 replies, 2 voices, and was last updated 7 years ago by
Nicolas.
-
-
06/06/2018 at 7:53 PM #72507
https://www.prorealcode.com/blog/learning/money-management-prorealtime-code/
https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
hi pro’s!
is there any option to combine these 2 codes?
thx!
06/07/2018 at 12:04 PM #7255206/07/2018 at 1:14 PM #72557- i am looking for the correct stop loss
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960efparam cumulateorders = falseREM Money ManagementCapital = 10000Risk = 0.01StopLoss = XXXXXX // whats my stop loss here?REM Calculate contractsequity = Capital + StrategyProfitmaxrisk = round(equity*Risk)PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)//order launch (example) would be set to any other entry conditions//c1 = close>close[1]c2 = close<close[1]//if c1 then//BUY positionsize AT MARKET//SET STOP PLOSS 50//endif//************************************************************************//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 STOPENDIF2) if i use this strategy and i buy an contract there is NO stoploss before //first move (breakeven).
i need an stoploss at the market entry too. do u know what i mean? :Sthx
06/07/2018 at 2:27 PM #72571Something like:
123if on market and newsl=0 thenset stop ploss 100endif1 user thanked author for this post.
06/07/2018 at 3:04 PM #72576ad 2) seems legit thx!
and what would u do bout the money management system?
ad 1) i tried this but it doesnt work:1234REM Money ManagementCapital = 10000Risk = 0.01StopLoss = tradeprice(1)+trailingstep*pipsize // whats my stop loss here?06/29/2018 at 9:19 AM #74716@Nicolas: can u help me a bit?
06/29/2018 at 10:13 AM #7473107/01/2018 at 8:39 PM #75033i am tryin to combine this two systems:
https://www.prorealcode.com/blog/learning/money-management-prorealtime-code/
https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
07/02/2018 at 10:00 AM #75069 -
AuthorPosts
Find exclusive trading pro-tools on