Need support on this code with breakeven level
Forums › ProRealTime English forum › ProOrder support › Need support on this code with breakeven level
- This topic has 5 replies, 4 voices, and was last updated 6 years ago by rama.
-
-
04/24/2018 at 6:16 AM #69040
Set stop loss 25
set target profit 200
IF NOT ONMARKET THEN
breakevenLevel=0
ENDIF// — BUY SIDE —
//test if the price have moved favourably of “startBreakeven” points already
IF longonmarket AND close-tradeprice>=12*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice+2*pipsize
ENDIFIF longonmarket AND close-tradeprice>=20*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice+10*pipsize
ENDIF******************************************************
The above code is working exactly the way I wanted the problem when I am in profit >= stop loss moves to 10
when the floating profit falls <=20 then stop loss moves to 2. I want to keep the stop loss at 10 once my floating profit was 20 then fallen below 20
04/24/2018 at 10:40 AM #69062Please avoid double posts, thanks, the other copy of this post inserted in another thread has been deleted to keep the potential answers from other users in only one thread (this one) and not split across separate multiple threads. Thanks for your understanding.
04/24/2018 at 10:57 AM #69066To write code, please use the <> “insert PRT code” button, to make code easier to read.
You should post the whole strategy to test it and try to spot any issue.
At first glance I warn you that
1Set stop loss 25will never be executed (at least on forex pairs), you should either write:
123Set stop loss 0.0025 //in Forex pairs, not Dax or oher indeces, it must be a difference in price// orSet stop Ploss 25 //this is 25 pips04/24/2018 at 1:39 PM #69088try this1234567891011121314151617181920// --- BUY SIDE ---//test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENSELL AT breakevenLevel STOPENDIFIF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)-PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENEXITSHORT AT breakevenLevel STOPENDIF// --- end of BUY SIDE ---04/24/2018 at 2:28 PM #69090sorry, mistake. I meant this one:
12345678910111213141516171819202122232425262728startBreakeven = 5 //how much pips/points in gain to activate the breakeven function?PointsToKeep = 3 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)//reset the breakevenLevel when no trade are on marketIF NOT ONMARKET THENbreakevenLevel=0ENDIF// --- BUY SIDE ---//test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENSELL AT breakevenLevel STOPENDIFIF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)-PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENEXITSHORT AT breakevenLevel STOPENDIF// --- end of BUY SIDE ---04/25/2018 at 1:23 AM #69109 -
AuthorPosts
Find exclusive trading pro-tools on