Bonjour les amis, y a t il qq un qui peut me corriger ce code sous forme d algorithme et merci :
// ProBackTest ProRealTime
// Algorithme basé sur indicateur Williams %R
// A FG PRODUCTION (c) 2011
// Indicateurs ------------------------------------
indicatorW = Williams[15](close) // Williams %R(15)
indicatorSK = Stochastic[14,3](close) // stochastique %K
indicatorSD = Average[5](Stochastic[14,3](close)) // stochastique %D
indicatorMACDMS = MACDline[12,26,9](close) // MACD - signal
indicatorMACD = MACD[12,26,9](close) // MACD (ligne bleue)
indicatorRSI = RSI[8](close) // RSI
indicatorZigZag = ZigZag[10](close) // ZigZag
indicatorBollingerBas = BollingerDown[20](close) // Courbe basse Bollinger
// Périodes d'analyse
IF Year=2011 THEN
// Conditions ACHAT --------------------------
// A1 --- retournement williams et oscillateurs ----------------------------------------------
// a1A: williams a traversé -80 par le haut aujourd'hui ou ces deux derniers jours
a1A = ((indicatorW CROSSES OVER -80.0) and (indicatorW[1] < -80.0)) or ((indicatorW[1] CROSSES OVER -80.0)
and (indicatorW[2] < -80.0)) or ((indicatorW[2] CROSSES OVER -80.0) and (indicatorW[3] < -80.0))
// a1B: retournement stochastique en cours sans trop être violent
a1Ba = (indicatorSK<indicatorSD) and (abs(indicatorSK - indicatorSD) < abs(indicatorSK[1] - indicatorSD[1]))
a1Bb = (indicatorSK>indicatorSD) and ((indicatorSK[2] < indicatorSD[2]) or (indicatorSK[3] < indicatorSD[3]))
a1B = (indicatorSK < indicatorSD+25) and (a1Ba or a1Bb)
// a1C: williams ne doit pas être déjà trop remonté et doit être montant
a1C = (indicatorW < -20.0) and (indicatorW > indicatorW[1])
// a1D: macd en cours de retournement et montant
a1Da = (indicatorMACDMS<0) and (abs(indicatorMACDMS) < abs(indicatorMACDMS[1])) and (indicatorMACD > indicatorMACD[1])
a1Db = (indicatorMACDMS>0) and (indicatorMACD > indicatorMACD[1]) and (abs(indicatorMACDMS) > abs(indicatorMACDMS[1]))
// a1E: RSI pas trop élevé
a1E = indicatorRSI < 60
A1 = a1A and a1B and a1C and (a1Da or a1Db) and a1E
// A3
// Conditions achat sur chandeliers ------------------------------------
// cours en hausse et pression plus forte à l'achat ces 2 derniers jours OU harami haussier
a3A = (Close > Open and ((High-Close) >= (Open-Low))) or (Close[1] > Open[1] and ((High[1]-Close[1]) >= (Open[1]-Low[1])))
a3B = (abs(Close[1]-Open[1]) < abs(Close[2]-Open[2])) and Open[1]>Close[2] and Open > Close[1]
a3C = (abs(Close[1]-Open[1]) > abs(Close[2]-Open[2])) and Open[1]<Open[2] and Open > Open[2]
A3 = a3A or a3B or a3C
// A4
// Conditions ACHAT sur forte baisse ----------------------------------
// a4A: Williams bas depuis 4 jours
a4A = (indicatorW < -85.0) and (indicatorW[1] < -85.0) and (indicatorW[2] < -85.0) and (indicatorW[3] < -85.0)
// a4B: MACD assez fortement en dessous de son signal et bas
a4B = indicatorMACDMS < -0.8 and indicatorMACD < -2.5
// a4C: Stock%K très bas depuis 3 jours
a4C = indicatorSK < 7.0 and indicatorSK[1] < 7 and indicatorSK[2] < 7.0 and (indicatorSK>indicatorSD)
// RSI bas
a4D = indicatorRSI < 15.0
A4 = (a4A and a4B and a4C and a4D)
// A5
// a5A: zigzag montant
a5A= indicatorZigZag > indicatorZigZag[1]
A5=A5a
// A6: marteau dans un contexte de forte baisse (cours sous ou proche bollinger)
a6A = (abs(Open-Close) < 5/100*abs(High-Low)) and (abs(Low-Open) > 1.5*abs(High-Close))
and (Close < (indicatorBollingerBas+indicatorBollingerBas*0/100))
A6=a6A
// ORDRES ACHAT ------------------------------------------------
// ACHAT à ouverture du lendemain
IF NOT OnMarket THEN
CutBas = (High) - Vstop/100*(High) // stop suiveur paramétrable
IF (A1 and A3 and A5) THEN
BUY 100 %LIQUIDITY AT MARKET NEXTBAROPEN
ELSIF A4 THEN
BUY 100 %LIQUIDITY AT MARKET NEXTBAROPEN
ELSIF A6 THEN
BUY 100 %LIQUIDITY AT MARKET NEXTBAROPEN
ENDIF
ENDIF
// remise à jour du stop suiveur si le cours a monté
IF OnMarket and (Close>Open) THEN
CutBas = (Close) - Vstop/100*(Close)
ENDIF
// positionnement du cours du stop suiveur
SET STOP (CutBas)
// vente si objectif de % de hausse atteint (paramétrable)
IF OnMarket and (Close - ENTRYQUOTE) / (ENTRYQUOTE) > Hstop/100 THEN
SELL AT MARKET
ENDIF
ENDIF // endif de la période d'analyse
Bonjour Md, quel est le problème avec votre algorithme? A la ligne 29 je vois :
IF Year=2011 THEN
Le problème ne vient-il pas de là tout simplement ? car toutes les conditions de l’algorithme ne sont exécutés que si il est exécuté en 2011 🙂
Bonsoir Mr Nicolas, et merci de votre réponse, mais le probleme persiste meme si vous mettez 2016 ,en donnant Erreur de synthaxe………. sur la ligne:
a1A = ((indicatorW CROSSES OVER -80.0) and (indicatorW[1] < -80.0)) or ((indicatorW[1] CROSSES OVER -80.0)
and (indicatorW[2] < -80.0)) or ((indicatorW[2] CROSSES OVER -80.0) and (indicatorW[3] < -80.0))
Les erreurs de syntax sont faciles à corriger, l’éditeur de code de ProRealTime souligne en rouge les problèmes. Dans ce cas présent, c’est simplement un mauvais ‘retour chariot’, l’expression n’est pas finit et on renvoi à la ligne suivante.. alors que la condition a1A doit être complète avec la ligne du dessous. Une ligne de code ne peut commencer par “and”, si il n’y a pas de code avant, l’interpréteur ne comprendra pas la phrase et indiquera qu’il s’agit d’une erreur de syntaxe ou de “typo” ou encore de frappe…
Il y a d’autres erreurs de ce type dans le code et aussi des variables manquantes que j’ai ajouté en début de code (celles-ci étant donc à paramétrer vous même, j’ai tenté d’en expliquer les fonctions dans les commentaires).
Voici le code complet corrigé :
//nouvelles variables
vstop = 3 //% de stop trailing
ENTRYQUOTE = 101 //prix d'entrée paramètrable
hstop = 5 //% de variation entre le entryquote et le close actuel
// Indicateurs ------------------------------------
indicatorW = Williams[15](close) // Williams %R(15)
indicatorSK = Stochastic[14,3](close) // stochastique %K
indicatorSD = Average[5](Stochastic[14,3](close)) // stochastique %D
indicatorMACDMS = MACDline[12,26,9](close) // MACD - signal
indicatorMACD = MACD[12,26,9](close) // MACD (ligne bleue)
indicatorRSI = RSI[8](close) // RSI
indicatorZigZag = ZigZag[10](close) // ZigZag
indicatorBollingerBas = BollingerDown[20](close) // Courbe basse Bollinger
// Périodes d'analyse
// Conditions ACHAT --------------------------
// A1 --- retournement williams et oscillateurs ----------------------------------------------
// a1A: williams a traversé -80 par le haut aujourd'hui ou ces deux derniers jours
a1A = ((indicatorW CROSSES OVER -80.0) and (indicatorW[1] < -80.0)) or ((indicatorW[1] CROSSES OVER -80.0) and (indicatorW[2] < -80.0)) or ((indicatorW[2] CROSSES OVER -80.0) and (indicatorW[3] < -80.0))
// a1B: retournement stochastique en cours sans trop être violent
a1Ba = (indicatorSK<indicatorSD) and (abs(indicatorSK - indicatorSD) < abs(indicatorSK[1] - indicatorSD[1]))
a1Bb = (indicatorSK>indicatorSD) and ((indicatorSK[2] < indicatorSD[2]) or (indicatorSK[3] < indicatorSD[3]))
a1B = (indicatorSK < indicatorSD+25) and (a1Ba or a1Bb)
// a1C: williams ne doit pas être déjà trop remonté et doit être montant
a1C = (indicatorW < -20.0) and (indicatorW > indicatorW[1])
// a1D: macd en cours de retournement et montant
a1Da = (indicatorMACDMS<0) and (abs(indicatorMACDMS) < abs(indicatorMACDMS[1])) and (indicatorMACD > indicatorMACD[1])
a1Db = (indicatorMACDMS>0) and (indicatorMACD > indicatorMACD[1]) and (abs(indicatorMACDMS) > abs(indicatorMACDMS[1]))
// a1E: RSI pas trop élevé
a1E = indicatorRSI < 60
A1 = a1A and a1B and a1C and (a1Da or a1Db) and a1E
// A3
// Conditions achat sur chandeliers ------------------------------------
// cours en hausse et pression plus forte à l'achat ces 2 derniers jours OU harami haussier
a3A = (Close > Open and ((High-Close) >= (Open-Low))) or (Close[1] > Open[1] and ((High[1]-Close[1]) >= (Open[1]-Low[1])))
a3B = (abs(Close[1]-Open[1]) < abs(Close[2]-Open[2])) and Open[1]>Close[2] and Open > Close[1]
a3C = (abs(Close[1]-Open[1]) > abs(Close[2]-Open[2])) and Open[1]<Open[2] and Open > Open[2]
A3 = a3A or a3B or a3C
// A4
// Conditions ACHAT sur forte baisse ----------------------------------
// a4A: Williams bas depuis 4 jours
a4A = (indicatorW < -85.0) and (indicatorW[1] < -85.0) and (indicatorW[2] < -85.0) and (indicatorW[3] < -85.0)
// a4B: MACD assez fortement en dessous de son signal et bas
a4B = indicatorMACDMS < -0.8 and indicatorMACD < -2.5
// a4C: Stock%K très bas depuis 3 jours
a4C = indicatorSK < 7.0 and indicatorSK[1] < 7 and indicatorSK[2] < 7.0 and (indicatorSK>indicatorSD)
// RSI bas
a4D = indicatorRSI < 15.0
A4 = (a4A and a4B and a4C and a4D)
// A5
// a5A: zigzag montant
a5A= indicatorZigZag > indicatorZigZag[1]
A5=A5a
// A6: marteau dans un contexte de forte baisse (cours sous ou proche bollinger)
a6A = (abs(Open-Close) < 5/100*abs(High-Low)) and (abs(Low-Open) > 1.5*abs(High-Close)) and (Close < (indicatorBollingerBas+indicatorBollingerBas*0/100))
A6=a6A
// ORDRES ACHAT ------------------------------------------------
// ACHAT à ouverture du lendemain
IF NOT OnMarket THEN
CutBas = (High) - Vstop/100*(High) // stop suiveur paramétrable
IF (A1 and A3 and A5) THEN
BUY 100 SHARES AT MARKET NEXTBAROPEN
ELSIF A4 THEN
BUY 100 SHARES AT MARKET NEXTBAROPEN
ELSIF A6 THEN
BUY 100 SHARES AT MARKET NEXTBAROPEN
ENDIF
ENDIF
// remise à jour du stop suiveur si le cours a monté
IF OnMarket and (Close>Open) THEN
CutBas = (Close) - Vstop/100*(Close)
ENDIF
// positionnement du cours du stop suiveur
SET STOP LOSS CutBas
// vente si objectif de % de hausse atteint (paramétrable)
IF OnMarket and (Close - ENTRYQUOTE) / (ENTRYQUOTE) > Hstop/100 THEN
SELL AT MARKET
ENDIF
Merci Mr Nicolas de votre aide ,c est sympa de votre part
De rien, j’espère que cela vous aidera! 😉
Bonjour a toi, sur que outil utilise ce code?
Bonjour,
le code fonctionne effectivement.
Mais sur quel support l’utiliser ?
Sur les indices actions ça ne donne rien, pas plus sur les paires du forex que j’ai testées…
Je suppose qu’il s’agit d’une version “bêta”.