Forums › ProRealTime English forum › ProBuilder support › Support and resistance zones with variables arrays › Reply To: Support and resistance zones with variables arrays
04/14/2020 at 7:28 PM
#126151
I don’t really get your point 1. My array is not sorted, so if I want to compare one item with all items, I can’t do z=x, otherwise you compare only with smaller and smaller items.
On the other hand, your second point seems indeed to solve the issue, thx I wouldn’t have found it!!!
Now the point I would like to improve is around the fractal, to filter the reversal points and retain only the most relevant one… Would need your help on that too;)
I’m noticing also that the most recent overlap is sometimes blinking with each new change of price, weird…
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
DEFPARAM DRAWONLASTBARONLY =TRUE defparam calculateonlastbars=500 barlimit = 400 ATR=averagetruerange[20](close) cp=2 ATRfactor=2 index1=0 index2=0 if high[cp] >= highest[(cp)*2+1](high) and barindex-$TOPx2[max(0,lastset($TOPx2))]>1 then //new fractal high found $TOPy[lastset($TOPy)+1] = high[cp] //store fractal value $TOPx[lastset($TOPx)+1] = barindex[cp] //store fractal barindex //drawpoint(barindex[cp],high[cp],1) coloured(100,75,150) bordercolor (100,75,150) $TOPx2[lastset($TOPx2)+1] = barindex endif if low[cp] <= lowest[(cp)*2+1](low) and barindex-$BOTx2[max(0,lastset($BOTx2))]>1 then //new fractal low found $BOTy[lastset($BOTy)+1] = low[cp] //store fractal value $BOTx[lastset($BOTx)+1] = barindex[cp] //stire fractal barindex //drawpoint(barindex[cp],low[cp],1) coloured(100,75,150) bordercolor (100,75,150) $BOTx2[lastset($BOTx2)+1] = barindex endif if(islastbarupdate and isset($topy[0]) and isset($boty[0])) then //check points in a range of X percent for i = 0 to lastset($TOPy) do //loop through the tops for y = 0 to lastset($BOTy) do //check first top with other tops if y<>i then change=abs($BOTy[y]-$topy[i])//percent range between the 2 tops if change<=ATR/ATRfactor and barindex-$BOTx[y]<barlimit and $topx[i]<>$BOTx[y] then $overlap[index1]=($BOTy[y]+$TOPy[i])/2 $overlapx1[index1]=min($BOTx[y],$TOPx[i]) $overlapx2[index1]=max($BOTx[y],$TOPx[i]) index1=index1+1 endif endif next next endif //test=index1 // drawtext(" #test#",barindex,high+50,SansSerif,standard,10) if islastbarupdate and isset($overlap[0]) then for x=index1 downto 1 do for z=index1 downto 1 do if x=index1 then count=0 endif if x<>z then if abs($overlap[x]-$overlap[z])<ATR then count=count+1 endif endif next if count=0 then $overlapfinal[index2]=$overlap[x] $overlapfinalx1[index2]=$overlapx1[x] $overlapfinalx2[index2]=$overlapx2[x] index2=index2+1 else if index2=0 then $overlapfinal[index2]=$overlap[x] $overlapfinalx1[index2]=$overlapx1[x] $overlapfinalx2[index2]=$overlapx2[x] index2=index2+1 endif for zz = 0 to index2 do if zz=0 then count=0 endif if x<>zz then if abs($overlap[x]-$overlapfinal[zz])<ATR then count=count+1 endif endif next if count=0 then $overlapfinal[index2]=$overlap[x] $overlapfinalx1[index2]=$overlapx1[x] $overlapfinalx2[index2]=$overlapx2[x] index2=index2+1 endif endif next endif if islastbarupdate and isset($overlapfinal[0]) then for x=0 to index2 do if $overlapfinal[x] > close then if highest[barindex-$overlapfinalx2[x]-1](high)<$overlapfinal[x]+ATR/ATRfactor then drawsegment($overlapfinalx1[x],$overlapfinal[x],barindex,$overlapfinal[x]) coloured(0,75,150) STYLE (dottedline,3) drawpoint($overlapfinalx2[x],$overlapfinal[x],2) coloured(0,75,150) bordercolor (0,75,150) endif else if lowest[barindex-$overlapfinalx2[x]-1](low)>$overlapfinal[x]-ATR/ATRfactor then drawsegment($overlapfinalx1[x],$overlapfinal[x],barindex,$overlapfinal[x]) coloured(0,75,150) STYLE (dottedline,3) drawpoint($overlapfinalx2[x],$overlapfinal[x],2) coloured(0,75,150) bordercolor (0,75,150) endif endif //drawsegment($overlapfinalx1[x],$overlapfinal[x],barindex,$overlapfinal[x]) coloured(0,75,150) STYLE (dottedline,3) //drawpoint($overlapfinalx2[x],$overlapfinal[x],2) coloured(0,75,150) bordercolor (0,75,150) next endif //plot the zone return |