Forums › ProRealTime forum Français › Support ProScreener › range filter buy & sell › Reply To: range filter buy & sell
09/24/2023 at 2:03 PM
#221511
Hi @finplus
Range Filter Screener
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 |
// Original Script > @DonovanWall // Adapted Version > @guikroth ////////////////////////////////////////////////////////////////////////// // Settings for 5min chart, BTCUSDC. For Other coin, change the parameters ////////////////////////////////////////////////////////////////////////// // Source src = customclose // Sampling Period // Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters // per = defval=100, minval=1, "Sampling Period" // Range Multiplier // mult = defval=3.0, minval=0.1, "Range Multiplier" // Smooth Average Range wper = per*2 -1 avrng = exponentialaverage[per](abs(src-src[1])) smrng = mult * exponentialaverage[wper](avrng) // Range Filter rngfilt = src If src > rngfilt[1] then If rngfilt[1] > src-smrng then rngfilt = rngfilt[1] Else rngfilt = src-smrng endif elsif rngfilt[1] < src+smrng then rngfilt = rngfilt[1] else rngfilt = src+smrng endif filt = rngfilt // Filter Direction upward = 0 If filt > filt[1] then upward = upward[1]+1 elsif filt < filt[1] then upward = 0 else upward = upward[1] endif downward = 0 If filt < filt[1] then downward = downward[1]+1 elsif filt > filt[1] then downward = 0 else downward = downward[1] endif // Break Outs longCond = (src > filt and src > src[1] and upward > 0) or (src > filt and src < src[1] and upward > 0) shortCond = (src < filt and src < src[1] and downward > 0) or (src < filt and src > src[1] and downward > 0) CondIni = 0 If longCond then CondIni = 1 elsif shortCond then CondIni = -1 else CondIni = CondIni[1] endif C1 = longCond and CondIni[1] = -1 C2 = shortCond and CondIni[1] = 1 Screener[C1 or C2](C1 as "Long=1") |