J’aimerais créer un signal lorsque des bougies Heiken Heishi présentent certaines conditions.
Achat lorsque 2 bougies sont vertes et sans mèche basse
Vente lorsque 2 bougies sont rouges et sans mèche haute..
J’ai essayé ce code mais cela ne donne aucun signal, quelqu’un voit l’erreur ??
haclose=(open+close+low+high)/4
haopen=(haopen[1]+haclose[1])/2
xHigh = Max(haOpen, haClose)
xLow = Min(haOpen, haClose)
hahigh = Max(High,xHigh)
halow = Min(Low,xLow)
if haclose[2]>haopen[2] and haclose[1]>haopen[1] and haopen[2]=halow[2] and haopen[1]=halow[1] then
signal=1
endif
if haclose[2]<haopen[2] and haclose[1]<haopen[1] and haopen[2]=hahigh[2] and haopen[1]=hahigh[1] then
signal=-1
endif
return signal
Il faut à minima une barre d’historique pour ton calcul de bougies Heikin Ashi fonctionne: (on teste donc si le barindex est supérieur à 1)
if barindex>1 then
haclose=(open+close+low+high)/4
haopen=(haopen[1]+haclose[1])/2
xHigh = Max(haOpen, haClose)
xLow = Min(haOpen, haClose)
hahigh = Max(High,xHigh)
halow = Min(Low,xLow)
endif
if haclose[2]>haopen[2] and haclose[1]>haopen[1] and haopen[2]=halow[2] and haopen[1]=halow[1] then
signal=1
endif
if haclose[2]<haopen[2] and haclose[1]<haopen[1] and haopen[2]=hahigh[2] and haopen[1]=hahigh[1] then
signal=-1
endif
return signal
Bonjour,
En partant de l’idée du signal généré par ce code…
Comment puis-je le faire déclencher sur une plage horaire bien définie, par exemple 10h à 12h ???
J’ai essayé “currentHour”, “currentTime”, “Time”, je n’arrive à rien! Soit le “Signal 1” m’affiche toute la plage horaire de 10h à 12h00, soit le “Signal 1” affiche bien la bonne configuration Heikin Ashi mais sûr n’importe quelle plage horaire dans la journée!!!
Si quelqu’un avait une piste à partager, je suis preneur.
Merci
@Alai-n
Pour être sûr de bien comprendre… tu veux que l’indicateur ne soit fonctionnel pour indiquer un signal qu’entre 10h et 12h ?
Mais si c’est dans le cadre d’une stratégie pro-order tu peux simplement utiliser les fonctions “Flatbefore” et “Flatafter” en début de code (ex : Defparam flatbefore = 100000). Ainsi, même si l’indicateur fonctionne H24, la stratégie n’en exploitera les signaux que dans la tranche horaire définie.
Merci pour ta réponse, mais c’est dans le cadre de “Probuilder” que je souhaiterai le faire fonctionner!!!
Si quelqu’un a une idée…
On peut avoir un code comme celui avec l’indication “time”.
signal=0
Ctime = time >= 100000 and time <= 120000
if barindex>1 then
haclose=(open+close+low+high)/4
haopen=(haopen[1]+haclose[1])/2
xHigh = Max(haOpen, haClose)
xLow = Min(haOpen, haClose)
hahigh = Max(High,xHigh)
halow = Min(Low,xLow)
endif
if haclose[2]>haopen[2] and haclose[1]>haopen[1] and haopen[2]=halow[2] and haopen[1]=halow[1] and ctime then
signal=1
endif
if haclose[2]<haopen[2] and haclose[1]<haopen[1] and haopen[2]=hahigh[2] and haopen[1]=hahigh[1] and ctime then
signal=-1
endif
return signal
@Sofitech
Merci beaucoup de ton aide, cela fonctionne enfin…
Vaut mieux un qui sait que dix qui cherchent! Encore merci.
Bonne soirée