Show your code.
//+------------------------------------------------------------------+ //| #Tens.mq4 | //| Copyright © 2009, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "DE" #property link "dd" #define MAGICMA 17586402 extern double Lots = 0.05; extern int Candles = 3; extern double HighLim = 0.4; extern double MinLim = 0.2; int counter = 0; int counter2 = 0; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ //int init() //{ // return(0); //} //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ //int deinit() //{ // return(0); // } //************************************************************************ int CalculateCurrentOrders(string symbol) { int buys=0,sells=0; //---- for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA) { if(OrderType()==OP_BUY) buys++; if(OrderType()==OP_SELL) sells++; } } //---- return orders volume if(buys>0) return(buys); else return(-sells); } // *********************************************************************** void CheckForOpen() { //if (iCustom(NULL, 0, "@TensA",Candles, HighLim, MinLim,0, 0) == EMPTY_VALUE) //{ //counter++; //Alert(counter); //} //else //{ // counter2++; // Alert("2: " + counter2 + "... " + iCustom(NULL, 0, "@TensA",Candles, HighLim, MinLim,0, 0)); //} int res; if (Close[1] == iCustom(NULL, 0, "@TensA",Candles, HighLim, MinLim, 0,0)) { res = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3 , 0 , 0 , "fd",MAGICMA, 0 , Green); return; } if (Close[1]*(-1) == iCustom(NULL, 0, "@TensA", Candles, HighLim, MinLim, 0 ,0)) { OrderSend(Symbol(), OP_SELL, Lots, Bid, 3 , 0 , 0 , "fd",MAGICMA, 0 , Red); return; } } void CheckForClose() { //Alert("dsds"); for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue; if(OrderType()==OP_BUY) { if(Close[1] == iCustom(NULL, 0, "@TensA", Candles, HighLim, MinLim, 0,0)) OrderClose(OrderTicket(),OrderLots(),Bid,3,White); break; } if(OrderType()==OP_SELL) { if(Close[1]*(-1) == iCustom(NULL, 0, "@TensA", Candles, HighLim, MinLim, 0,0)) OrderClose(OrderTicket(),OrderLots(),Ask,3,White); break; } } } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ void start() { //---- if(Bars<100 || IsTradeAllowed()==false) return; //Alert("888"); //************************** if(CalculateCurrentOrders(Symbol())==0) CheckForOpen(); else CheckForClose(); //***************************** //return(0); } //+------------------------------------------------------------------+
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Just after I have made my custom ind. I start working on EA to check it.
the EA run and made 0 orders...
After debug I saw that iCustom always return the EMPTY_VALUE, except of the first tick.
for conclusion iCustom return the value it should only once at the beginning, then it returns EMPTY_VALUE .
I assume I do something wrong with EA code, but looking over samples of EA I can't find my mistake.
I would appreciate if anyone knows what could be the reason for that.
Thanks all.