Hello Guys,
I developed my first EA named (CCI Stoch.)
I solved all problems concerning programming except the code of opening positions.
So, the EA is running on MT4 but with no positions opened and generating 2 errors:
1-unmatched data error (volume limit 2178 at 2016.01.18 22:00 exceeded)
2-CCI Stoch. EA AUDUSD,H1: OrderSend error 130
I want EA to open long position when cci crosses 0 upward and stochastic crosses 50 upward
and open short position when cci crosses 0 downward and stochastic crosses 50 downward
as indicated in the attached photo
This is the EA code :
//±-----------------------------------------------------------------+
//| test1.mq4 |
//| Copyright 2016, MetaQuotes Software Corp. |
//|
//±-----------------------------------------------------------------+
#property copyright “Copyright 2016, MetaQuotes Software Corp.”
#property link
#property version “1.00”
#property strict
//±-----------------------------------------------------------------+
//| Expert Variables |
//±-----------------------------------------------------------------+
extern double TP=100,SL=100,LotSize=0.1;
double Stoch=iStochastic(Symbol(),0,14,3,3,MODE_SMA,1,PRICE_CLOSE,0);
double cci=iCCI(Symbol(),0,14,PRICE_CLOSE,1);
int MagicNum=987876;
//±-----------------------------------------------------------------+
//| Expert initialization function |
//±-----------------------------------------------------------------+
int OnInit()
{
//—
//—
return(INIT_SUCCEEDED);
}
//±-----------------------------------------------------------------+
//| Expert deinitialization function |
//±-----------------------------------------------------------------+
void OnDeinit(const int reason)
{
//—
}
int orderstotal()
{
int cnt=0;
for(int i=0;i<OrdersTotal();i++)
{
int x = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && MagicNum==OrderMagicNumber())
{
(cnt++);
}
}
return(cnt);
}
//±-----------------------------------------------------------------+
//| Expert tick function |
//±-----------------------------------------------------------------+
void OnTick()
{
double stopless=Ask-SLPoint;
double takeprofit=Ask+TPPoint;
if(orderstotal()<1)
{
if(Stoch>50 && cci>0)
{
int y = OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,stopless,takeprofit,NULL,MagicNum,0,clrGreen);
}
}
if(Stoch<50 && cci<0)
{
int z = OrderSend(Symbol(),OP_SELL,LotSize,Ask,3,stopless,takeprofit,NULL,MagicNum,0,clrRed);
}
}
//±-----------------------------------------------------------------+