//PRC_Market Structure Breakers
//version = 0
//15.03.24
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//---------------------Inputs------------------------------
lenght = 20
//----------------------------------------------------------//
//----------------Bullish Breaker---------------------------//
//----------------------------------------------------------//
//-----Calculate pivots high------------------------------------------
if high < high[lenght] and highest[lenght](high)<high[lenght] and high[lenght]>highest[lenght](high)[lenght+1] then
$ph[lastset($ph)+1]=high[lenght]
$phx[lastset($phx)+1]=barindex[lenght]
phcross = 0
endif
//-----Test for bullish market structure--------------------
if close > $ph[max(0,lastset($ph))] and not phcross then
drawsegment($phx[max(0,lastset($phx))],$ph[max(0,lastset($ph))],barindex,$ph[max(0,lastset($ph))])style(line,2)coloured(8,153,129)
//MS Label
if os = -1 then
drawtext("MSS",(barindex+$phx[max(0,lastset($phx))])/2,$ph[max(0,lastset($ph))]+0.25*tr)
else
drawtext("MSB",(barindex+$phx[max(0,lastset($phx))])/2,$ph[max(0,lastset($ph))]+0.25*tr)
endif
$lasty2[lastset($lasty2)+1] = $ph[max(0,lastset($ph))]
$lastx2[lastset($lastx2)+1] = barindex
breakdown = 0
checkup = 0
phcross = 1
os = 1
endif
//------Iterate trough existing bullish structures and test for breaks
if close < $lasty2[max(0,lastset($lasty2))] and open > $lasty2[max(0,lastset($lasty2))] and breakdown=0 then
breakdown = 1
checkup = 1
drawsegment($lastx2[max(0,lastset($lastx2))],$lasty2[max(0,lastset($lasty2))],barindex,$lasty2[max(0,lastset($lasty2))])coloured(242, 54, 69)style(dottedline,2)
drawtext("▼",barindex,high+0.25*tr)coloured("red")
endif
//------Check for support events-------------------------------------
lvl2 = $lasty2[max(0,lastset($lasty2))]
if low < lvl2 and min(close,open)> lvl2 and not checkup then
drawcandle(high,high,low,low)coloured("black",90)
checkup=1
endif
//----------------------------------------------------------//
//----------------Bearish Breaker---------------------------//
//----------------------------------------------------------//
//-----Calculate pivots low------------------------------------------
if low > low[lenght] and lowest[lenght](low) > low[lenght] and low[lenght] < lowest[lenght](low)[lenght+1] then
$pl[lastset($pl)+1] = low[lenght]
$plx[lastset($plx)+1] = barindex[lenght]
plcross = 0
endif
//---------------------------------------------------------
//-----Test for bearish market structure--------------------
if close < $pl[max(0,lastset($pl))] and not plcross then
drawsegment($plx[max(0,lastset($plx))],$pl[max(0,lastset($pl))],barindex,$pl[max(0,lastset($pl))])coloured(242, 54, 69)style(line,2)
//MS Label
if os = 1 then
drawtext("MSS",(barindex+$plx[max(0,lastset($plx))])/2,$pl[max(0,lastset($pl))]-0.25*tr)
else
drawtext("MSB",(barindex+$plx[max(0,lastset($plx))])/2,$pl[max(0,lastset($pl))]-0.25*tr)
endif
$lasty[lastset($lasty)+1]=$pl[max(0,lastset($pl))]
$lastx[lastset($lastx)+1]=barindex
plcross=1
os = -1
breakup=0
checkdw=0
endif
//------Iterate trough existing bearish structures and test for breaks
if close > $lasty[max(0,lastset($lasty))] and open < $lasty[max(0,lastset($lasty))] and breakup=0 then
breakup = 1
checkdw = 1
drawsegment($lastx[max(0,lastset($lastx))],$lasty[max(0,lastset($lasty))],barindex,$lasty[max(0,lastset($lasty))])coloured(8,153,129)style(dottedline,2)
drawtext("▲",barindex,low-0.25*tr)coloured("green")
endif
//------Check for resistance events-------------------------------------
lvl = $lasty[max(0,lastset($lasty))]
if high > lvl and max(close,open)<lvl and not checkdw then
drawcandle(high,high,low,low)coloured("black",90)
checkdw=1
endif
return
Bonjour,
une question stp : comment faire pour prolonger les lignes de Drawsegment sur une période plus longue (par exemple un jour ou une semaine)?
Merci.