trailing stop not accepted when going live
Forums › ProRealTime English forum › ProOrder support › trailing stop not accepted when going live
- This topic has 9 replies, 4 voices, and was last updated 3 years ago by robertogozzi.
-
-
11/30/2020 at 6:28 PM #152247
Hi guys, anybody can explain me why when I am adding a trailing condition in my strategy the platform doesn’t allow me to run the system and when I delete the trailing conditions from the strategy the platform run my strategy?? Thanks
11/30/2020 at 7:08 PM #152250SET STOP TRAILING is accepted,thiough recommended.
What error does it return?
Usually a common mistake is to use TWO different kinds of stop, such as:
1SET STOP LOSS 100 TRAILING 10which is not allowed, SET STOP LOSS and SET STOP TRAILING cannot be in the same line and cannot be in the same strategy. If they are in the same line an error is reported, while if they are on different lines they are accepted, but the second line always overrides the previous one.
1 user thanked author for this post.
11/30/2020 at 7:53 PM #152255Hi, this is the code I am using for
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758defparam cumulateorders = false//order launch (example) would be set to any other entry conditions//c1 = close>close[1]c2 = close<close[1]//if c1 then//BUY 1 LOT AT MARKET//SET STOP PLOSS 50//endifif c2 thenSELLSHORT 1 LOT AT MARKETSET STOP PLOSS 50endif//************************************************************************//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//************************************************************************GRAPH newSL as “trailing”11/30/2020 at 7:55 PM #15225611/30/2020 at 8:22 PM #15226111/30/2020 at 9:16 PM #15226511/30/2020 at 10:27 PM #152268Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
Thank you 🙂
12/02/2020 at 10:57 AM #1523921234567891011121314breakeven = 30keeppoints = 5if not onmarket thenflag = 0endifIF longonmarket and close - tradeprice >= Breakeven*pipsize THENflag = 1endifif flag thensell at (tradeprice + keeppoints) stopendifHi guys, I am new in programming so there is anybody who can help me how to build a breakeven code for short positions ? what do I have to change exactly to make it work for short one ? thank you for your patience.
MODERATORS EDIT: One post deleted and merged and code tidied up. Topic also moved to correct forum. Please try to be more careful with future posts.
12/02/2020 at 11:35 AM #15239912/02/2020 at 11:39 AM #152402Replace line 30 with:
1sell at (tradeprice + keeppoints*PipSize) stopLong & Short breakeven1234567891011121314151617181920breakeven = 30 * pipsizekeeppoints = 5 * pipsizeif not onmarket thenflag = 0endif// LongIF longonmarket and close - tradeprice >= Breakeven THENflag = 1endif// ShortIF shortonmarket and tradeprice - close >= Breakeven THENflag = 1endifIF Flag = 1 thenIF LongOnMarket THENsell at (tradeprice + keeppoints) stopELSIF ShortOnMarket THENexitshort at (tradeprice - keeppoints) stopENDIFEndif1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on