Cci_ea

 

Bonjour,

Après avoir longuement regardé et étudié certains des outils ou somme toute stratégies de ce (merveilleux) forum, il m'est apparu que l'indicateur CCI est souvent utilisé comme un filtre fiable.

Les marques de référence : +100/-100 et 0 sont significatifs. Mais avant d'aller trop loin, commençons par le repère 0.

Dès que ce repère 0 est cassé, le prix va obligatoirement dans la même direction.

Alors serait-il possible de faire un EA (pour mt3 ou mt4) avec les valeurs simples ?

Indicateur :

CCI (10 ou 14 ) (possibilité de changer de période)

FT : M30 ou H1

SL : 20 (externe)

TP : 200 (externe)

TP : 6 (externe)

Règles : Ouverture : franchissement effectué du repère 0

Fermer : avec SL, ou TP, ou TS ou nouveau franchissement effectué du repère 0.

Commençons simplement et en fonction des premiers résultats, nous allons mettre des filtres.

Cette méthode ne veut pas prendre le maximum de pips à risque mais s'assurer de petits trades fiables et avantageux à chaque fois.

Merci à tous pour votre intérêt pour cette demande.

 
BrunoFX:
Bonjour,

Après avoir longuement regardé et étudié certains des outils ou somme toute des stratégies de ce (merveilleux) forum, il m'est apparu que l'indicateur CCI est souvent utilisé comme un filtre fiable.

Les marques de référence : +100/-100 et 0 sont significatifs. Mais avant d'aller trop loin, commençons par le repère 0.

Dès que ce repère 0 est cassé, le prix va obligatoirement dans la même direction.

Alors serait-il possible de faire un EA (pour mt3 ou mt4) avec les valeurs simples ?

Indicateur :

CCI (10 ou 14 ) (possibilité de changer de période)

FT : M30 ou H1

SL : 20 (externe)

TP : 200 (externe)

TP : 6 (externe)

Règles : Ouverture : franchissement effectué du repère 0

Fermer : avec SL, ou TP, ou TS ou nouveau franchissement effectué du repère 0.

Commençons simplement et en fonction des premiers résultats, nous allons mettre des filtres.

Cette méthode ne cherche pas à prendre le maximum de pips à risque mais à s'assurer de petits trades fiables et avantageux à chaque fois.

Merci à tous pour votre intérêt pour cette demande .

Bruno,

Vous voulez dire que si le CCI monte en franchissant le 0 alors c'est un signal d'achat. N'est-ce pas ?

Si le CCI est en baisse et qu'il traverse le zéro, c'est un signal de vente.

C'est bien cela ?

Si oui, alors il semble que je sois capable de le faire.

 

Bonjour Newdigital,

You mean that if CCI is going up crossing the 0 so it is signal to buy. Right?

Si le CCI est en baisse et traverse le zéro, c'est une vente.

C'est bien cela ?

Si oui alors semble je suis capable de le faire.

oui c'est bien cela, voulez vous une image de confirmation ?

Je vous remercie pour votre travail et votre intérêt. Que pensez-vous de cette stratégie ?

 

Nous pouvons également tracer la MA (25) sur le graphique de l'ICC (14), et prendre le même signal mais plus tôt, ou simplement attendre que l'ICC traverse le niveau 0 et confirme la direction.

A mon avis, il est préférable d'utiliser le graphique journalier, il n'est pas aussi bruyant que le graphique 1H.

 

J'ai créé cet EA.

J'essaie de le joindre au message.

Mais je pense que cela devrait être un filtre ou un autre indicateur.

Et t/s = 6 n'est pas une bonne idée je pense.

Quoi qu'il en soit, je l'ai fait.

Il devrait être exact selon vos règles.

Et nous pouvons ajouter tout autre indicateur si nous le voulons.

 
krall:
Nous pouvons également tracer la MA (25) sur le graphique CCI (14), et prendre le même signal mais plus tôt, ou juste attendre que le CCI traverse le niveau 0 et confirme la direction. IMHO il est préférable d'utiliser le graphique quotidien, il est moins bruyant que 1H.

Bonjour Krall,

Merci pour votre intérêt et votre idée.

J'avais pensé a cette possibilité mais comme je l'ai écrit plus haut, commencer avec une ea simple, sans filtre afin de valider les premiers résultats.

 

BrunoFX,

Je ne peux pas l'attacher maintenant donc je poste le code.

J'espère qu'il n'y a pas de bugs.

//+--------------------------------------------------------------------------+

//| CCI_ea.mq4 |

//| code by Newdigital |

//| https://www.forex-tsd.com |

//| using Gordago software |

//| http://www.gordago.com |

//| |

//| 21.02.2006 CCI_ea by idea of BrunoFX |

//| (see the thread |

//| https://www.forex-tsd.com/suggestions-trading-systems/1089-cci_ea.html |

//| |

//+--------------------------------------------------------------------------+

#property copyright "BrunoFX and newdigital"

#property link "https://www.forex-tsd.com"

extern int MAGIC = 976714;

extern string PARAMETERS_TRADE = "PARAMETERS TRADE";

extern double Lots = 0.10;

extern int Slippage = 4;

extern double lStopLoss = 20;

extern double sStopLoss = 20;

extern double lTakeProfit = 200;

extern double sTakeProfit = 200;

extern double lTrailingStop = 6;

extern double sTrailingStop = 6;

extern string PARAMETERS_EXPERT = "PARAMETERS EXPERT";

extern color clOpenBuy = Blue;

extern color clCloseBuy = Aqua;

extern color clOpenSell = Red;

extern color clCloseSell = Violet;

extern color clModiBuy = Blue;

extern color clModiSell = Red;

extern string Name_Expert = "CCI_ea";

extern string PARAMETERS_ALARM = "PARAMETERS ALARM";

extern bool UseSound = True;

extern string NameFileSound = "alert.wav";

extern string PARAMETERS_HOURS = "TRADING HOURS";

extern bool UseHourTrade = True;

extern int FromHourTrade = 8;

extern int ToHourTrade = 18;

extern string PARAMETERS_INDICATOR_ONE = "CCI";

extern int CCIPeriod=14;

void deinit() {

Comment("");

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int start(){

if (UseHourTrade){

if (!(Hour()>=FromHourTrade && Hour()<=ToHourTrade)) {

Comment("Time for trade has not come else!");

return(0);

} else Comment("");

}else Comment("");

if(Bars<100){

Print("bars less than 100");

return(0);

}

if(lStopLoss<10){

Print("StopLoss less than 10");

return(0);

}

if(lTakeProfit<10){

Print("TakeProfit less than 10");

return(0);

}

if(sStopLoss<10){

Print("StopLoss less than 10");

return(0);

}

if(sTakeProfit<10){

Print("TakeProfit less than 10");

return(0);

}

double diCCI0=iCCI(NULL,0,CCIPeriod,PRICE_TYPICAL,1);

double diCCI1=iCCI(NULL,0,CCIPeriod,PRICE_TYPICAL,0);

double diCCI2=iCCI(NULL,0,CCIPeriod,PRICE_TYPICAL,0);

double d3=(0);

double diCCI4=iCCI(NULL,0,CCIPeriod,PRICE_TYPICAL,1);

double diCCI5=iCCI(NULL,0,CCIPeriod,PRICE_TYPICAL,0);

double diCCI6=iCCI(NULL,0,CCIPeriod,PRICE_TYPICAL,0);

double d7=(0);

double diCCI8=iCCI(NULL,0,CCIPeriod,PRICE_TYPICAL,1);

double diCCI9=iCCI(NULL,0,CCIPeriod,PRICE_TYPICAL,0);

double diCCI10=iCCI(NULL,0,CCIPeriod,PRICE_TYPICAL,0);

double d11=(0);

double diCCI12=iCCI(NULL,0,CCIPeriod,PRICE_TYPICAL,1);

double diCCI13=iCCI(NULL,0,CCIPeriod,PRICE_TYPICAL,0);

double diCCI14=iCCI(NULL,0,CCIPeriod,PRICE_TYPICAL,0);

double d15=(0);

if(AccountFreeMargin()<(1000*Lots)){

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

if (!ExistPositions()){

if ((diCCI0=d3)){

OpenBuy();

return(0);

}

if ((diCCI4>diCCI5 && diCCI6<=d7)){

OpenSell();

return(0);

}

}

if (ExistPositions()){

if(OrderType()==OP_BUY){

if ((diCCI8>diCCI9 && diCCI10<=d11)){

CloseBuy();

return(0);

}

}

if(OrderType()==OP_SELL){

if ((diCCI12=d15)){

CloseSell();

return(0);

}

}

}

TrailingPositionsBuy(lTrailingStop);

TrailingPositionsSell(sTrailingStop);

return (0);

}

bool ExistPositions() {

for (int i=0; i<OrdersTotal(); i++) {

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {

return(True);

}

}

}

return(false);

}

void TrailingPositionsBuy(int trailingStop) {

for (int i=0; i<OrdersTotal(); i++) {

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {

if (OrderType()==OP_BUY) {

if (Bid-OrderOpenPrice()>trailingStop*Point) {

if (OrderStopLoss()<Bid-trailingStop*Point)

ModifyStopLoss(Bid-trailingStop*Point);

}

}

}

}

}

}

void TrailingPositionsSell(int trailingStop) {

for (int i=0; i<OrdersTotal(); i++) {

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {

if (OrderType()==OP_SELL) {

if (OrderOpenPrice()-Ask>trailingStop*Point) {

if (OrderStopLoss()>Ask+trailingStop*Point || OrderStopLoss()==0)

ModifyStopLoss(Ask+trailingStop*Point);

}

}

}

}

}

}

void ModifyStopLoss(double ldStopLoss) {

bool fm;

fm = OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);

if (fm && UseSound) PlaySound(NameFileSound);

}

void CloseBuy() {

bool fc;

fc=OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, clCloseBuy);

if (fc && UseSound) PlaySound(NameFileSound);

}

void CloseSell() {

bool fc;

fc=OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, clCloseSell);

if (fc && UseSound) PlaySound(NameFileSound);

}

void OpenBuy() {

double ldLot, ldStop, ldTake;

string lsComm;

ldLot = GetSizeLot();

ldStop = GetStopLossBuy();

ldTake = GetTakeProfitBuy();

lsComm = GetCommentForOrder();

OrderSend(Symbol(),OP_BUY,ldLot,Ask,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenBuy);

if (UseSound) PlaySound(NameFileSound);

}

void OpenSell() {

double ldLot, ldStop, ldTake;

string lsComm;

ldLot = GetSizeLot();

ldStop = GetStopLossSell();

ldTake = GetTakeProfitSell();

lsComm = GetCommentForOrder();

OrderSend(Symbol(),OP_SELL,ldLot,Bid,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenSell);

if (UseSound) PlaySound(NameFileSound);

}

string GetCommentForOrder() { return(Name_Expert); }

double GetSizeLot() { return(Lots); }

double GetStopLossBuy() { return (Bid-lStopLoss*Point);}

double GetStopLossSell() { return(Ask+sStopLoss*Point); }

double GetTakeProfitBuy() { return(Ask+lTakeProfit*Point); }

double GetTakeProfitSell() { return(Bid-sTakeProfit*Point); }
 

Et quelques améliorations concernant la fermeture des ordres.

Nous pouvons maintenant choisir la période de l'ICC pour la fermeture des ordres.

//+--------------------------------------------------------------------------+

//| CCI_ea.mq4 |

//| code by Newdigital |

//| https://www.forex-tsd.com |

//| using Gordago software |

//| http://www.gordago.com |

//| |

//| 21.02.2006 CCI_ea by idea of BrunoFX |

//| (see the thread |

//| https://www.forex-tsd.com/suggestions-trading-systems/1089-cci_ea.html |

//| |

//+--------------------------------------------------------------------------+

#property copyright "BrunoFX and newdigital"

#property link "https://www.forex-tsd.com"

extern int MAGIC = 976714;

extern string PARAMETERS_TRADE = "PARAMETERS TRADE";

extern double Lots = 0.10;

extern int Slippage = 4;

extern double lStopLoss = 20;

extern double sStopLoss = 20;

extern double lTakeProfit = 200;

extern double sTakeProfit = 200;

extern double lTrailingStop = 6;

extern double sTrailingStop = 6;

extern string PARAMETERS_EXPERT = "PARAMETERS EXPERT";

extern color clOpenBuy = Blue;

extern color clCloseBuy = Aqua;

extern color clOpenSell = Red;

extern color clCloseSell = Violet;

extern color clModiBuy = Blue;

extern color clModiSell = Red;

extern string Name_Expert = "CCI_ea";

extern string PARAMETERS_ALARM = "PARAMETERS ALARM";

extern bool UseSound = True;

extern string NameFileSound = "alert.wav";

extern string PARAMETERS_HOURS = "TRADING HOURS";

extern bool UseHourTrade = True;

extern int FromHourTrade = 8;

extern int ToHourTrade = 18;

extern string PARAMETERS_INDICATOR_ONE = "CCI";

extern int CCIPeriod_signal=14;//taking the signal to open buy or sell

extern int CCIPeriod_close_buy=14;

extern int CCIPeriod_close_sell=14;

void deinit() {

Comment("");

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int start(){

if (UseHourTrade){

if (!(Hour()>=FromHourTrade && Hour()<=ToHourTrade)) {

Comment("Time for trade has not come else!");

return(0);

} else Comment("");

}else Comment("");

if(Bars<100){

Print("bars less than 100");

return(0);

}

if(lStopLoss<10){

Print("StopLoss less than 10");

return(0);

}

if(lTakeProfit<10){

Print("TakeProfit less than 10");

return(0);

}

if(sStopLoss<10){

Print("StopLoss less than 10");

return(0);

}

if(sTakeProfit<10){

Print("TakeProfit less than 10");

return(0);

}

double diCCI0=iCCI(NULL,0,CCIPeriod_signal,PRICE_TYPICAL,1);

double diCCI1=iCCI(NULL,0,CCIPeriod_signal,PRICE_TYPICAL,0);

double diCCI2=iCCI(NULL,0,CCIPeriod_signal,PRICE_TYPICAL,0);

double d3=(0);

double diCCI4=iCCI(NULL,0,CCIPeriod_signal,PRICE_TYPICAL,1);

double diCCI5=iCCI(NULL,0,CCIPeriod_signal,PRICE_TYPICAL,0);

double diCCI6=iCCI(NULL,0,CCIPeriod_signal,PRICE_TYPICAL,0);

double d7=(0);

double diCCI8=iCCI(NULL,0,CCIPeriod_close_buy,PRICE_TYPICAL,1);

double diCCI9=iCCI(NULL,0,CCIPeriod_close_buy,PRICE_TYPICAL,0);

double diCCI10=iCCI(NULL,0,CCIPeriod_close_buy,PRICE_TYPICAL,0);

double d11=(0);

double diCCI12=iCCI(NULL,0,CCIPeriod_close_sell,PRICE_TYPICAL,1);

double diCCI13=iCCI(NULL,0,CCIPeriod_close_sell,PRICE_TYPICAL,0);

double diCCI14=iCCI(NULL,0,CCIPeriod_close_sell,PRICE_TYPICAL,0);

double d15=(0);

if(AccountFreeMargin()<(1000*Lots)){

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

if (!ExistPositions()){

if ((diCCI0=d3)){

OpenBuy();

return(0);

}

if ((diCCI4>diCCI5 && diCCI6<=d7)){

OpenSell();

return(0);

}

}

if (ExistPositions()){

if(OrderType()==OP_BUY){

if ((diCCI8>diCCI9 && diCCI10<=d11)){

CloseBuy();

return(0);

}

}

if(OrderType()==OP_SELL){

if ((diCCI12=d15)){

CloseSell();

return(0);

}

}

}

TrailingPositionsBuy(lTrailingStop);

TrailingPositionsSell(sTrailingStop);

return (0);

}

bool ExistPositions() {

for (int i=0; i<OrdersTotal(); i++) {

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {

return(True);

}

}

}

return(false);

}

void TrailingPositionsBuy(int trailingStop) {

for (int i=0; i<OrdersTotal(); i++) {

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {

if (OrderType()==OP_BUY) {

if (Bid-OrderOpenPrice()>trailingStop*Point) {

if (OrderStopLoss()<Bid-trailingStop*Point)

ModifyStopLoss(Bid-trailingStop*Point);

}

}

}

}

}

}

void TrailingPositionsSell(int trailingStop) {

for (int i=0; i<OrdersTotal(); i++) {

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {

if (OrderType()==OP_SELL) {

if (OrderOpenPrice()-Ask>trailingStop*Point) {

if (OrderStopLoss()>Ask+trailingStop*Point || OrderStopLoss()==0)

ModifyStopLoss(Ask+trailingStop*Point);

}

}

}

}

}

}

void ModifyStopLoss(double ldStopLoss) {

bool fm;

fm = OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);

if (fm && UseSound) PlaySound(NameFileSound);

}

void CloseBuy() {

bool fc;

fc=OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, clCloseBuy);

if (fc && UseSound) PlaySound(NameFileSound);

}

void CloseSell() {

bool fc;

fc=OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, clCloseSell);

if (fc && UseSound) PlaySound(NameFileSound);

}

void OpenBuy() {

double ldLot, ldStop, ldTake;

string lsComm;

ldLot = GetSizeLot();

ldStop = GetStopLossBuy();

ldTake = GetTakeProfitBuy();

lsComm = GetCommentForOrder();

OrderSend(Symbol(),OP_BUY,ldLot,Ask,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenBuy);

if (UseSound) PlaySound(NameFileSound);

}

void OpenSell() {

double ldLot, ldStop, ldTake;

string lsComm;

ldLot = GetSizeLot();

ldStop = GetStopLossSell();

ldTake = GetTakeProfitSell();

lsComm = GetCommentForOrder();

OrderSend(Symbol(),OP_SELL,ldLot,Bid,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenSell);

if (UseSound) PlaySound(NameFileSound);

}

string GetCommentForOrder() { return(Name_Expert); }

double GetSizeLot() { return(Lots); }

double GetStopLossBuy() { return (Bid-lStopLoss*Point);}

double GetStopLossSell() { return(Ask+sStopLoss*Point); }

double GetTakeProfitBuy() { return(Ask+lTakeProfit*Point); }

double GetTakeProfitSell() { return(Bid-sTakeProfit*Point); }
 

Salut Newdigital,

Cheer. Quelle efficacité et quelle vitesse.

Je vois dans le script que vous mettez des alarmes et un filtre temps serveur.

En fait tout ce qu'il faut.

Je vais le tester dès demain matin.

Vous êtes le meilleur

 

Je ne peux pas joindre d'image, mais l'EA semble ne pas fonctionner correctement, ouvre des ordres sur presque chaque bougie....

 

Je pensais que la transaction ne serait ouverte qu'une fois, lorsque le CCI franchirait le niveau 0. Regardez le graphique. Pourquoi avons-nous tant de transactions ?