Question for connoisseurs - page 8

 

Good afternoon. In the 'Sensation! A profitable strategy has been found!

Rid posted an EAthis morning. I downloaded it, optimised it a bit and ran it.

It works on a demo account (dax) without any problems (mt4 brok-trade).

I have tested it on real account. Start lot=0.01 or 0.1.

It does not work! Log returns error

2009.06.12 15:17:26 HlopMaster FDAXM9,M1: invalid lots amount for OrderSend function

2009.06.12 15:17:26 HlopMaster FDAXM9,M1: OrderSend()- Error OP_SELLSTOP. op 5087.50000000 sl 0.00000000 tp 0.00000000 4051

//------------------------------------------------------------------

I can not understand why.

The size of the deposit allows you to set a given lot with a reserve. There are no restrictions in the code of the Expert Advisor for the real account.

So what's the problem? Please advise!


 

Here's the source code.

...!!!!!!!!!!!!!!!!!! .........!!!!!!!!!!!!!!!!!

I wonder. When will they remove restrictions on the code? Why can't I post in an open window the code of an EA in its entirety in a specialized forum?

The answer I get instead of "READY LARGE TEXT SIZE" works too well.

Looks like MQ is staffed by a competitor's "Cossacks" who do everything they can to piss off visitors and prevent them from asking the right questions here.



Files:
hlopmaster.mq4  11 kb
 

Here are the pieces of code responsible for calculating the lots:

//------------------------------------------------
double GetMaxLot()// Функция возвращает максимальный обьем 
//открытой позиции.  
{int i;double maxlot;
   for( i=1; i<=OrdersTotal(); i++)         
   {
      if(OrderSelect( i-1, SELECT_BY_POS)==true) 
       {                                   
           if((OrderType()==OP_BUY ||OrderType()==OP_SELL)  && OrderSymbol()==Symbol()
          && maxlot<OrderLots()){ maxlot=OrderLots();}
       }
    }   
return( maxlot);
}
//-----------------------------------------------
double GetMaxLotOrder()
//Функция возвращает максимальный обьем установленных
// стоп ордеров. 
{int i;double maxlot;
   for( i=1; i<=OrdersTotal(); i++)         
   {
      if(OrderSelect( i-1, SELECT_BY_POS)==true) 
       {                                   
           if((OrderType()==OP_BUYSTOP ||OrderType()==OP_SELLSTOP)  &&
           OrderSymbol()==Symbol() && maxlot<OrderLots())
           { maxlot=OrderLots();}
       }
    }   
return( maxlot);
}
//----------------------------------------------
int GetLastTypePos(){
   int i;datetime dt;int type;
      for( i=1; i<=OrdersTotal(); i++)         
      {
         if(OrderSelect( i-1, SELECT_BY_POS)==true) 
          {                                   
              if((OrderType()==OP_BUY ||OrderType()==OP_SELL)  && OrderSymbol()==Symbol() 
              && dt<OrderOpenTime())
              { dt=OrderOpenTime(); type=OrderType();}
          }
       }   
   return( type);
}
//-----------------------------------------------
int DopOrder(double Lots)
{
int type= GetLastTypePos();
   if( type==1){
     op=Bid+ pips*Point;if( SL>0){ sl=Bid;}else{ sl=0;}if( TP>0){ tp= op+ TP*Point;}else{ tp=0;}
     err=OrderSend(Symbol(),OP_BUYSTOP, Lots,NormalizeDouble( op,Digits),3,NormalizeDouble( sl,Digits),
NormalizeDouble( tp,Digits),"FORTRADER.RU",0,0,Red);
     if( err<0){Print("OrderSend()-  Ошибка OP_BUYSTOP. 
                op "+ op+" sl "+ sl+" tp "+ tp+" "+GetLastError());return(-1);}
   }
   if( type==0){
      op=Ask- pips*Point;if( SL>0){ sl=Ask;}else{ sl=0;}if( TP>0){ tp= op- TP*Point;}else{ tp=0;}
      err=OrderSend(Symbol(),OP_SELLSTOP, Lots,NormalizeDouble( op,Digits),3,NormalizeDouble( sl,Digits),
NormalizeDouble( tp,Digits),"FORTRADER.RU",0,0,Red);
      if( err<0){Print("OrderSend()-  Ошибка OP_SELLSTOP. 
                   op "+ op+" sl "+ sl+" tp "+ tp+" "+GetLastError());return(-1);}
   }
return(0);
}
//-------------------------------------------------
int CloseAllPos(int type)
{  int buy=1; int sell=1;
int i, b=0;int ordertiket;
 
 if( type==1)
   {
   while( buy==1)
     {
        buy=0;
        for( i=0; i<OrdersTotal(); i++)
         {
           if(true==OrderSelect( i, SELECT_BY_POS, MODE_TRADES))
           {
           if(OrderType()==OP_BUY && OrderSymbol()==Symbol() ){ buy=1; 
                                  OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);}
           }else{ buy=0;}
         }  
         if( buy==0){return(0);}
      } 
   }
   
   if( type==0)
   {
      while( sell==1)
     {
        sell=0;
        for( i=0; i<OrdersTotal(); i++)
         {
           if(true==OrderSelect( i, SELECT_BY_POS, MODE_TRADES))
           {
           if(OrderType()==OP_SELL && OrderSymbol()==Symbol() ){ sell=1;
                                 OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); }
           }else{ sell=0;}
         }  
         
        if( sell==0){return(0);}
      } 
     }
   return(0);
   }
//--------------------------------------------------------


 
Rita писал(а) >>

Here are the pieces of code that calculate the lots:

The Expert Advisor is not designed to work on a real account. If there is at least one open position on other symbols, then the work logic is broken. Of course, it may be corrected but I, for instance, do not see much sense in doing so.

 
Thank you. Why then is such a strange error returned?
 
Rita писал(а) >>
>> Thank you. Why is such a strange error coming back then?

The error most likely occurs

   if(OrdersTotal()<1){ err= OpenNewOrders();}
   if(OrdersTotal()>0){ TrailStopOrders();}

when calling TrailStopOrders();

Since there are already orders for other symbols. In this case, the EA does not open at all.

However, we have to consider the logic.

It seems that the error occurs somewhere else. But I will not be able to check it. I do not have any open positions.

I can only check it in my mind. And I need my EA to be mine for that.

 
Do you know if there is a system in MT4 to determine pips gained or lost on today's trades at the moment?
 

It's not quite clear what exactly you want. Have a look at this design.

http://www.kimiv.ru/index.php?option=com_remository&Itemid=13&func=fileinfo&id=45

 
Rita, thank you!
 

Good evening. A big problem has arisen. Not really on topic. And very bad timing.

Last night I received an incomprehensible link in my ICQ, which I carelessly clicked.

After that, my computer froze up and a window appeared with the suggestion to send an sms.

I rebooted the computer a few times and it unlocked after 45-50 minutes.

But now I can't get into my WM wallet

Requires some kind of key access code. (The file itself keys is).

I do not know what to do. Who-knib. was in a similar sititsiyu ?

Reason: