Cci_ea

 

Здравствуйте,

После длительного просмотра и изучения некоторых инструментов или стратегий этого (замечательного) форума, мне показалось, что индикатор CCI часто используется как надежный фильтр.

Контрольные отметки: +100/-100 и 0 являются значимыми. Но прежде чем заходить слишком далеко, давайте начнем с опорной метки 0.

Как только эта опорная отметка 0 будет пробита, цена обязательно пойдет в том же направлении.

Можно ли тогда сделать советник (для mt3 или mt4) на основе этих простых значений?

Индикатор:

CCI (10 или 14) (возможность изменения периода).

FT: M30 или H1

SL: 20 (внешний)

TP: 200 (внешний)

TP: 6 (внешний)

Правила : Открыть : пересечение контрольной отметки 0

Закрытие : с SL, или TP, или TS или новым пересечением, проведенным через контрольную отметку 0.

Начнем просто и по первым результатам поставим фильтры.

Этот метод не стремится взять максимум пунктов с риском, а хочет обеспечить себя небольшими сделками, надежными и выгодными каждый раз.

Спасибо за проявленный интерес к данному запросу

 
BrunoFX:
Здравствуйте,

После длительного просмотра и изучения некоторых инструментов или стратегий этого (замечательного) форума, мне показалось, что индикатор CCI часто используется как надежный фильтр.

Контрольные отметки: +100/-100 и 0 являются значимыми. Но прежде чем заходить слишком далеко, давайте начнем с опорной метки 0.

Как только эта опорная отметка 0 будет пробита, цена обязательно пойдет в том же направлении.

Можно ли тогда сделать советник (для mt3 или mt4) на основе этих простых значений?

Индикатор:

CCI (10 или 14) (возможность изменения периода).

FT: M30 или H1

SL: 20 (внешний)

TP: 200 (внешний)

TP: 6 (внешний)

Правила : Открыть : пересечение контрольной отметки 0

Закрытие : с SL, или TP, или TS или новым пересечением, проведенным через контрольную отметку 0.

Начнем просто и по первым результатам поставим фильтры.

Этот метод не стремится взять максимум пунктов с риском, а обеспечивает себя небольшими сделками, надежными и выгодными каждый раз.

Благодарим вас за проявленный интерес к данной заявке

Бруно,

Вы имеете в виду, что если CCI идет вверх, пересекая 0, то это сигнал к покупке. Правильно?

Если CCI идет по нисходящему тренду и пересекает ноль, то это сигнал к продаже.

Так ли это?

Если да, то, похоже, я смогу это сделать.

 

Здравствуйте, Newdigital,

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

Если CCI идет по нисходящему тренду и пересекает ноль, то это продажа.

Так ли это?

Если да, то, похоже, я в состоянии это сделать.

Да, это так, хотите изображение подтверждения?

Я благодарю вас за вашу работу и интерес. Что вы думаете об этой стратегии?

 

Мы также можем построить MA (25) на графике CCI (14), и взять тот же сигнал, но раньше, или просто подождать, пока CCI пересечет уровень 0 и подтвердит направление.

ИМХО лучше использовать дневной график, он не такой шумный, как 1H.

 

Я создал этот советник.

Я пытаюсь прикрепить его к сообщению.

Но я думаю, что это должен быть какой-то фильтр или какой-то другой индикатор(ы).

И t/s = 6 не очень хорошая идея, я думаю.

В любом случае, я сделал это.

Это должно быть точно в соответствии с вашими правилами.

И мы можем добавить любой другой индикатор, если захотим.

 
krall:
Мы также можем построить MA (25) на графике CCI (14), и взять тот же сигнал, но раньше, или просто подождать пока CCI пересечет уровень 0 и подтвердит направление. ИМХО лучше использовать дневной график, он не такой шумный как 1H.

Здравствуйте, Крал,

Спасибо за ваш интерес и вашу идею.

Я думал о такой возможности, но как я уже писал выше, начнем с простого ea, без фильтра, чтобы проверить первые результаты.

 

BrunoFX,

Я не могу прикрепить его сейчас, поэтому выкладываю код.

Надеюсь, что ошибок не будет.

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

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

И некоторые улучшения, касающиеся закрытия ордеров.

Теперь мы можем выбирать период CCI для закрытия ордеров.

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

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

Привет Newdigital,

Поднимайте настроение. Какая эффективность и какая скорость.

Я вижу в скрипте, что вы ставите алармы и фильтр time serveur.

Фактически все, что нужно.

Я буду тестировать его завтра утром.

Вы лучший

 

Я не могу прикрепить изображение, но советник, похоже, работает неправильно, открывает ордера почти на каждой свече...

 

Я думал, что сделка будет открыта только один раз, когда CCI пересечет уровень 0. Взгляните на график. Почему у нас так много сделок?

Причина обращения: