EMA crossover with Nicolas' Break even stop loss
Forums › ProRealTime English forum › ProOrder support › EMA crossover with Nicolas' Break even stop loss
- This topic has 19 replies, 3 voices, and was last updated 4 years ago by
crolakstrading.
-
-
08/10/2019 at 2:48 PM #104524
Can you post the date & time of at least one trade that shows the issue? (from your first pic I can’t tell exactly when).
08/10/2019 at 3:02 PM #104526Hi Roberto,
I actually fixed this code last night see addition at lines 67 to 69 in the below code. However, sadly when accounting for a 2pt spread on the NASDAQ what is a highly profitable strategy becomes a losing strategy. Back to the drawing board then.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788// Intraday trend following strategy. Entries and Exits defined by EMA crossovers. Position size determiend by distance to stop loss and percent of equity at risk. Initial stop loss set at recent swing low or high. Profits are protected by a stoploss that moves to breakeven after a defined number of points// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedDEFPARAM FlatBefore = 230000DEFPARAM FlatAfter = 211500EMAfast = 11EMAslow = 38//Risk ManagementCapital = 36000Risk = 0.01equity = Capital + StrategyProfitmaxrisk = round(equity*Risk)PositionSizeL = abs(round((maxrisk/StopLossL)/PointValue)*pipsize)PositionSizeS = abs(round((maxrisk/StopLossS)/PointValue)*pipsize)// Conditions to enter long positionsindicator1 = ExponentialAverage[EMAfast](close)indicator2 = ExponentialAverage[EMAslow](close)c1 = (indicator1 CROSSES OVER indicator2)IF c1 THENBUY PositionSizeL PERPOINT AT MARKETStopLossL = abs(close - LOWEST[10](Low)) + 1.5 * pointsizeset stop loss StopLossLENDIF// Conditions to exit long positionsindicator3 = ExponentialAverage[EMAfast](close)indicator4 = ExponentialAverage[EMAslow](close)c2 = (indicator3 CROSSES UNDER indicator4)IF c2 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator5 = ExponentialAverage[EMAfast](close)indicator6 = ExponentialAverage[EMAslow](close)c3 = (indicator5 CROSSES UNDER indicator6)IF c3 THENSELLSHORT PositionSizeS PERPOINT AT MARKETStopLossS = abs(close - HIGHEST[10](High)) + 1.5 * pointsizeset stop loss StopLossSENDIF// Conditions to exit short positionsindicator7 = ExponentialAverage[EMAfast](close)indicator8 = ExponentialAverage[EMAslow](close)c4 = (indicator7 CROSSES OVER indicator8)IF c4 THENEXITSHORT AT MARKETENDIF//trailing stop functionTrailingStart = AverageTrueRange[10] * pipsize //trailing will start @trailinstart points profitTrailingStep = -2 * pipsizeif not onmarket thennewsl=0endifif ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thennewsl=0endifif longonmarket thenif close-tradeprice(1)>= TrailingStart thennewsl=TRADEPRICE(1) + TrailingStependifendifif shortonmarket thenif tradeprice(1)-close>= TrailingStart thennewsl= TRADEPRICE(1) - TrailingStependifendifif longonmarket and newsl>0 thensell at newsl stopendifif shortonmarket and newsl>0 thenexitshort at newsl stopendif1 user thanked author for this post.
06/18/2020 at 1:03 PM #136428Hi I’m curious about this.. Where do you place the Stoploss..
StopLossL = abs(close – LOWEST[10](Low)) + 1.5 * pointsize does this meam swing low??
06/18/2020 at 2:09 PM #136437Yes, it’s the lowest low within the last 10 bars, so it could be a swing point (+ 1.5 pips), within 40+ bars would grant a greater accuracy.
1 user thanked author for this post.
06/22/2020 at 7:47 PM #136821thanks very much for the clarification!!
-
AuthorPosts
Find exclusive trading pro-tools on