Cci_ea

 

Hola,

Después de haber mirado y estudiado largamente algunas de las herramientas o algunas estrategias de este (maravilloso) foro, me pareció que el indicador CCI se utiliza a menudo como un filtro fiable.

Las marcas de referencia: +100/-100 y 0 son significativos. Pero antes de ir demasiado lejos vamos a empezar con la marca de referencia 0.

Tan pronto como esta marca de referencia 0 se rompe, el precio va obligatoriamente en la misma dirección.

¿Entonces sería posible hacer un EA (para mt3 o mt4)avec de los valores simples?

Indicador:

CCI (10 o 14 ) (posibilidad de cambiar el periodo)

FT: M30 o H1

SL: 20 (externo)

TP: 200 (externo)

TP: 6 (externo)

Reglas : Abrir : cruce efectuado de la marca de referencia 0

Cierre : con SL, o TP, o TS o nuevo cruce realizado de la marca de referencia 0.

Empecemos simplemente y según los primeros resultados, pondremos filtros.

Este método no quiere tomar el máximo de pips con riesgo sino asegurarse de pequeñas operaciones fiables y ventajosas cada vez.

Gracias con todo para su interés para esta petición

 
BrunoFX:
Hola,

Después de haber mirado y estudiado largamente algunas de las herramientas o estrategias de este (maravilloso) foro, me pareció que el indicador CCI se utiliza a menudo como un filtro fiable.

Las marcas de referencia: +100/-100 y 0 son significativos. Pero antes de ir demasiado lejos vamos a empezar con la marca de referencia 0.

Tan pronto como esta marca de referencia 0 se rompe, el precio va obligatoriamente en la misma dirección.

¿Entonces sería posible hacer un EA (para mt3 o mt4)avec de los valores simples?

Indicador:

CCI (10 o 14 ) (posibilidad de cambiar el periodo)

FT: M30 o H1

SL: 20 (externo)

TP: 200 (externo)

TP: 6 (externo)

Reglas : Abrir : cruce efectuado de la marca de referencia 0

Cierre : con SL, o TP, o TS o nuevo cruce realizado de la marca de referencia 0.

Empecemos simplemente y según los primeros resultados, pondremos filtros.

Este método no quiere tomar el máximo de pips con riesgo sino asegurarse de pequeñas operaciones fiables y ventajosas cada vez.

Gracias a todos por su interés en esta solicitud

Bruno,

Quieres decir que si el CCI está subiendo cruzando el 0 entonces es señal de compra. ¿No es así?

Si el CCI va a la baja y cruza el 0 es señal de venta.

¿Es eso cierto?

Si es así parece que soy capaz de hacerlo.

 

Hola Newdigital,

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

Si el CCI va a la baja y cruza el cero es vender.

¿Es eso cierto?

Si es así parece que soy capaz de hacerlo.

sí es así, ¿quieres una imagen de confirmación?

Te agradezco tu trabajo y tu interés. ¿Qué te parece esta estrategia?

 

También podemos trazar la MA (25) en el gráfico del CCI (14), y tomar la misma señal pero antes, o simplemente esperar hasta que el CCI cruce el nivel 0 y confirme la dirección.

IMHO es mejor usar el gráfico diario, no es tan ruidoso como 1H.

 

He creado este EA.

Intento adjuntarlo al post.

Pero creo que debe ser algún filtro o algún otro indicador (s).

Y t/s = 6 no es buena idea creo.

De todos modos lo hice.

Debe ser exacto de acuerdo a sus reglas.

Y podemos añadir cualquier otro indicador si queremos.

 
krall:
También podemos trazar MA (25) en el gráfico de CCI (14), y tomar la misma señal, pero antes, o simplemente esperar hasta CCI cruzará el nivel 0 y confirma la dirección. IMHO es mejor usar gráfico diario, no es tan ruidoso como 1H.

Hola Krall

Gracias por su interés y su idea.

Yo había pensado tiene esta posibilidad, pero como he escribirlo más alto, empezar con un ea simple, sin filtro con el fin de validar los primeros resultados.

 

BrunoFX,

No puedo adjuntarlo ahora así que estoy publicando el código.

Espero que no haya ningún error.

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

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

Y algunas mejoras relativas al cierre de las órdenes.

Ahora podemos elegir el período de CCI para el cierre de las órdenes.

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

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

Hola Newdigital,

Anímate. Que efectividad y que velocidad.

Veo en el script que pones alarmas y un filtro de tiempo serveur.

De hecho todo lo que es necesario.

Lo probaré a partir de mañana por la mañana.

Usted es el mejor

 

No puedo adjuntar la imagen, pero el EA parece no funcionar correctamente, abre órdenes en casi todas las velas...

 

Pensé que el comercio se abrirá sólo una vez, cuando CCI cruzar el nivel 0. Echa un vistazo al gráfico. ¿Por qué tenemos tantas operaciones?