Cci_ea

 

Olá,

Depois de olhar longamente e estudar algumas das ferramentas ou estratégias deste (maravilhoso) fórum, pareceu-me que o indicador CCI é freqüentemente usado como um filtro confiável.

Marcas de referência: +100/-100 e 0 são significativas. Mas antes de ir longe demais, vamos começar com a marca de referência 0.

Assim que esta marca de referência 0 for quebrada, o preço vai obrigatoriamente na mesma direção.

Então seria possível fazer uma EA (para mt3 ou mt4)avec dos valores simples?

Indicador:

CCI (10 ou 14 ) (possibilidade de mudança de período)

FT: M30 ou H1

SL: 20 (externo)

TP: 200 (externo)

TP: 6 (externo)

Regras : Aberto : travessia realizada da marca de referência 0

Fechar : com SL, ou TP, ou TS ou nova travessia realizada de marca de referência 0.

Vamos começar de forma simples e de acordo com os primeiros resultados, vamos colocar filtros.

Este método não quer assumir o máximo de pips com risco, mas assegurar-se de pequenos negócios confiáveis e vantajosos a cada vez.

Obrigado a todos por seu interesse por este pedido.

 
BrunoFX:
Olá,

Depois de olhar longamente e estudar algumas das ferramentas ou estratégias deste (maravilhoso) fórum, pareceu-me que o indicador CCI é freqüentemente usado como um filtro confiável.

Marcas de referência: +100/-100 e 0 são significativas. Mas antes de ir longe demais, vamos começar com a marca de referência 0.

Assim que esta marca de referência 0 for quebrada, o preço vai obrigatoriamente na mesma direção.

Então seria possível fazer uma EA (para mt3 ou mt4)avec dos valores simples?

Indicador:

CCI (10 ou 14 ) (possibilidade de mudança de período)

FT: M30 ou H1

SL: 20 (externo)

TP: 200 (externo)

TP: 6 (externo)

Regras : Aberto : travessia realizada da marca de referência 0

Fechar : com SL, ou TP, ou TS ou nova travessia realizada de marca de referência 0.

Vamos começar de forma simples e de acordo com os primeiros resultados, vamos colocar filtros.

Este método não quer assumir o máximo de pips com risco, mas assegurar-se de pequenos negócios confiáveis e vantajosos a cada vez.

Obrigado a todos por seu interesse por este pedido

Bruno,

Você quer dizer que, se a CCI está subindo para cruzar o 0, então é sinal para comprar. Certo?

Se a CCI está diminuindo a tendência e cruzando o zero, ela é vendida.

É isso mesmo?

Se sim, parece que sou capaz de fazer isso.

 

Olá Newdigital,

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

Se a CCI está descendo de tendência e cruzando o zero, ela é vendida.

É isso mesmo?

Se sim, parece que sou capaz de fazer isso.

Sim, é bem isso, você quer uma imagem de confirmação?

Agradeço-lhe por seu trabalho e seu interesse. O que você acha desta estratégia?

 

Também podemos traçar MA (25) no gráfico CCI (14), e tomar o mesmo sinal mas mais cedo, ou apenas esperar até que a CCI cruze o nível 0 e confirme a direção.

IMHO é melhor usar o gráfico diário, não é tão barulhento quanto 1H.

 

Eu criei esta EA.

Tento anexá-lo ao posto.

Mas acho que deveria ser algum filtro ou algum outro(s) indicador(es).

E t/s = 6 não é uma boa idéia, eu acho.

De qualquer forma, eu o fiz.

Deve ser exato, de acordo com suas regras.

E podemos acrescentar qualquer outro indicador, se quisermos.

 
krall:
Também podemos traçar MA (25) no gráfico CCI (14), e tomar o mesmo sinal, mas mais cedo, ou apenas esperar até que a CCI cruze o nível 0 e confirme a direção.IMHO é melhor usar o gráfico diário, não é tão barulhento quanto 1H.

Olá Krall,

Obrigado por seu interesse e por sua idéia.

Eu tinha pensado ter esta possibilidade, mas como a escrevi mais alto, comece com uma simples ea, sem filtro, a fim de validar os primeiros resultados.

 

BrunoFX,

Não posso anexá-lo agora, por isso estou postando o código.

Espero que não haja nenhum bug.

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

//| 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); }
 

E algumas melhorias relativas ao fechamento das encomendas.

Podemos escolher agora o período da CCI para o fechamento das ordens.

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

//| 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); }
 

Olá Newdigital,

Saúde. Qual a eficácia e qual a velocidade.

Vejo no roteiro que você coloca alarmes e um filtro de tempo serveur.

Na verdade, tudo o que é necessário.

Vou testá-lo a partir de amanhã de manhã.

Vocês são os melhores

 

Não consigo anexar imagem, mas a EA parece não funcionar corretamente, abre pedidos em quase todas as velas...

 

Eu pensei que esse comércio seria aberto apenas uma vez, quando a CCI atravessasse o nível 0. Dê uma olhada no gráfico. Por que temos tantos comércios?

Razão: