Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 366

 
vadynik:
Why an order closes immediately on the next tick, my head is already boiling over, I'm trying to make an order close at a certain number of pips from the price, like a virtual stop...

Print out the value

priceopen

...

 
vadynik:
Why the order is closed immediately at the next tick, my head is already boiling because I am trying to close it by a certain amount of points from the price, sort of a virtual stop...


This would be the same as if you did the following calculation on this line:

if ((100 >=100-30)||(100 <=100 + 25))

{

Print(100) ;

OrderClose(OrderTicket(),OrderLots(),Bid,50,Blue) ;

}

You see what I mean?)

 
Ekburg:


It's like if you did the following calculation on this line:

if ((100 >=100-30)||(100 <=100 + 25))

{

Print(100) ;

OrderClose(OrderTicket(),OrderLots(),Bid,50,Blue) ;

}

See what I mean?)


Yes, the logic is floating))
 
vadynik:

Yes, the logic swam)))

It will...))) At first, I think everyone did...))
 
Ekburg:

It will...)))) at first, I think everyone had that))))


Yeah hard to start) thanks for the help

NormalizeDouble(priceopen-30*Point,Digits)>=Bid

That's how it works.

 
can you tell me how to write "some condition, then request manual confirmation" on MLQ4?
 
Trader7777:
can you tell me how to write "some condition, then request manual confirmation" on MLQ4?


The MessageBox function creates and displays a message box and controls it.
 
 
Trader7777:

Thank you, we'll look into it...)

example

//+------------------------------------------------------------------+
//|                                         проверка(MessageBox).mq4 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
extern int     stoploss    = 0,        //уровень выставления SL, если 0, то SL не выставляется
               takeprofit  = 0,        //уровень выставления TP, если 0, то TP не выставляется
               Magic       = 0;        //уникальный номер ордера
extern double  Lot         = 0.01;      //объем ордера
extern int     slippage    = 0;        //Максимально допустимое отклонение цены для рыночных ордеров

double SL,TP;
#include <WinUser32.mqh>
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
    if (MessageBox (" открыть ордер BUY??? ","Скрипт интересуется:",1)==1)
        {
      if (takeprofit!=0) TP  = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
      if (stoploss!=0)   SL  = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;     
      OPENORDER ("Buy");
        } 

//----
   return(0);
  }
//+------------------------------------------------------------------+
void OPENORDER(string ord)
{
   int error,err;
   while (true)
   {  error=true;
      if (ord=="Buy" ) error=OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP,"BUY",Magic,0,Blue);
      if (ord=="Sell") error=OrderSend(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid,Digits),slippage,SL,TP,"SELL",Magic,0,Red);
      if (error==-1) //неудачная покупка OK
      {  
         ShowERROR();
         err++;Sleep(2000);RefreshRates();
      }
      if (error || err >10) return;
   }
return;
}                  
//--------------------------------------------------------------------
void ShowERROR()
{
   int err=GetLastError();
   switch ( err )
   {                  
      case 1:   return;
      case 2:   Alert("Нет связи с торговым сервером ",Symbol());return;
      case 3:   Alert("Error неправильные параметры ",Symbol());return;
      case 130: Alert("Error близкие стопы   Ticket ",Symbol());return;
      case 134: Alert("Недостаточно денег   ",Symbol());return;
      case 146: Alert("Error Подсистема торговли занята ",Symbol());return;
      case 129: Alert("Error Неправильная цена ",Symbol());return;
      case 131: Alert("Error Неправильный объем ",Symbol());return;
      case 4200:Alert("Error Объект уже существует ",Symbol());return;
      default:  Alert("Error  " ,err," ",Symbol());return;
   }
}
//--------------------------------------------------------------------
 

Hi all. Can you give me a suggestion?

MarketInfo(Symbol(),MODE_SPREAD) returns result in pips, it's written in description. Is it in int or double ? It doesn't say anything about it. Thank you in advance.