EMA crossover with Nicolas' Break even stop loss
- This topic has 19 replies, 3 voices, and was last updated 5 years ago by .
Similar topics:
Forums › ProRealTime English forum › ProOrder support › EMA crossover with Nicolas' Break even stop loss
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).
Hi 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.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
// 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 parameters DEFPARAM CumulateOrders = False // Cumulating positions deactivated DEFPARAM FlatBefore = 230000 DEFPARAM FlatAfter = 211500 EMAfast = 11 EMAslow = 38 //Risk Management Capital = 36000 Risk = 0.01 equity = Capital + StrategyProfit maxrisk = round(equity*Risk) PositionSizeL = abs(round((maxrisk/StopLossL)/PointValue)*pipsize) PositionSizeS = abs(round((maxrisk/StopLossS)/PointValue)*pipsize) // Conditions to enter long positions indicator1 = ExponentialAverage[EMAfast](close) indicator2 = ExponentialAverage[EMAslow](close) c1 = (indicator1 CROSSES OVER indicator2) IF c1 THEN BUY PositionSizeL PERPOINT AT MARKET StopLossL = abs(close - LOWEST[10](Low)) + 1.5 * pointsize set stop loss StopLossL ENDIF // Conditions to exit long positions indicator3 = ExponentialAverage[EMAfast](close) indicator4 = ExponentialAverage[EMAslow](close) c2 = (indicator3 CROSSES UNDER indicator4) IF c2 THEN SELL AT MARKET ENDIF // Conditions to enter short positions indicator5 = ExponentialAverage[EMAfast](close) indicator6 = ExponentialAverage[EMAslow](close) c3 = (indicator5 CROSSES UNDER indicator6) IF c3 THEN SELLSHORT PositionSizeS PERPOINT AT MARKET StopLossS = abs(close - HIGHEST[10](High)) + 1.5 * pointsize set stop loss StopLossS ENDIF // Conditions to exit short positions indicator7 = ExponentialAverage[EMAfast](close) indicator8 = ExponentialAverage[EMAslow](close) c4 = (indicator7 CROSSES OVER indicator8) IF c4 THEN EXITSHORT AT MARKET ENDIF //trailing stop function TrailingStart = AverageTrueRange[10] * pipsize //trailing will start @trailinstart points profit TrailingStep = -2 * pipsize if not onmarket then newsl=0 endif if ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then newsl=0 endif if longonmarket then if close-tradeprice(1)>= TrailingStart then newsl=TRADEPRICE(1) + TrailingStep endif endif if shortonmarket then if tradeprice(1)-close>= TrailingStart then newsl= TRADEPRICE(1) - TrailingStep endif endif if longonmarket and newsl>0 then sell at newsl stop endif if shortonmarket and newsl>0 then exitshort at newsl stop endif |
Hi 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??
Yes, 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.
thanks very much for the clarification!!
Find exclusive trading pro-tools on