Trailing stop, Breakeven code
Forums › ProRealTime English forum › ProOrder support › Trailing stop, Breakeven code
- This topic has 5 replies, 3 voices, and was last updated 5 years ago by bullbear.
Tagged: BreakEven, trailing stop
-
-
08/04/2019 at 1:19 PM #104144
There are many different exit codes.
I am coding 1 min DAX and testing different stops, trailing, breakeven etc.
It would make it easier for me who is not so good at coding if there was a list on different exits.
The best thing would be to be able to copy past different exits to a code you made.
Maybe there is already here on the forum?08/04/2019 at 1:30 PM #104147Great idea! I would welcome this also! Hope it comes about!
If I thought there is support I would raise a spreadsheet and host it on my google drive similar to below
Maybe this Thread needs a more appropriate title … e.g EXIT Conditions??
08/05/2019 at 8:07 AM #104197Here is one.
1234567// dynamic units based STOP LOSSmyATRLL = 2* averagetruerange[2](close)//8,1myATRPL = 3* averagetruerange[6](close)//6,9SET stop loss myATRLLSET target profit myATRPL1 user thanked author for this post.
08/05/2019 at 10:02 AM #1042001234567891011IF NOT LONMARKET THENnewSL=0ENDIFIF LONGONMARKET AND close-tradeprice(1)>=30*pipsize THENnewSL = tradeprice(1)+5*pipsizeENDIFIF newSL>0 THENSELL AT newSL STOPENDIFIf current buy order is in gain of 30 points, order will be closed at entry price + 5 points.
1 user thanked author for this post.
08/05/2019 at 1:13 PM #104209This, I am not quite sure if it works but I think so 🙂
123456789101112131415161718192021222324252627282930313233343536//trailing stoptrailingstop = 20StartTrailingStopValue = 10//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)-close > StartTrailingStopValue*pointsize thenif 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 levelendifendifendif//case LONG orderif longonmarket thenMAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current tradeif close-tradeprice(1) > StartTrailingStopValue*pointsize thenif 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 levelendifendifendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPendif1 user thanked author for this post.
08/05/2019 at 1:41 PM #104211One more 🙂
1234567891011121314151617181920212223242526272829303132333435enableBreakeven=1 //BESG = 0.25// % break even stop gainBESL = 0 // % break even stop levelunderlaying=0.01if enableBreakeven thenif not onmarket thennewsl=0endifif ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thennewsl=0endifif longonmarket thenif close-tradeprice(1)>=(((tradeprice(1)/100)*BESG)/(underlaying/100))*pointsize thennewsl=tradeprice(1)+(((tradeprice(1)/100)*BESL)/(underlaying/100))*pointsizeendifendifif shortonmarket thenif tradeprice(1)-close>=(((tradeprice(1)/100)*BESG)/(underlaying/100))*pointsize thennewsl=tradeprice(1)-(((tradeprice(1)/100)*BESL)/(underlaying/100))*pointsizeendifendifif longonmarket and newsl>0 thensell at newsl stopendifif shortonmarket and newsl>0 thenexitshort at newsl stopendifendifSET STOP %LOSS 0.4SET TARGET %profit 1set stop ploss 201 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on