ProRealCode - Trading & Coding with ProRealTime™
Bonjour,
je souhaiterai modifier les couleurs de l’indicateur ci-après de la façon suivante :
si hband > hband[1] and lband > band[1] alors la couleur entre lband et hband est bleue et si hband < hband[1] and lband < band[1] alors la couleur entre lband et hband est rouge
merci.
// Original Script > @DonovanWall
// Adapted Version > @guikroth
//////////////////////////////////////////////////////////////////////////
// Settings for 5min chart, BTCUSDC. For Other coin, change the parameters
//////////////////////////////////////////////////////////////////////////
// Color variables
downColorR = 255
downColorG = 69
downColorB = 0
upColorR = 50
upColorG = 205
upColorB = 50
midColorR = 0
midColorG = 191
midColorB = 255
// Source
src = customclose
// Sampling Period
// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
// per = defval=100, minval=1, “Sampling Period”
// Range Multiplier
// mult = defval=3.0, minval=0.1, “Range Multiplier”
// Smooth Average Range
wper = per*2 -1
avrng = exponentialaverage[per](abs(src-src[1]))
smrng = mult * exponentialaverage[wper](avrng)
// Range Filter
rngfilt = src
If src > rngfilt[1] then
If rngfilt[1] > src-smrng then
rngfilt = rngfilt[1]
Else
rngfilt = src-smrng
endif
elsif rngfilt[1] < src+smrng then
rngfilt = rngfilt[1]
else
rngfilt = src+smrng
endif
filt = rngfilt
// Filter Direction
upward = 0
If filt > filt[1] then
upward = upward[1]+1
elsif filt < filt[1] then
upward = 0
else
upward = upward[1]
endif
downward = 0
If filt < filt[1] then
downward = downward[1]+1
elsif filt > filt[1] then
downward = 0
else
downward = downward[1]
endif
// Target Bands
hband = filt + smrng
lband = filt – smrng
// Colors
If upward > 0 then
filtcolorR = upColorR
filtcolorG = upColorG
filtcolorB = upColorB
elsif downward > 0 then
filtcolorR = downColorR
filtcolorG = downColorG
filtcolorB = downColorB
else
filtcolorR = midColorR
filtcolorG = midColorG
filtcolorB = midColorB
endif
if src > filt and src > src[1] and upward > 0 then
barcolorR = upColorR
barcolorG = upColorG
barcolorB = upColorB
elsif src > filt and src < src[1] and upward > 0 then
barcolorR = upColorR
barcolorG = upColorG
barcolorB = upColorB
elsif src < filt and src < src[1] and downward > 0 then
barcolorR = downColorR
barcolorG = downColorG
barcolorB = downColorB
elsif src < filt and src > src[1] and downward > 0 then
barcolorR = downColorR
barcolorG = downColorG
barcolorB = downColorB
else
barcolorR = midColorR
barcolorG = midColorG
barcolorB = midColorB
endif
colorbetween(hband,filt,upColorR,upColorG,upColorB,30)
colorbetween(lband,filt,downColorR,downColorG,downColorB,30)
// Break Outs
longCond = (src > filt and src > src[1] and upward > 0) or (src > filt and src < src[1] and upward > 0)
shortCond = (src < filt and src < src[1] and downward > 0) or (src < filt and src > src[1] and downward > 0)
CondIni = 0
If longCond then
CondIni = 1
elsif shortCond then
CondIni = -1
else
CondIni = CondIni[1]
endif
longCondition = longCond and CondIni[1] = -1
shortCondition = shortCond and CondIni[1] = 1
//Alerts
If longCondition then
Drawarrowup(barindex,low-AverageTrueRange[14](close)) coloured(0,255,255)
endif
If shortCondition then
Drawarrowdown(barindex,high+AverageTrueRange[14](close)) coloured(255,255,0)
endif
Return filt style(line,4) coloured(barcolorR,barcolorG,barcolorB,255) as “Range Filter”, hband style(line,2) coloured(upColorR,upColorG,upColorB,100) as “High Target”, lband style(line,2) coloured(downColorR,downColorG,downColorB,100) as “Low Target”
Bonjour
Ajoutez ce bout de code pour voir
//////////////////////////////////////////////////////////////////////////
// Zone de couleurs : selon des conditions
//////////////////////////////////////////////////////////////////////////
alphaZoneUp = 111
alphaZoneDown = 55
if hband > hband[1] and lband > lband[1] then
DRAWTRIANGLE(barindex[0], hband[0], barindex[1] , hband[1] , barindex[0], lband[0]) coloured ( 0,111,255,alphaZoneUp) bordercolor(0,111,255,0)
DRAWTRIANGLE(barindex[0], lband[0], barindex[1] , lband[1] , barindex[1], hband[1]) coloured ( 0,111,255,alphaZoneUp) bordercolor(0,111,255,0)
endif
if hband < hband[1] and lband < lband[1] then
DRAWTRIANGLE(barindex[0], hband[0], barindex[1] , hband[1] , barindex[0], lband[0]) coloured ( 255,64,0,alphaZoneDown) bordercolor(255,64,0,0)
DRAWTRIANGLE(barindex[0], lband[0], barindex[1] , lband[1] , barindex[1], hband[1]) coloured ( 255,64,0,alphaZoneDown) bordercolor(255,64,0,0)
endif
Bonjour,
merci pour ce retour mais cela ne fonctionne pas. La couleur de remplissage entre les deux limites ne change pas.
Le remplissage se fait selon les conditions que tu as demandé
Désactive les lignes : – 112 et 113
//colorbetween(hband,filt,upColorR,upColorG,upColorB,30)
//colorbetween(lband,filt,downColorR,downColorG,downColorB,30)
Augmente les valeurs (max 255) de ces variables : alphaZoneUp et alphaZoneDown
Comme ça
// Original Script > @DonovanWall
// Adapted Version > @guikroth
//////////////////////////////////////////////////////////////////////////
// Settings for 5min chart, BTCUSDC. For Other coin, change the parameters
//////////////////////////////////////////////////////////////////////////
// Color variables
downColorR = 255
downColorG = 69
downColorB = 0
upColorR = 50
upColorG = 205
upColorB = 50
midColorR = 0
midColorG = 191
midColorB = 255
// Source
src = customclose
// Sampling Period
// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
// per = defval=100, minval=1, “Sampling Period”
// Range Multiplier
// mult = defval=3.0, minval=0.1, “Range Multiplier”
// Smooth Average Range
wper = per*2 -1
avrng = exponentialaverage[per](abs(src-src[1]))
smrng = mult * exponentialaverage[wper](avrng)
// Range Filter
rngfilt = src
If src > rngfilt[1] then
If rngfilt[1] > src-smrng then
rngfilt = rngfilt[1]
Else
rngfilt = src-smrng
endif
elsif rngfilt[1] < src+smrng then
rngfilt = rngfilt[1]
else
rngfilt = src+smrng
endif
filt = rngfilt
// Filter Direction
upward = 0
If filt > filt[1] then
upward = upward[1]+1
elsif filt < filt[1] then
upward = 0
else
upward = upward[1]
endif
downward = 0
If filt < filt[1] then
downward = downward[1]+1
elsif filt > filt[1] then
downward = 0
else
downward = downward[1]
endif
// Target Bands
hband = filt + smrng
lband = filt – smrng
// Colors
If upward > 0 then
filtcolorR = upColorR
filtcolorG = upColorG
filtcolorB = upColorB
elsif downward > 0 then
filtcolorR = downColorR
filtcolorG = downColorG
filtcolorB = downColorB
else
filtcolorR = midColorR
filtcolorG = midColorG
filtcolorB = midColorB
endif
if src > filt and src > src[1] and upward > 0 then
barcolorR = upColorR
barcolorG = upColorG
barcolorB = upColorB
elsif src > filt and src < src[1] and upward > 0 then
barcolorR = upColorR
barcolorG = upColorG
barcolorB = upColorB
elsif src < filt and src < src[1] and downward > 0 then
barcolorR = downColorR
barcolorG = downColorG
barcolorB = downColorB
elsif src < filt and src > src[1] and downward > 0 then
barcolorR = downColorR
barcolorG = downColorG
barcolorB = downColorB
else
barcolorR = midColorR
barcolorG = midColorG
barcolorB = midColorB
endif
///colorbetween(hband,filt,upColorR,upColorG,upColorB,30)
///colorbetween(lband,filt,downColorR,downColorG,downColorB,30)
//////////////////////////////////////////////////////////////////////////
// Zone de couleurs : selon des conditions
//////////////////////////////////////////////////////////////////////////
alphaZoneUp = 111
alphaZoneDown = 55
if hband > hband[1] and lband > lband[1] then
DRAWTRIANGLE(barindex[0], hband[0], barindex[1] , hband[1] , barindex[0], lband[0]) coloured ( 0,111,255,alphaZoneUp) bordercolor(0,111,255,0)
DRAWTRIANGLE(barindex[0], lband[0], barindex[1] , lband[1] , barindex[1], hband[1]) coloured ( 0,111,255,alphaZoneUp) bordercolor(0,111,255,0)
endif
if hband < hband[1] and lband < lband[1] then
DRAWTRIANGLE(barindex[0], hband[0], barindex[1] , hband[1] , barindex[0], lband[0]) coloured ( 255,64,0,alphaZoneDown) bordercolor(255,64,0,0)
DRAWTRIANGLE(barindex[0], lband[0], barindex[1] , lband[1] , barindex[1], hband[1]) coloured ( 255,64,0,alphaZoneDown) bordercolor(255,64,0,0)
endif
// Break Outs
longCond = (src > filt and src > src[1] and upward > 0) or (src > filt and src < src[1] and upward > 0)
shortCond = (src < filt and src < src[1] and downward > 0) or (src < filt and src > src[1] and downward > 0)
CondIni = 0
If longCond then
CondIni = 1
elsif shortCond then
CondIni = -1
else
CondIni = CondIni[1]
endif
longCondition = longCond and CondIni[1] = -1
shortCondition = shortCond and CondIni[1] = 1
//Alerts
If longCondition then
Drawarrowup(barindex,low-AverageTrueRange[14](close)) coloured(0,255,255)
endif
If shortCondition then
Drawarrowdown(barindex,high+AverageTrueRange[14](close)) coloured(255,255,0)
endif
Return filt as “Range Filter”, hband as “High Target”, lband as “Low Target”
Peux tu envoyer un graphique avec des annotations de ce que tu souhaites obtenir au final?
* j’ai définie per =100 et mult =3
En fait, ce que je recherche est exactement ce que ton graphique mentionne. Sauf que quand j’intègre tes lignes de code, le rendu n’est pas le même. Je pense que quelque chose m’échappe.
Merci encore pour ton aide sur ce sujet.
// Original Script > @DonovanWall
// Adapted Version > @guikroth
//////////////////////////////////////////////////////////////////////////
// Settings for 5min chart, BTCUSDC. For Other coin, change the parameters
//////////////////////////////////////////////////////////////////////////
// Color variables
downColorR = 255
downColorG = 69
downColorB = 0
upColorR = 50
upColorG = 205
upColorB = 50
midColorR = 0
midColorG = 191
midColorB = 255
// Source
src = customclose
// Sampling Period
// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
per = 100//defval=100, minval=1, "Sampling Period"
// Range Multiplier
mult = 3//defval=3.0, minval=0.1, "Range Multiplier"
// Smooth Average Range
wper = per*2 -1
avrng = exponentialaverage[per](abs(src-src[1]))
smrng = mult * exponentialaverage[wper](avrng)
// Range Filter
rngfilt = src
If src > rngfilt[1] then
If rngfilt[1] > src-smrng then
rngfilt = rngfilt[1]
Else
rngfilt = src-smrng
endif
elsif rngfilt[1] < src+smrng then
rngfilt = rngfilt[1]
else
rngfilt = src+smrng
endif
filt = rngfilt
// Filter Direction
upward = 0
If filt > filt[1] then
upward = upward[1]+1
elsif filt < filt[1] then
upward = 0
else
upward = upward[1]
endif
downward = 0
If filt < filt[1] then
downward = downward[1]+1
elsif filt > filt[1] then
downward = 0
else
downward = downward[1]
endif
// Target Bands
hband = filt + smrng
lband = filt - smrng
// Colors
If upward > 0 then
filtcolorR = upColorR
filtcolorG = upColorG
filtcolorB = upColorB
elsif downward > 0 then
filtcolorR = downColorR
filtcolorG = downColorG
filtcolorB = downColorB
else
filtcolorR = midColorR
filtcolorG = midColorG
filtcolorB = midColorB
endif
if src > filt and src > src[1] and upward > 0 then
barcolorR = upColorR
barcolorG = upColorG
barcolorB = upColorB
elsif src > filt and src < src[1] and upward > 0 then
barcolorR = upColorR
barcolorG = upColorG
barcolorB = upColorB
elsif src < filt and src < src[1] and downward > 0 then
barcolorR = downColorR
barcolorG = downColorG
barcolorB = downColorB
elsif src < filt and src > src[1] and downward > 0 then
barcolorR = downColorR
barcolorG = downColorG
barcolorB = downColorB
else
barcolorR = midColorR
barcolorG = midColorG
barcolorB = midColorB
endif
//colorbetween(hband,filt,upColorR,upColorG,upColorB,30)
//colorbetween(lband,filt,downColorR,downColorG,downColorB,30)
// Break Outs
longCond = (src > filt and src > src[1] and upward > 0) or (src > filt and src < src[1] and upward > 0)
shortCond = (src < filt and src < src[1] and downward > 0) or (src < filt and src > src[1] and downward > 0)
CondIni = 0
If longCond then
CondIni = 1
elsif shortCond then
CondIni = -1
else
CondIni = CondIni[1]
endif
longCondition = longCond and CondIni[1] = -1
shortCondition = shortCond and CondIni[1] = 1
//Alerts
If longCondition then
Drawarrowup(barindex,low-AverageTrueRange[14](close)) coloured(0,255,255)
endif
If shortCondition then
Drawarrowdown(barindex,high+AverageTrueRange[14](close)) coloured(255,255,0)
endif
//////////////////////////////////////////////////////////////////////////
// Zone de couleurs : selon des conditions
//////////////////////////////////////////////////////////////////////////
if hband > hband[1] and lband > lband[1] then
red=0
green=0
blue=255
elsif hband < hband[1] and lband < lband[1] then
red=255
green=0
blue=0
else
red=255
green=255
blue=255
endif
colorbetween(lband,hband,red,Green,Blue,30)
Return filt style(line,4) coloured(barcolorR,barcolorG,barcolorB,255) as "Range Filter", hband style(line,2) coloured(upColorR,upColorG,upColorB,100) as "High Target", lband style(line,2) coloured(downColorR,downColorG,downColorB,100) as "Low Target"
Merci à tous les deux.
je testerai ce soir.
Bonne soirée.
Bonsoir,
cela fonctionne correctement (voir pièce jointe).
Néanmoins, je m’interroge sur la possibilité de lisser les hausses et les baisses de façon à éviter des zones sans remplissage.
Merci.
Rebonjour,
pour illustrer mon propos j’ai fait un scan du rendu que j’aimerai avoir.
Peut-être coder un lissage ? Mais je ne sais pas quel paramètre prendre.
Merci pour votre aide.
Essayez avec cette approche simplifiée.
//// v1.1 ///////////////////////////////////////////////////////////////
//// Zone de couleurs : selon des conditions
////////////////////////////////////////////////////////////////////////////
mbTendance = ( Average[9](filt) + filt)/2
if mbTendance > mbTendance[1] then
red=0
green=0
blue=255
elsif mbTendance < mbTendance[1] then
red=255
green=0
blue=0
endif
colorbetween(lband,hband,red,Green,Blue,88)
Return filt style(line,4) coloured(barcolorR,barcolorG,barcolorB,255) as "Range Filter", hband style(line,2) coloured(upColorR,upColorG,upColorB,100) as "High Target", lband style(line,2) coloured(downColorR,downColorG,downColorB,100) as "Low Target"
PK. merci. Je vais tester ce soir.
Bonjour.
Testé avec succès.
merci.
Modification color between
This topic contains 14 replies,
has 3 voices, and was last updated by finplus
1 year, 3 months ago.
| Forum: | ProBuilder : Indicateurs & Outils Personnalisés |
| Language: | French |
| Started: | 11/16/2024 |
| Status: | Active |
| Attachments: | 3 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.