Bonjour, comment serait-il possible de créer une alerte du type (+1/-1) lors du test du point médian de l’IFVG dans le code joint?
Du genre low[1] <= MedianIFVG and high[1]>=MedianIFVG (OU) low[1] <= MedianIFVG and close[1]>MedianIFVG
Merci
defparam drawonlastbaronly=true
//dispNum=7
//atrMult=0.25
//showbrokenFvg=0
//-----------------------------------------------//
// Atr calculation
//-----------------------------------------------//
if barindex<=200 and barindex>1 then
atr=averagetruerange[barindex](close)*atrMult
else
atr=averagetruerange[200](close)*atrMult
endif
//-----------------------------------------------//
// FVG Detection
//-----------------------------------------------//
fvgUp=low>high[2] and close[1]>high[2]
fvgDown=high<low[2] and close[1]<low[2]
ctop=max(close,open)
cbot=min(close,open)
if fvgUp and abs(low-high[2])>atr then
$fvgLeft[n+1]=barindex[1]
$fvgTop[n+1]=low
$fvgRight[n+1]=barindex
$fvgBot[n+1]=high[2]
$fvgMid[n+1]=(low+high[2])/2
$fvgDir[n+1]=1
$State[n+1]=0
n=n+1
endif
if fvgDown and abs(low[2]-high)>atr then
$fvgLeft[n+1]=barindex[1]
$fvgTop[n+1]=low[2]
$fvgRight[n+1]=barindex
$fvgBot[n+1]=high
$fvgMid[n+1]=(low[2]+high)/2
$fvgDir[n+1]=-1
$State[n+1]=0
n=n+1
endif
if islastbarupdate then
t1=0
FOR i = n DOWNTO 0 DO
t1=$fvgLeft[i]+1
if t1<barindex then
for j=barindex-t1 downto 0 do
IF $fvgDir[i] = 1 AND cbot[j] < $fvgBot[i] THEN
$invLeft[i] = $fvgLeft[i]
$invTop[i] = $fvgTop[i]
$invRight[i] = barindex[j]
$invBot[i] = $fvgBot[i]
$State[i] = 1
break
ENDIF
IF $fvgDir[i] = -1 AND ctop[j] > $fvgTop[i] THEN
$invLeft[i] = $fvgLeft[i]
$invTop[i] = $fvgTop[i]
$invRight[i] = barindex[j]
$invBot[i] = $fvgBot[i]
$State[i] = 1
break
ENDIF
next
endif
NEXT
count2=0
t2=0
for i=n downto 0 do
t2=$invRight[i]+1
if t2<barindex then
for j=barindex-t2 downto 0 do
if $fvgDir[i] = 1 and $State[i] = 1 and close[j] > $invTop[i] THEN
if count2<dispNum and showbrokenFvg then
drawrectangle($invLeft[i],$invTop[i],$invRight[i],$invBot[i])coloured("green",0)fillcolor("green",10)
drawsegment($invRight[i],$invTop[i],barindex[j],$invTop[i])coloured("yellow",100)style(dottedline)
endif
count2=count2+1
$State[i] = -1
break
endif
if $fvgDir[i] = -1 and $State[i] = 1 and close[j] < $invBot[i] THEN
if count2<dispNum and showbrokenFvg then
drawrectangle($invLeft[i],$invTop[i],$invRight[i],$invBot[i])coloured("red",0)fillcolor("red",10)
drawsegment($invRight[i],$invTop[i],barindex[j],$invTop[i])coloured("yellow",100)style(dottedline)
endif
count2=count2+1
$State[i] = -1
break
endif
next
endif
next
count=0
for i=n downto 0 do
if $State[i] = 1 and count < dispNum then
count=count+1
if $fvgDir[i]=1 then
//drawrectangle($invLeft[i],$invTop[i],$invRight[i],$invBot[i])coloured("green",0)fillcolor("green",50)
drawrectangle($invRight[i],$invTop[i],barindex+10,$invBot[i])coloured("red",0)fillcolor("red",50)
drawsegment($invLeft[i],($invBot[i]+$invTop[i])/2,barindex+10,($invBot[i]+$invTop[i])/2)coloured("white",150)style(dottedline3)
elsif $fvgDir[i]=-1 then
//drawrectangle($invLeft[i],$invTop[i],$invRight[i],$invBot[i])coloured("red",0)fillcolor("red",50)
drawrectangle($invRight[i],$invTop[i],barindex+10,$invBot[i])coloured("green",0)fillcolor("green",50)
drawsegment($invLeft[i],($invBot[i]+$invTop[i])/2,barindex+10,($invBot[i]+$invTop[i])/2)coloured("white",150)style(dottedline3)
endif
endif
next
endif
//-----------------------------------------------//
return