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

 
Dimka-novitsek:
But what's in there? Because I've been looking at it for 15 minutes... Yeah, maybe there's something simple I can't see!
 OrderSend(  Symbol( ), OP_SELL, Lot, NormalizeDouble(Bid, Digits), slippage, NormalizeDouble( Ask + stoploss*Point), NormalizeDouble(Bid - takeprofit*Point), "comment", magic, color );

 OrderSend(  Symbol( ), OP_BUY,  Lot, NormalizeDouble(Ask, Digits), slippage, NormalizeDouble(Bid - stoploss*Point), NormalizeDouble(Ask + takeprofit*Point), "comment", magic, color );

 
What's wrong with OrderOpenPrice( ) ? ??? It's a simple normal function!!! The order I pre-selected.
 
Sorry, what is it? The OrderSend function works for me, while OrderClose is showing off!
 
Dimka-novitsek:
Sorry, what is it? The OrderSend function works for me, while OrderClose is showing off!
total = OrdersTotal();
  for(i=total-1;i>=0;i--)
    {
    OrderSelect(i, SELECT_BY_POS);
    type   = OrderType(); result = false;
    switch(type)
          { 
          case OP_BUY       : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), l_SlipPage, Red ); break;
          case OP_SELL      : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), l_SlipPage, Red ); break; 
          }
    if(!result)
      {
      error =  GetLastError(); 
      errorcomment = "Неудалось закрыть ордер №" + OrderTicket() + " " + Symbol() + " " + OrderType() + " " + ErrorDescript(error); 
      Print(errorcomment);
      }  
    }
this is an example of closing all orders, note that bai and sells are closed by bids and asks ....
 
Oh, thank you!!!
 
7777877:

Thank you very much for the previous answers. Everything works and almost everything is clear... Now about that "almost".

1. In which line (see attached file for indicator) is there an indication that the Line calculated on the array data should be displayed in the Client Terminal window?

2. Why is the IndicatorBuffers function needed (or rather, in what situations should it be used), if the number of buffers can be declared as a string

Thanks in advance for the answer

#property indicator_buffers 3                                           //объявляем количество буферов

this string you declare the number of indicator buffers visible in the terminal

   IndicatorBuffers(4);                                                 //устанавливаем общее количество всех индикаторов, участвующих в расчете всех индикаторных линий

this string you declare the total number of buffers used by the indicator for calculations (3 visible and 1 hidden)

if you don't need any additional buffers, you don't need this string

The number of buffers cannot exceed 8 and should be less than the value specified in the indicator_buffers property. Here is a good example.


 
Good morning! Tell me, is it really necessary to normalise the ask and bid prices?
NormalizeDouble(Bid, Digits)
Because I have it like this
for(int i=1; i<=OrdersTotal(); i++) {  
            if (OrderSelect(i-1,SELECT_BY_POS)==true) // Если есть следующий
        {                                       // Анализ ордеров:
         if (OrderSymbol()!=Symbol( ) )continue;      // Не наш фин. инструм
         if (OrderMagicNumber( ) !=magicnumber)continue;
         if (OrderType()==0){ BUY++; ticket=OrderTicket( );Print( "BUY++   " , BUY  ,"  ticket ",ticket);}
         if (OrderType()==1) {SELL++;ticket=OrderTicket( );Print( "SELL++   " , SELL  ,"  ticket ",ticket);}    } }
         
  
  if (strela1<strela2&&SELL==0&&BUY!=0
  ){ udalenie ();
              
   OrderSend(Symbol( ), OP_BUY, lot, Ask, 3*Point, NormalizeDouble( Bid- (stoplos*Point),Digits),   NormalizeDouble( Ask+( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE);           
      Print( "strela1<strela2&&BUY==0&&SELL!=0 " , GetLastError()); }
            
  if (strela1>strela2){ udalenie ();
                
   OrderSend(Symbol( ), OP_SELL, lot, Bid, 3*Point, NormalizeDouble( Ask+ (stoplos*Point),Digits),   NormalizeDouble( Ask-( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE) ; 
        Print( "strela1>strela2&&SELL==0&&BUY!=0 " , GetLastError()); }
      
    if (strela1<strela2&&BUY==0&&SELL==0){    
            
           OrderSend( Symbol( ), OP_BUY, lot, Ask, 3*Point, NormalizeDouble( Bid- (stoplos*Point),Digits),   NormalizeDouble( Ask+( takeprofit*Point),Digits), NULL, magicnumber, 0, CLR_NONE);  
            Print( "strela1>strela2&&BUY==0&&SELL==0   " , GetLastError()  ,"  Ask ",Ask,"   stoplos= NormalizeDouble( Bid- (stoplos*Point),Digits)  ", NormalizeDouble( Bid- (stoplos*Point),Digits),
"    takeprofit= NormalizeDouble( Ask+( takeprofit*Point),Digits) ", NormalizeDouble( Ask+( takeprofit*Point),Digits)); }
           
   if (strela1>strela2&&BUY==0&&SELL==0){  

It fouls like this 2012.11.01 11:31:00 AUDUSD,M15: strela1<strela2&&SELL==0&&BUY!=0 129

ERR_INVALID_PRICE 129Incorrect price It hasn't happened before for years! Didn't happen yesterday either

 
Dimka-novitsek:
Good morning! Tell me, do the ask and bid prices really need to be normalized? Because I have this

It fouls like this 2012.11.01 11:31:00 AUDUSD,M15: strela1<strela2&&SELL==0&&BUY!=0 129

ERR_INVALID_PRICE 129 Incorrect price Never happened before!!! Didn't see it yesterday either.

In the tester you don't need to, but in on-line you have to do whatever the DC server dictates if you want to work.
 
Dimka-novitsek:
Good morning! Do the ask and bid prices really need to be normalized?

It fouls like this 2012.11.01 11:31:00 AUDUSD,M15: strela1<strela2&&SELL==0&&BUY!=0 129

ERR_INVALID_PRICE 129 Incorrect price It hasn't happened before for years! It wasn't yesterday either


Not always like this...

"" Incorrect bid or ask price, possibly non-normalized price. You need to refresh the data after a delay of 5 seconds or more using the RefreshRates function and try again. If the error persists, it is necessary to stop all trading attempts and change the program logic."" "FROM DOCUMENTATION".

If on demo or real - it will not work. You very often try to open two orders in a row. This will work in the Strategy Tester. You would need a delay between orders opening.

 

Thank you!!! Put in the normalisation... And damn-what the hell is going on at all!!!!!! My head's on fire. Seems easier than high school geometry.