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

 
Looking for a UMPC to use in my day job, could you please tell me if MT4 will work on a netbook like this http://cgi.ebay.com/4-8-TOUCH-LCD-BenQ-S6-HSDPA-UMPC-3G-NETBOOK-XP-/190490113552?pt=Laptops_Nov05&hash=item2c5a187610#ht_15003wt_1139 It's too much to photograph, so I've provided a link.
 
afirius:
Looking for a UMPC to use in my day job, could you tell me if MT4 will work on this netbook https://www.mql5.com/go?link=https://www.ebay.com/itm/4-8-TOUCH-LCD-BenQ-S6-HSDPA-UMPC-3G-NETBOOK-XP-/190490113552?hash=item2c5a187610&pt=Laptops_Nov05[hash]ht_15003wt_1139 Picture too much, so I've provided a link.

Yes
 
Sergstuddek:
Hello. Please write the code for opening a pending (stop) order relative to an already open (last) order.


Well, that's a classic. :)

The code should look like this:

If there is an open order, we calculate its setting price. Then we should add some distance to this price (it can be negative) - we obtain the level where the pending order will be set. Then we check if there is no pending order and if the distance to the pending order is more or equal to the minimal permissible level, we place the pending order on this level. This is it. The code should look like this.

Is your request satisfied?

 
Is it possible to enter the desired optimisation parameters into the MT4 tester by text or other file?
 
Sergey_Rogozin:
Is it possible to enter the desired optimisation parameters into the MT4 tester with a text or other file?
Look for an auto-optimiser in the codebase
 

Familiar with this article, tried to run the auto-optimiser, but it didn't work for me.

I don't have enough knowledge.

I need something simpler.

Nevertheless, thank you.

 
drknn:


It's a classic. :)

The programming code should look like this:

If there is an open order, calculate its setting price. Then we should add a certain distance to this price (it can be negative) - we obtain the level at which the pending order is set. Then we check if there is no pending order and if the distance to the pending order is more or equal to the minimal permissible level, we place the pending order on this level. This is it. The code should look like this.

Satisfied?

+10 Good fishing rod... :)

Now there are two possible developments - the person will write code using this algorithm, asking questions about the case, or he will point out that it's not a code, but an algorithm and wait for a ready-made solution... :)

 
sergeev:

You need a pending bystop/slestop order

Or do you need a stop loss in an existing order?


First option: a pending bystop/sllestop order.

Please write some basic code like template so I can look at it and figure it out.

 
drknn:


This is a classic. :)

The programming code should look like this:

If there is an open order, calculate its setting price. Then we should add a certain distance to this price (it can be negative) - we obtain the level at which the pending order is set. Then we check if there is no pending order and if the distance to the pending order is more or equal to the minimal permissible level, we place the pending order on this level. This is it. The code should look like this.

Is your request satisfied?


Classy is good, but there's still a problem)))

In theory, I understand it but in practice, I cannot do it. Perhaps you may look at my code and tell me what's wrong.

#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
// Суть советника в том что сначала он открывает первый ордер на покупку
// затем выставляет стопы в две стороны
// в одну сторону как продолжене уже открытого ордера
// в другую в два раза больше в случае разворота графика
// стопы выставляются по отношению к последнему открытому советником ордеру
// с каждым новым открытием нового отложеного ордера, все старые удаляються
// а ноые отложеные стопы уже открываются относительно нового открытого ордера.
#define MAGIC  20101012
extern double Lot=1;            // Размер лота
extern int TP=0;                // Тейкпрофит
extern int SL=0;                // СтопЛосс
extern int DS=0;                // Дистанция  для открытия ордера в противоположну сторону
int buys=0,sells=0;
int i=0;
//-----------------------------------------------------
void DeleteStopOrders()
{
  int res;
  for(int i=0;i<OrdersTotal();i++)
  {
    if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
    if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC)
    {
      if(OrderType()==OP_SELLSTOP)
        res=OrderDelete(OrderTicket());
      if(OrderType()==OP_BUYSTOP)
        res=OrderDelete(OrderTicket());
     }
  }
}
        
void OpenBuy()
    
   {
   int tickbuy2  =OrderSend(Symbol (), OP_BUY, Lot,  NormalizeDouble(Ask,Digits), 5, Ask-SL*Point,Ask+TP*Point, NULL, MAGIC, 0, Green); // покупка первого ордера при запуске советника
   }
//+------------------------------------------------------------------+
//| считаем количество открытых ордеров                              |
//+------------------------------------------------------------------+
int CalculateCurrentOrders1(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()==MAGIC)
        {
         if(OrderType()==OP_BUY)  buys++;
         if(OrderType()==OP_SELL) sells++;
        }
     }
//---- return orders volume
   return(buys+sells);   
}
//+------------------------------------------------------------------+
//| считаем количество отложеных ордеров                              |
//+------------------------------------------------------------------+
int CalculateCurrentOrders2(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()==MAGIC)
        {
         if(OrderType()==OP_BUYSTOP)  buys++;
         if(OrderType()==OP_SELLSTOP) sells++;
        }
     }
//---- return orders volume
   return(buys+sells);   
}

int OpenStops()

{for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true && OrderType()==OP_BUY)   // Проверка на то что открытый ордер на покупку
int ticket;
double LotSize=OrderLots();                                                                                 // Размер лота открытого ордера
double OpenPrice=OrderOpenPrice();                                                                          // Цена открытия открытого ордера
ticket=OrderSend(Symbol(),OP_SELLSTOP,LotSize*2,OpenPrice-DS*Point,0,SL*Point,TP*Point,"",MAGIC,0,Red);            // Открытие отложки на продажу в противополжну сторону до открытого ордера   
ticket=OrderSend(Symbol(),OP_BUYSTOP,Lot,OpenPrice+TP*Point,0,SL*Point,TP*Point,"",MAGIC,0,Blue);                  // Открытие отложки на покупку в сторону продолжения до открытого ордера

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true && OrderType()==OP_SELL)  // Проверка на то что открытый ордер на продажу
ticket=OrderSend(Symbol(),OP_SELLSTOP,Lot,OpenPrice-TP*Point,0,SL*Point,TP*Point,"",MAGIC,0,Red);                  // Открытие отложки на покупку в сторону продолжения до открытого ордера
ticket=OrderSend(Symbol(),OP_BUYSTOP,LotSize*2,OpenPrice+DS*Point,0,SL*Point,TP*Point,"",MAGIC,0,Blue);            // Открытие отложки на покупку в противополжну сторону до открытого ордера
}
}
  
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
  if (CalculateCurrentOrders1(Symbol())==0)
   OpenBuy();
  if (CalculateCurrentOrders2(Symbol())<=1)
  DeleteStopOrders();
  if (CalculateCurrentOrders2(Symbol())<=1)
   OpenStops();
//----
   return(0);
I understand it is a simple EA, but I am just beginning my journey)))) and already have a problem
 

Question about the indicator.

The indicator is a cross indicator. Draws a lot of arrows to one side, then a lot to the other. How to make only the first ones to be drawn. I have tried it in the way given in the code, but it changes when I switch the frame.

Please, advise how to do it correctly.

 for(int i=limit-1;i>=0;i--)
   {      
         if ( s == 0 &&    условие продажи)
               {Продажа[i] = High[i]+point*Point;            
                s=1; b=0;}               
      
         if (b == 0 &&     условие покупки)
        
          
              {Покупка[i] = Low[i]-point*Point; 
               s=0; b=1;}
   }
Reason: