Bonjour,
J’ai essayé sans succès de codifier en PRT une formule AFL (Amibroker), au demeurant très simple.
Le problème est que le résultat en PRT ne correspond; je pense que c’est dû au fait qu’il n’y a pas de fonction “tangente hyperbolique” dans PRT, ou bien devrais-je utiliser ATAN (arc tangente)?? Je dois dire que j’ai oublié mes cours de trigonométrie 😉
Voici le code en AFL:
_SECTION_BEGIN(“CCI special”);
specperiod=Param(“CCI_Period”,14,1,100,1);
scaleCCI=StDev(CCI(specperiod),3* specperiod); //scale CCI swing
rbCCI=0.5*(1+tanh(CCI(specperiod)/scaleCCI));
rbCCI=25*rbCCI; //CCIboundto[0,50]
rb=rbCCI;
Plot( rb, “RangeBound_CCI “+ specperiod, ParamColor( “Color”, colorCycle ), ParamStyle(“Style”) );
Plot( 5, “”, colorWhite);
Plot( 20, “”,colorWhite);
_SECTION_END();
Voici mon code en PRT, mais qui ne fonctionne pas:
period=14
scalecci= STD[3*period](cci[period])
rbcci= 0.5*(1+TAN(cci[period]/scalecci ))
rbcci= 25*rbcci
rb= rbcci
return rb as "RB CCI", 5 as "5", 20 as "20"
Merci de toute aide, cher Nicolas.
Carl Vanhaesendonck
Bonjour,
reconstitution de la tangente hyperbolique à partir de l’exponentielle (et supposition que le reste de la traduction de code était ok), image attachée du dow ut jour pour comparer au chart amibroker:
period=14
scalecci= STD[3*period](cci[period])
arg= cci[period]/scalecci
tanharg= (1-exp(-2*arg))/(1+exp(-2*arg))
rbcci= 0.5*(1+tanharg)
rb= 25*rbcci
return rb as "RB CCI", 5 as "5", 20 as "20"
Merci beaucoup – c’est parfait !
ZigoParticipant
Master
The same calculation can be done with SMI (14, 5, 3) for example. The indicator becomes more gentle.
[attachment file=”RB SMI.itf”]
Zigo – thank you and indeed, SMI works well when “rangebounded”. I guess this should be tested for other indicators too.