salut ;
je veux convertir ce code de cet indicateur pour pouvoir automatiser mes trading apres avec prorealtime
//@version=4
study(“METHOD SIGNALS”, overlay=true)
// author: METHOD
// last updated: 2024-04-23
leftBars = input(2)
rightBars = input(2)
swh = pivothigh(leftBars, rightBars)
swl = pivotlow(leftBars, rightBars)
swh_cond = not na(swh)
hprice = 0.0
hprice := swh_cond ? swh : hprice[1]
le = false
le := swh_cond ? true : le[1] and high > hprice ? false : le[1]
swl_cond = not na(swl)
lprice = 0.0
lprice := swl_cond ? swl : lprice[1]
se = false
se := swl_cond ? true : se[1] and low < lprice ? false : se[1]
// Filter out signals if opposite signal is also on
se_filtered = se and not le
le_filtered = le and not se
// Filter consecutive entries
prev = 0
prev := se_filtered ? 1 : le_filtered ? -1 : prev[1]
se_final = se_filtered and prev[1] == -1
le_final = le_filtered and prev[1] == 1
plotshape(se_final, color=color.blue, text="BUY NOW!", style=shape.triangleup, location=location.belowbar)
plotshape(le_final, color=color.red, text="SELL NOW!", style=shape.triangledown, location=location.abovebar)
alertcondition(se_final, "BUY!", "")
alertcondition(le_final, "SELL!", "")
Bon tard, voici le code pour prorealtime. Merci de vous assurer de partager le code au format correct (pincer le bouton Insérer le code).
//--------------------------------------------------------------//
//PRC_Method Signals
//version = 0
//14.05.24
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//-------------------------------------------------------------//
//----Inputs------------------------------------------//
leftbars=2
rightbars=2
//----------------------------------------------------//
//-----Pivot High&Low---------------------------------//
src1 = low
src2 = high
/////pivots low
if src1 > src1[rightbars] and lowest[rightbars](src1) > src1[rightbars] and src1[rightbars] < lowest[leftbars](src1)[rightbars+1] then
$pivotlowy[z+1] = src1[rightbars]
$pivotlowx[z+1] = barindex[rightbars]
z=z+1
endif
/////pivots high
if src2 < src2[rightbars] and highest[rightbars](src2)<src2[rightbars] and src2[rightbars]>highest[leftbars](src2)[rightbars+1] then
$pivothighy[t+1]=src2[rightbars]
$pivothighx[t+1]=barindex[rightbars]
t=t+1
endif
//----------------------------------------------------//
swh=$pivothighy[t]
swl=$pivotlowy[z]
once hprice=0
if t<>t[1] then
hprice=swh
else
hprice=hprice[1]
endif
once le=0
if t<>t[1] then
le=1
else
if le[1] and high>hprice then
le=0
else
le=le[1]
endif
endif
once lprice=0
if z<>z[1] then
lprice=swl
else
lprice=lprice[1]
endif
once se=0
if z<>z[1] then
se=1
else
if se[1] and low<lprice then
se=0
else
se=se[1]
endif
endif
sefiltered=se and not le
lefiltered=le and not se
once prev=0
if sefiltered then
prev=1
elsif lefiltered then
prev=-1
else
prev=prev[1]
endif
sefinal=sefiltered and prev[1]=-1
lefinal=lefiltered and prev[1]=1
if sefinal then
drawtext("▲",barindex,low)coloured("blue")
elsif lefinal then
drawtext("▼",barindex,high)coloured("red")
endif
//----------------------------------------------------//
return