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

 
okvseok:

Please advise!

It is possible to print one sheet, but how can I set it to start printing sheets from a certain date to a certain date? So that one sheet at a time is not printed.

Thank you!



ignore)
 
Good afternoon! You know, something is not working in my scrip. When I drag it onto the chart, nothing happens at all.
 
The start is unavoidable on every tick, but the necessary conditions can be provided in it.
 
Good afternoon! You know, something is not working in my scrip. When I drag it onto the chart, nothing happens at all. How do I use it?
//+------------------------------------------------------------------+
//|                                                      Покупка.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
for(int i=0;i<=OrdersTotal();i++){
   if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true)
 { if(OrderSymbol() != Symbol()) continue; 
   if(OrderType()==OP_SELL) 
  OrderClose(OrderTicket(),OrderLots(),Ask,6,Red);
   if(OrderType()==OP_BUY)
  OrderClose(OrderTicket(),OrderLots(),Bid,6,Red);
   if(OrderType()>=2)
  OrderDelete(OrderTicket());}} 
//----
   for(i=0;i<23;i++){
    Sleep(2000);RefreshRates(); if(!IsTradeAllowed())continue;
    int tiket=OrderSend(Symbol(),OP_BUY,0.1,Ask,6,0,0,"Skript",98600,0,Blue);
   if( tiket!=-1)break;
   if (tiket==-1){ int Error=GetLastError();  
            string errorcomment = "Ошибка открытия  ордера OP_BUY"  + " " + Symbol() +  " " + ErrorDescript(Error); 
            Print (errorcomment);}}
//----
   return(0);
  }
//+------------------------------------------------------------------+

//------- :  Коды ошибок
string ErrorDescript(int error_code){string error_string;switch(error_code){
      //---- Коды ошибок, возвращаемые торговым сервером:
      case 0:   error_string="Нет ошибок";                                                                                             break;
      case 1:   error_string="Нет ошибки, но результат неизвестен";                                                                    break;
      case 2:   error_string="Общая ошибка";                                                                                           break;
      case 3:   error_string="Неправильные параметры";                                                                                 break;
      case 4:   error_string="Торговый сервер занят";                                                                                  break;
      case 5:   error_string="Старая версия клиентского терминала";                                                                    break;
      case 6:   error_string="Нет связи с торговым сервером";                                                                          break;
      case 7:   error_string="Недостаточно прав";                                                                                      break;
      case 8:   error_string="Слишком частые запросы";                                                                                 break;
      case 9:   error_string="Недопустимая операция нарушающая функционирование сервера";                                              break;
     
 
paladin80:

After normalisation the number changes, e.g:

Another thing is when you print it out, with DoubleToStr, e.g.:

And if you print it out after normalisation, it goes like this:


Thank you.
 

Good afternoon.

I need to calculate the total profit of only the last two buy positions. How do I rewrite the code?

double profits_buy_2pos()
{
   double pr_buy = 0;
   int cnt = 0;
   int OpenOrders=OrdersTotal();
   for(cnt=0;cnt<OpenOrders;cnt++)   // scan all orders and positions. ..
   {
     OrderSelect(cnt, SELECT_BY_POS);
          if (OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType() == OP_BUY)
          {     
          if (OrderType()==OP_BUY) 
          {
            pr_buy+= OrderProfit();
          } 
          }                               
   } 
return(pr_buy);   
}
 
How do I set a Take Profit in Metatrader4 by clicking on a chart? The context menu -> "modify order" is very inconvenient.
 
abeiks:

Good afternoon.

I need to calculate the total profit of only the last two buy positions. How do I rewrite the code?


Function from Kim IV.

The GetProfitOpenPosInCurrency() function. - To help.

+ You rearrange the loop yourself, i.e. you go from the last to the first one, summing up the profit of buy orders and adding the counter of calculated buy positions. As soon as it reaches 2, you exit the loop and that is it.

 
ascerdfg:
How do I set a Take Profit in Metatrader4 by clicking on a chart? The context menu -> "modify order" is very inconvenient.
The terminal itself cannot do it, but there are scripts that can do it. E.g., this one. There are several similar scripts in our database.
 
Roman.:

Function from Kim IV.

GetProfitOpenPosInCurrency() function. - help.

+ You re-do the loop yourself, i.e. you go from the last to the first one, summing up the profit of buy orders and add the counter of counted buy positions. As soon as it reaches 2, you exit the loop and that is it.


Thank you!