[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 161

 
Mopo3:

Yeah, it's called "learn the game", i.e. the language :)


Well I remember that the principle is based on the fact that there were times of 1min. and then to see a period of 20min. data are taken just by 20 bars for 1 minute....

the point is...then I didn't think twice about it...))

 

People! Look at the MA trend change, can anyone help? https://www.mql5.com/ru/forum/131277/page159

 
If it is not difficult to advise which period should be set for Murray levels so it does not lie or for each TF its period. If it has its own period then which ones?
 

Good afternoon!!!!!

Can you tell me where is the mistake...... when compiling no errors, but does not trade in the tester's log eSvechi+MA AUDUSD,H1: OrderSend error 131 and what is the reason - I do not understand

//+------------------------------------------------------------------+
//|                                                   eSvechi+MA.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.01;
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(StopLoss <= StopLevel+Spread)
         double SL = 0;
        else
         SL = Ask - StopLoss*Point;
       if(TakeProfit <= StopLevel-Spread)
         double TP = 0;
        else
         TP = Ask + TakeProfit*Point;
       if(!OrderSend(Symbol(), OP_BUY, Lots, Ask, 10, SL, TP, 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(StopLoss <= StopLevel+Spread)
         SL = 0;
        else
         SL = Bid + StopLoss*Point;
       if(TakeProfit <= StopLevel-Spread)
         TP = 0;
        else
         TP = Bid - TakeProfit*Point;
       if(!OrderSend(Symbol(), OP_SELL, Lots, Bid, 10, SL, TP, NULL, MagicNumber))
         Print("Не открыт ордер Sell. Ошибка №", GetLastError()); 
       }
//-----------------конец блока продажи ----------------------
   return(0);
  }
//+------------------------------------------------------------------+

ERR_INVALID_TRADE_VOLUME 131 Incorrect volume, error in the volume granulation. You need to stop all trading attempts and change the program logic.

The logic seems to be correct.............................................

 
igrok2008:

Good afternoon!!!!!

Can you tell me where is the mistake...... when compiling no errors, but does not trade in the tester's log eSvechi+MA AUDUSD,H1: OrderSend error 131 and what is the reason - I do not understand

ERR_INVALID_TRADE_VOLUME 131 Incorrect volume, error in the volume granulation. You need to stop all trading attempts and change the program logic.

The logic seems to be correct.............................................


Lots should not be less than (+ sort of multiple of) MarketInfo(Symbol(), MODE_MINLOT);

Many traders' programs have 0.1, but yours is 10 times less.

 
ilunga:


Lots must be at least (+ sort of a multiple of) MarketInfo(Symbol(), MODE_MINLOT);

Many traders' programs have 0.1, while you have 10 times less.

AND ALL !!!! The whole catch is this!!!!!!!!! .......... Well what about small depots of 5 -10 bucks???????
 
ilunga:


Lots must be at least (+ sort of a multiple of) MarketInfo(Symbol(), MODE_MINLOT);

Many traders' programs have 0.1, while you have 10 times less.

changed lot to 0.1 still does not trade
 
igrok2008:
changed my lot to 0.1 still not working


ran on InterBank, everything works even with 0.01

Alpari at 0.01 gives error 131, at 0.1 it works

 
ilunga:


ran on InterBank, everything works even with 0.01

Alpari at 0.01 gives error 131, at 0.1 it works

exactly Alpari on demo account and testing does NOT work!!!!! terminal mt4 build 229........ prompt!!!!!!
 
igrok2008:

Good afternoon!!!!!

Can you tell me where is the mistake...... when compiling no errors, but does not trade in the tester's log eSvechi+MA AUDUSD,H1: OrderSend error 131 and what is the reason - I do not understand

ERR_INVALID_TRADE_VOLUME 131 Incorrect volume, error in the volume granulation. You need to stop all trading attempts and change the program logic.

The logic seems to be correct.............................................

Normalise Stop Loss, Take Profit and Open Price with NormalizeDouble