[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 162

 
igrok2008:
exactly Alpari on demo account and tested NOT traded!!!!! terminal mt4 build 229........ tips!!!!!!
i have an alpari account but i dont trade without stoplosses and takeovers, just the price and after placing orders and position i place stoplosses afterwards
 
todem:
Normalise Stop Loss, Take Profit and Open Price with NormalizeDouble

without normalization IMHO there will be a 130th error, but yes, that's needed too
 
i thought maybe it was something with the currency. i tried both euro and pound. NOTHING TRADES!!!!! anyone can tell me!!!!!!
 
igrok2008:
i thought maybe it was something with the currency. i tried both euro and pound. NOTHING trades!!!!! who can advise me?
my suggestion: take off the SL and TP. instead of 0...
 
igrok2008:
i thought maybe there was something wrong with the currency. tried both euro and pound NOTHING trades!!!!! who can tell us please!!!!!!
ticket1=OrderSend(Symbol(), OP_BUY, Lots, Ask, 10, SL, TP, NULL, MagicNumber);
if (ticket1!=0) {return(0);}
else Print("Не открыт ордер Buy. Ошибка №", GetLastError()); 
     
or just do it this way because you want a lot at once.
 
todem:
i also have an alpari but everything trades without stoplosses and takeovers, just the price and after placing orders and position i place stoplosses next

I set both stop and trawl in the EA at 0 and it still does not trade. I made a copy of the EA, removed stop from the code, trall still does not trade

code of the Expert Advisor without a stop and trall

//+------------------------------------------------------------------+
//|                                                eSvechi+MA_v1.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"


//---- input parameters
extern int       MA=13;
extern double    Lots=0.1;
extern int       StopLoss=100;
extern int       TakeProfit=100;
extern int       MagicNumber=501;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
  
bool CheckOrders(int Type)
{
 bool Result=True;
 for(int i=0;i<OrdersTotal();i++)
  if(OrderSelect(i,SELECT_BY_POS))
   if(OrderMagicNumber()==MagicNumber && OrderSymbol() == Symbol())
      if(OrderType()==Type)
        {
         if(Type==OP_BUY)
           if(!OrderClose(OrderTicket(),OrderLots(),Bid,0))
             Result=False;
         if(Type==OP_SELL)
           if(!OrderClose(OrderTicket(),OrderLots(),Ask,0))
             Result=False;
         } 
        else Result=False;
 return(Result); 
}

// Проверяем наличие закрытой на текущей свече позиции типа Type. Если есть, то возвращает False  
bool CheckExists(int Type)  
{
 bool Result=True;
 for(int i=OrdersHistoryTotal()-1; i>=0;i--)
  if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
   if(OrderMagicNumber()==MagicNumber && OrderSymbol() == Symbol() && OrderCloseTime() >= Time[0] && OrderType() == Type)
    {
     Result=False;
     break;
     }
 return(Result); 
 }
  
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {

        // Узнаем уровень стопов и спрэд
    int Spread = MarketInfo(Symbol(), MODE_SPREAD);
    int StopLevel = MarketInfo(Symbol(), MODE_STOPLEVEL);

        //Рассчитываем значения средних на 0-ом и 1-м баре
    double MA_0 =iMA(NULL, 0, MA,0,1,1,0);    
    double MA_1 =iMA(NULL, 0, MA,0,1,1,1);
    
 //-------------открытие позиции Buy покупка-----------------
 //сравниваем на 1-м баре цену закр. и откр. между собой и с МА, на 0-м баре откр. меньше МА закр. больше МА
    if(
       (Open[0+1]<Close[0+1])&& 
       (Close[0+1]<MA_1)&&
       (Open[0]<MA_0)&&
       (Close[0]>MA_0)
      )
     if(CheckOrders(OP_SELL) && CheckExists(OP_BUY))
      {
       if(!OrderSend(Symbol(), OP_BUY, Lots, Ask, 10, 0, 0, NULL, MagicNumber))
         Print("Не открыт ордер Buy. Ошибка №", GetLastError()); 
       }
    //-------------------Конец блока покупки -------------------
    //-------------Открытие позиции Sell продажа----------------   
    if(
       (Open[0+1]>Close[0+1])&& 
       (Close[0+1]>MA_1)&&
       (Open[0]>MA_0)&&
       (Close[0]<MA_0)
      )
     if(CheckOrders(OP_BUY) && CheckExists(OP_SELL))
      {
       if(!OrderSend(Symbol(), OP_SELL, Lots, Bid, 10, 0, 0, NULL, MagicNumber))
         Print("Не открыт ордер Sell. Ошибка №", GetLastError()); 
       }
//-----------------конец блока продажи ----------------------
   return(0);
  }
//+------------------------------------------------------------------+
 
int OrderOp(int ord,double lot) // открытие ордера бай 
{
   double TP,SL,ticket;
   string ccm="";
   int ticket1;
   j2=autorazmer();
   
   if (ord==OP_BUY) {
   l=NormalizeDouble(MarketInfo(Symbol(), MODE_ASK), MarketInfo(Symbol(), MODE_DIGITS));
   
      ccm="ZZ:"+Period()+" -> BUY";
      ticket1=OrderSend(Symbol(),ord,lot,l,3,0,0,ccm,MG,0,White);
      OrderPrint();
   }
   if (ord==OP_SELL) {
   h=NormalizeDouble(MarketInfo(Symbol(), MODE_BID), MarketInfo(Symbol(), MODE_DIGITS));
   
      ccm="ZZ:"+Period()+" -> sell";
      ticket1=OrderSend(Symbol(),ord,lot,h,3,0,0,ccm,MG,0,White);
      OrderPrint();
   }
   if (ord==OP_BUYSTOP) {
   l=NormalizeDouble(MarketInfo(Symbol(), MODE_ASK), MarketInfo(Symbol(), MODE_DIGITS));
   lo=NormalizeDouble(l+j2*Point,Digits);
      ccm="ZZ:"+Period()+" -> BUYstop";
      ticket1=OrderSend(Symbol(),ord,lot,lo,3,0,0,ccm,MG,0,White);
      OrderPrint();
   }
   if (ord==OP_SELLSTOP) {
   h=NormalizeDouble(MarketInfo(Symbol(), MODE_BID), MarketInfo(Symbol(), MODE_DIGITS));
   ho=NormalizeDouble(h-j2*Point,Digits);
      ccm="ZZ:"+Period()+" -> sellstop";
      ticket1=OrderSend(Symbol(),ord,lot,ho,3,0,0,ccm,MG,0,White);
      OrderPrint();
   }
   return(ticket1);
}
you can use the order opening function for Alpari...
 
error everywhere 131
 

A simple question. Can you tell me who can :)

If I need to put 2 EAs on one tool.

I open two windows in the terminal and bind my bot to each?

It turns out that the 2nd bot, for example, that works with only 1 market order will not be able to open a deal if there are pending deals opened by the 1st bot?

Or the 2nd bot will be able to close trades of the 1st bot if they meet the criteria for closing of the 2nd bot?

 

Hi all...

Could you please tell me how to build path to MetaTrader 4 history files? Like "c:\program files\metatrader 4\history\alpari-classic\"?

I know there is a magic string TerminalPath() which returns the path to the folder where the terminal is loaded from. It's understandable, there's \history}, and then mysterious names of rich offices, which live at my expense. How do I get to them?