J’ai déplacé votre demande sur le forum ProOrder, car il s’agit d’une stratégie.
Il s’agit de l’indicateur modifié de manière à n’imprimer que les flèches ROUGE et VERTE. J’ai également joint le fichier PRC_2B Reversal Pattern(1).itf. :
//-------------------------------------------------------------------//
//PRC_2B Reversarl Pattern(1)
//version = 0
//27.06.2024
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//-------------------------------------------------------------------//
//-----Inputs--------------------------------------------------------//
//prd=20
//maxi=10
//mini=3
src1 = low
src2 = high
//-------------------------------------------------------------------//
//-----Pivot Point Calculation---------------------------------------//
//-----pivots low
if src1 > src1[prd] and lowest[prd](src1) > src1[prd] and src1[prd] < lowest[prd](src1)[prd+1] then
pl=low[prd]
plL=barindex[prd]
//drawpoint(barindex[prd],low[prd],2)coloured("red",90)
endif
//-----pivots high
if src2 < src2[prd] and highest[prd](src2)<src2[prd] and src2[prd]>highest[prd](src2)[prd+1] then
ph=high[prd]
phL=barindex[prd]
//drawpoint(barindex[prd],high[prd],2)coloured("blue",90)
endif
//-------------------------------------------------------------------//
//-----Pattern Detection---------------------------------------------//
//-----Calculate price level to check breakout down
if close crosses over ph then
bomin=low
bominL=barindex
//drawsegment(phL,ph,bominL,ph)style(dottedline)
//drawpoint(phL,ph,1)coloured("white")
ph=undefined
endif
//-----Calculate price level to check breakout up
if close crosses under pl then
bomax=high
bomaxL=barindex
//drawsegment(plL,pl,bomaxL,pl)style(dottedline)
//drawpoint(plL,pl,1)coloured("white")
pl=undefined
endif
//-----Breakout down confirmation
atr=averagetruerange[14](close)
if close crosses under bomin and barindex-bominL<=maxi and barindex-bominL>=mini then
//drawsegment(bominL,bomin,barindex,bomin)coloured(242,54,69)style(line,2)
drawtext("▼",barindex,high+atr*0.999,dialog,bold,20)coloured("Red")
bomin=0
endif
//-----Breakout up confirmation
if close crosses over bomax and barindex-bomaxL<=maxi and barindex-bomaxL>=mini then
//drawsegment(bomaxL,bomax,barindex,bomax)coloured(108,229,160)style(line,2)
drawtext("▲",barindex,low-atr*0.999,dialog,bold,20)coloured("Green")
bomax=0
endif
//-----Restart price level y cross is to late/soon
if close crosses over bomax then
bomax=0
elsif close crosses under bomin then
bomin=0
endif
//-------------------------------------------------------------------//
return
Voici la stratégie que vous avez demandée (avec le code simplement appelé strategie2b.itf) :
//-------------------------------------------------------------------//
//PRC_2B Reversarl Pattern
//version = 0
//27.06.2024
//Iván González @ www.prorealcode.com
//Sharing ProRealTime knowledge
//-------------------------------------------------------------------//
//-----Inputs--------------------------------------------------------//
ONCE Capital = 100000
ONCE LotSize = 1
ONCE prd = 20
ONCE maxi = 10
ONCE mini = 3
Risk = Capital / 100 // 1% risk
SL = Risk / PipValue / PipSize / LotSize
src1 = low
src2 = high
//-------------------------------------------------------------------//
//-----Pivot Point Calculation---------------------------------------//
//-----pivots low
if src1 > src1[prd] and lowest[prd](src1) > src1[prd] and src1[prd] < lowest[prd](src1)[prd+1] then
pl=low[prd]
plL=barindex[prd]
//drawpoint(barindex[prd],low[prd],2)coloured("red",90)
endif
//-----pivots high
if src2 < src2[prd] and highest[prd](src2)<src2[prd] and src2[prd]>highest[prd](src2)[prd+1] then
ph=high[prd]
phL=barindex[prd]
//drawpoint(barindex[prd],high[prd],2)coloured("blue",90)
endif
//-------------------------------------------------------------------//
//-----Pattern Detection---------------------------------------------//
//-----Calculate price level to check breakout down
if close crosses over ph then
bomin=low
bominL=barindex
//drawsegment(phL,ph,bominL,ph)style(dottedline)
//drawpoint(phL,ph,1)coloured("white")
ph=undefined
endif
//-----Calculate price level to check breakout up
if close crosses under pl then
bomax=high
bomaxL=barindex
//drawsegment(plL,pl,bomaxL,pl)style(dottedline)
//drawpoint(plL,pl,1)coloured("white")
pl=undefined
endif
//-----Breakout down confirmation
atr=averagetruerange[14](close)
if close crosses under bomin and barindex-bominL<=maxi and barindex-bominL>=mini then
//drawsegment(bominL,bomin,barindex,bomin)coloured(242,54,69)style(line,2)
//drawtext("▼",barindex,high+atr*0.999,dialog,bold,20)coloured("Red")
IF Not ShortOnMarket THEN
SELLSHORT LotSize CONTRACTS AT MARKET
StopPrice = high[1] + SL
SET STOP PRICE StopPrice
bomin=0
ENDIF
endif
//-----Breakout up confirmation
if close crosses over bomax and barindex-bomaxL<=maxi and barindex-bomaxL>=mini then
//drawsegment(bomaxL,bomax,barindex,bomax)coloured(108,229,160)style(line,2)
//drawtext("▲",barindex,low-atr*0.999,dialog,bold,20)coloured("Green")
IF Not LongOnMarket THEN
BUY LotSize CONTRACTS AT MARKET
StopPrice = low[1] - SL
SET STOP PRICE StopPrice
bomax=0
ENDIF
endif
//-----Restart price level y cross is to late/soon
if close crosses over bomax then
bomax=0
elsif close crosses under bomin then
bomin=0
endif
//-------------------------------------------------------------------//
//return
graph SL
graphOnPrice StopPrice