Forums › ProRealTime English forum › ProOrder support › Reversal long › Reply To: Reversal long
10/12/2024 at 11:47 AM
#238900
This is what you just asked:
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 |
DEFPARAM CumulateOrders = False // Cumulating positions deactivated // Define parameters nBars = 20 //20 Period to calculate RangeBars BounceBars = 4 //4 bouce periods rangeMin = 10 * PipSize rangeMax = 80 * PipSize studsThreshold = 10 * PipSize stopLossBuffer = 20 * PipSize emaPeriod = 14 // EMA for exit condition ema14 = ExponentialAverage[emaPeriod](close) // Define the RangeBars calculation highestHigh = highest[nBars](high) lowestLow = lowest[nBars](low) myRange = highestHigh - lowestLow Rangebars = (myRange >= rangeMin) AND (myRange <= rangeMax) Count = 0 lowestBounce = 9999999 IF Rangebars THEN FOR i = 0 TO (nBars - 1) IF (low[i] <> lowestLow) AND (abs(low[i] - lowestLow) <= studsThreshold) THEN Count = Count + 1 lowestBounce = min(lowestBounce,low[i]) ENDIF NEXT ENDIF Bounce = (Count >= BounceBars) // Initialize counter for studs and tracking the lowest bounce IF (close > ema14) AND Not OnMarket AND Bounce THEN BUY 1 Contract at Market StopLoss = lowestBounce - stopLossBuffer SET STOP PRICE StopLoss ENDIF // Exit condition: Close position if price crosses below the EMA14 IF close < ema14 THEN SELL AT MARKET ENDIF // //graphonprice StopLoss AS "Stop Loss" coloured("Red") //graphonprice TradePrice AS "Entry Price" coloured("Blue") //graphonprice lowestBounce |