[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 562

 
delf:
Hello Dear. Does anyone have any unsophisticated EA with order rotation (buy-sell-buy) in stock. I just need an example of how this option is embedded in the body and what it should actually consist of. Our search did not give us anything understandable for our not too experienced in mql 4: From short

I have this.

#define OrderBuy  0
#define OrderSell 1
int OldOrder;

 

start()

{
... 
... 

if(OldOrder==OrderBuy)

        {
        //...ставить sell
        OldOrder=OrderSell;
        }
  else
        {
        //...ставить buy
        OldOrder=OrderBuy;
        }

....
....

} 
 
peshihod:

I have it like this.

Thank you, it's so simple and straightforward, I'll give it a go
 
delf:
Thank you, it's so simple and straightforward, I'll try it out.
Something's wrong. After Stor Loss it's back to the same direction again.
 
delf:
Something's wrong. After STOPLoss it's back to the same direction.

What's StopLoss?

 

Hello!

Can you tell me which files need to be downloaded and where to install them in mt4 to get this window?

I don't understand how to do it in theSimulation on different timeframes of the instrument under test

I want to see only three daily charts, four-hour and hourly

i want to see three daily, four-hour and hourly charts. Please help, i have not managed to do it all night long!


 
ametist444:

Hello!

Can you tell me which files need to be downloaded and where to install them in mt4 to get this window?

I don't understand how to do it in theSimulation on different timeframes of the instrument under test

I want to see only three daily charts, four-hour and hourly

i want to see only three windows in one timeframe, i want to see only three charts, i want to see only three daily, four-hour and hourly charts.

Do you need to open these windows programmatically from MT4? I`m not sure, I`m not very good at it... :-)

Open a few windows manually and insert the indicator there, not an option?

 

Good evening: Could you please advise how to understand

The amount of margin required for the specified order type in the current account and in the current market environment without taking into account the current pending orders and open positions.

Can you approximate the existing function?

 

I also started using this function instead of a lot

double     Lott  ( double     Lot ){
     if ( risk!=0)  Lot=AccountFreeMargin()*risk/10000 ; return (Lot);}  

OrderSend error 131 - wrong volume. With initial deposit 10000 initial lot 1. However, something does not work...

 

For some time I have been trying to rework the buy close block to close only the last two buy positions, but it fails. Can you tell how to redo the block ?

void Close_2buy()
{
   bool   result;
  double  close_price;
  int    cmd,error;
  bool close;

      for (int f=OrdersTotal()-1; f>=0; f--) // 
      {
         OrderSelect(f, SELECT_BY_POS);
         if (OrderSymbol()==Symbol() &&(OrderMagicNumber()==magic ) 
         && (OrderType() == OP_BUY )) 
         {
            close = False;
            {
               close_price = MarketInfo(OrderSymbol(), MODE_BID);
               close = True;
            }
               
            if (close) 
            {
               result=OrderClose(OrderTicket(), OrderLots(), close_price, 0, CLR_NONE);
               if(result!=TRUE)
               {error=GetLastError();Print("LastError = ", error);}
            }
            
         }
      }
}
 
Dimka-novitsek:

I also started using this function instead of a lot

OrderSend error 131 - wrong volume. With initial deposit 10000 initial lot 1. However, something does not work...


I use this. modify it for you and try (change AccountBalance() to AccountFreeMargin(), put your variable. LotsDigits)
//+------------------------------------------------------------------+
//|                                                         0000.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
////////////////////////////////////////////////////////////////////////|
extern int     Method         =1;      // Метод: 0-FixedLots, 1-часть //|
                                       //(Risk) от свободных средств  //|
                                       // нормированных по значению   //|
                                       // MeansStep(например Risk=    //|
                                       // 0.01,MeansStep=1000,если    //|
                                       // средств меньше 2000,лот     //|
                                       // равен 0.01,если средств     //|
                                       // стало 2000 или более - 0.02 //|
                                       // лота, 3000 или более - 0.03 //|
                                       // лота и т.д.).               //|
                                                                      //|
extern double  LOTS           =0.01;   // Количество лотов при        //|
                                       // Method=0.                   //|
                                                                      //|
extern double  Risk           =0.01;   // Риск. Часть от средств при  //|
                                       // FixedLot=false.             //|
                                                                      //|
extern double  MeansStep      =100.0;  // Шаг средств. Используется   //|
                                       // при Method=1.               //|     
////////////////////////////////////////////////////////////////////////|
//+------------------------------------------------------------------+//|
//|  Определяем "свой" минимальный размер или шаг лота на момент     |//|
//|  начала цикла в зависимости от размера баланса и установленного  |//|
//|  риска.                                                          |//|
//+------------------------------------------------------------------+//|
////////////////////////////////////////////////////////////////////////|
double fGetLotsSimple()                                               //|
   {                                                                  //|
   double LOTSTEP,lot;                                                //|
   double Means;                                                      //|
   switch (Method)                                                    //|
      {                                                               //|
      case 0:                                                         //|
         lot=LOTS;                                                    //|
      break;                                                          //|
      case 1:                                                         //|
         Means=AccountBalance();                                      //|
         if(Means<MeansStep)Means=MeansStep;                          //|
         lot=(MeansStep*MathFloor(Means/MeansStep))/MeansStep*Risk;   //|
      break;                                                          //|
      default:lot=LOTS;                                               //|
   }                                                                  //|
   if(lot<1.0/MathPow(10,LotsDigits))lot=1.0/MathPow(10,LotsDigits);  //|
   LOTSTEP=MarketInfo(Symbol(),MODE_LOTSTEP);                         //|
   lot=MathFloor(lot/LOTSTEP)*LOTSTEP;                                //|
   lot=NormalizeDouble(lot,LotsDigits);                               //|
   if(lot>AccountFreeMargin())lot=-1;                                 //|
   return(lot);                                                       //|
}                                                                     //|
////////////////////////////////////////////////////////////////////////|
)
Reason: