//+------------------------------------------------------------------+ //| CCI_TRADER.mq4 | //| Copyright © 2009, Victor Chebotariov | //+----[ ICQ ]-------------------------------------------------------+ //| 342-574-15 | //+----[ Phone ]-----------------------------------------------------+ //| +380958965042 | //| +380652707069 | //| +380443609960 | //+----[ Web ]-------------------------------------------------------+ //| http://chebotariov.com | //| http://chebotariov.co.ua | //| http://amero.com.ua | //| http://amero.co.ua | //| http://investmoney.kiev.ua | //| http://riskinvest.kiev.ua | //| http://tetrabourse.com.ua | //| http://tb-unitrade.com.ua | //| http://i-contact.kiev.ua | //| http://srubidom.com | //+----[ E-mail ]----------------------------------------------------+ //| victor@chebotariov.co.ua | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009, Victor Chebotariov" #property link "http://www.chebotariov.com" #define magic 1052009 //---- input parameters extern int period=720; //+------------------------------------------------------------------+ //| CCI_TRADER expert start function | //+------------------------------------------------------------------+ int start() { //---- double val = iCCI(NULL ,0,period,PRICE_TYPICAL,0); int ticket, cnt, total=OrdersTotal(); if(total<1) { if(val>100) { ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,0,0,"CCI_TRADER",magic,0,Green); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } else { Print("Error opening BUY order : ",GetLastError()); return(0); } } else if(val<-100) { ticket=OrderSend(Symbol(),OP_SELL,0.1,Bid,3,0,0,"CCI_TRADER",magic,0,Red); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } else { Print("Error opening SELL order : ",GetLastError()); return(0); } } } for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && // check for opened position OrderSymbol()==Symbol()) // check for symbol { if(OrderType()==OP_BUY) // long position is opened { // should it be closed? if(val<-100) { OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position return(0); // exit } } else // go to short position { // should it be closed? if(val>100) { OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position return(0); // exit } } } } //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Indicator Curves created:
Indicators Used:
Commodity channel index
Custom Indicators Used:
Order Management characteristics:
Checks for the total of open orders
It automatically opens orders when conditions are reached
It Closes Orders by itself
Other Features: