J’essaie de faire un pauvre screener basique 😉
L’idée c’est juste d’avoir 2 moyennes mobiles différentes en weekly. Quand la plus rapide croise la plus longue, on a notre condition.
Je colle mon code :
TIMEFRAME(weekly)
//----------------------------//
// JMA - Jurik Moving Average //
//----------------------------//
// --- parameters
JMASeries = Close
JMAPeriod = 7 // (7 (short), 35 (medium), 175 (long))
JMAPow = 2 // ({ 1..10 })
JMAPhase = 0 // ({-100..100})
// ---
beta = 0.45 * (JMAPeriod - 1) / (0.45 * (JMAPeriod - 1) + 2)
IF JMAPhase < -100 THEN
R = 0.5
ELSIF JMAPhase > 100 THEN
R = 2.5
ELSE
R = 0.01 * JMAPhase + 1.5
ENDIF
IF JMAPow = 1 THEN
alpha = beta
ELSIF JMAPow = 2 THEN
alpha = beta * beta
ELSIF JMAPow = 3 THEN
alpha = beta * beta * beta
ELSIF JMAPow = 4 THEN
alpha = beta * beta * beta * beta
ELSIF JMAPow= 5 THEN
alpha = beta * beta * beta * beta * beta
ELSIF JMAPow = 6 THEN
alpha = beta * beta * beta * beta * beta * beta
ELSIF JMAPow = 7 THEN
alpha = beta * beta * beta * beta * beta * beta * beta
ELSIF JMAPow = 8 THEN
alpha = beta * beta * beta * beta * beta * beta * beta * beta
ELSIF JMAPow = 9 THEN
alpha = beta * beta * beta * beta * beta * beta * beta * beta * beta
ELSIF JMAPow = 10 THEN
alpha = beta * beta * beta * beta * beta * beta * beta * beta * beta
ENDIF
IF BarIndex = 0 THEN
Filt0 = JMASeries
Filt1 = JMASeries
JMA = JMASeries
ELSE
Filt0 = (1 - alpha) * JMASeries + alpha * Filt0[1]
Det0 = (JMASeries - Filt0[0]) * (1 - beta) + beta * Det0[1]
Filt1 = Filt0[0] + R * Det0[0]
Det1 = (Filt1[0] - JMA[1]) * ((1 - alpha) * (1 - alpha)) + (alpha * alpha) * Det1[1]
JMA = JMA[1] + Det1[0]
ENDIF
//------------------------------------------------------------//
// BSF2P - 2-Pole Butterworth Smoothing Filter by John Ehlers //
//------------------------------------------------------------//
// --- parameters
BSF2PSeries = Close
BSF2PPeriod = 16
// ---
a1 = EXP(-1.414 * 3.14159 / BSF2PPeriod)
b1 = 2 * a1 * COS(1.414 * 180 / BSF2PPeriod)
coef2 = b1
coef3 = -a1 * a1
coef1 = (1 - b1 + a1 * a1) / 4
IF BarIndex < 2 THEN
BSF2P = BSF2PSeries
ELSE
BSF2P = coef1 * (BSF2PSeries + 2 * BSF2PSeries[1] + BSF2PSeries[2]) + coef2 * BSF2PSeries[1] + coef3 * BSF2PSeries[2]
ENDIF
//-----------//
// Condition //
//-----------//
Condition = JMA crosses over BSF2P
SCREENER[Condition]
Bon ben quand je lance le screener, j’ai pas mal de résultat, mais c’est tout sauf que je veux 😉
Aucun croisement, rien.
Un truc doit m’échapper mais je vois pas!
JMA et BSF2P dans le screener n’ont pas les mêmes valeurs qu’avec l’indicateur sur un graphique en weekly.
Je suis perplexe.
L’appel à CALL dans le screener fonctionne et me donne une bonne valeur mais quand je copie/colle l’indicateur ça merde. Trop louche sérieux 🙁
I’ve not interpreted / understood your code, but is below okay? Barindex = 0 … means there are no bars??
IF BarIndex = 0 THEN
Filt0 = JMASeries
Filt1 = JMASeries
JMA = JMASeries
ELSE
It’s okay, the index of BarIndex starts to 0. That’s the first bar to the left of the chart.
In fact I have just copied/pasted the code of my indicators in the screener and I have not the same results (wrong ones) than when they are attached on a chart in weekly.
It only works when I use CALL.
It’s very strange.
Post your code with the indicator pasted in (no CALL) and I’m sure somebody will spot the issue?
Nous devrions revenir au français ici encore, Nicolas nous “aura-t-il”! 🙂
Merci GraHal pour le rappel à l’ordre ! 😀
En effet lorsque tu CALL l’indicateur, celui-ci ne doit pas être interprété par le moteur de ProScreener mais par celui de ProBuilder et les résultats peuvent différer. Même si ça ne semble pas être le cas ici, il ne faut pas oublier que ProScreener a une limite de 254 bars d’historique, peu importe le timeframe utilisé.