Break even coding
Forums › ProRealTime English forum › ProOrder support › Break even coding
- This topic has 21 replies, 4 voices, and was last updated 6 years ago by rmhandel.
Tagged: Break Even, BreakEven
-
-
05/31/2018 at 1:36 AM #7174905/31/2018 at 9:38 PM #7189609/18/2018 at 10:03 AM #80746
hi guys ,
pleae could somebody explain me why this break even i not working . The strategy don´t consider it ? I expect a Kept in profit of 5 point but d0n´t work. thanks in advance
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152//-------------------------------------------------------------------------// Hauptcode : SAR Kauf TOP mit BREAKEVEN 5mi//-------------------------------------------------------------------------// Festlegen der Code-ParameterDEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert// Bedingungen zum Einstieg in Long-Positionenindicator1 = SAR[0.02,0.02,0.2]c1 = (indicator1 CROSSES over close)startBreakeven = 1 //how much pips/points in gain to activate the breakeven function?PointsToKeep = 5 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)//SET STOP PLOSS 10 //first stoploss//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 SHORTONMARKET 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 c1 THENSELLSHORT 1 CONTRACT AT MARKETENDIF// Bedingungen zum Ausstieg von Long-Positionenindicator2 = RSI[14](close)c2 = (indicator2 CROSSES over 30)indicator3 = RSI[14](close)c3 = (indicator3[1] < indicator3)IF c2 AND c3 THENexitshort at marketendif09/18/2018 at 10:24 AM #80749You are going short, you should replace line 27 with
1IF SHORTONMARKET AND (tradeprice(1)-close)>=(startBreakeven*pipsize) THENand line 29 with
1breakevenLevel = tradeprice(1)-PointsToKeep*pipsize09/18/2018 at 10:32 AM #8075009/18/2018 at 11:02 AM #80752I backtested it on DAX, 5-minute TF, calculations are fine.
Keep in mind that 1 pips is way too low, I guess, and orders in real accounts could be rejected because too close to price.
Moreover, I just realized you are using SELL to exit a short trade, while you should use EXITSHORT (SELL is reserved to exit a LONG position).
09/18/2018 at 12:10 PM #80765 -
AuthorPosts
Find exclusive trading pro-tools on
Similar topics: