[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 252

 

drknn, is this a limit on the number of orders?

int SchBuy(int MAGIC){
  string SMB=Symbol();
  int SchBuy=0;
  int i;
  for ( i=OrdersTotal()-1; i>=0; i--) {
    if (!OrderSelect( i, SELECT_BY_POS, MODE_TRADES)) { WriteError( i);}
    else {
      if(OrderSymbol()!= SMB || OrderMagicNumber()!= MAGIC){ continue;}
      if(OrderType()==OP_BUY){ 
        SchBuy++;
      }  
    }
  }
  return( SchBuy);
}                  
//==================================================================================================


//=========== SchSell()  ===============================
//  Функция возвращает количество Sell-ордеров
//  SchSell  - счётчик Sell ордеров
//-----------------------------------------------------------
int SchSell(int MAGIC){
  string SMB=Symbol();
  int SchSell=0;
  int i;
  for ( i=OrdersTotal()-1; i>=0; i--){
    if (!OrderSelect( i, SELECT_BY_POS, MODE_TRADES)) { WriteError( i);}
    else {
      if(OrderSymbol()!= SMB || OrderMagicNumber()!= MAGIC){ continue;} 
      if(OrderType()==OP_SELL){
        SchSell++;
      }
    }
  }
 return( SchSell);     
}                  
 
IlyaA >> :


Hey man can you speak like this or like this :) >> I'm breaking my eyes. :)

:-)) Yes I can like You, but I dont think that every one can like us, than ...... ya dolgen pusat na translute, tak na rabote gde rabotayu vse klavu s Uspanskoj raskladkoj. Uzvunyajte.

 
Ibiss >> :

drknn, is this a limit on the number of orders?



Well, a trade signal comes in. Let's say a signal comes in to open a buy order. Before we open it, we re-calculate the buy orders on our pair. If there are none, we open an order. If there is at least 1 order, we will not open a second buy order on the same signal.

These two subroutines are just order counters.

By the way, limiting orders on a single candlestick using counters is not the only way to avoid piles of orders on a single candlestick.

 

I get an error during compilation:

'WriteError' - function is not defined

maybe 'WriteError' should be defined in global variables? i don't get it yet)

thanks)


 
Yesterday I read "Gap 1_500 or how to dump a DC" and a similar thought occurred to me. In brief. What if we open positions on well correlated instruments (coefficient => -1 and 1) in both directions. The loss on the first instrument will be closed by profit on the second one and there may be some bread and butter left over. But something tells me that the idea is not new. Kindly comment on it.
 

I wrote an indicator, it shows the High-Low value as a histogram B if the value is higher than the previous - green, below - red. but the indicator is not displayed in the thermal, what is the error?

The code of the indicator:

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red

int BarsCount = 10000;

//---- buffers
double buf_1[], buf_2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
    SetIndexStyle(0,DRAW_HISTOGRAM);
    SetIndexBuffer(0, buf_1);
    SetIndexStyle(1,DRAW_HISTOGRAM);
    SetIndexBuffer(1, buf_2);
    //----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
int i, HL_0, HL_1;
//----
   int limit = BarsCount;
    if ( limit > Bars)
        limit = Bars;
        
   for ( i = limit; 0 <= i; i--) {

        HL_0 = High[ i]-Low[ i];
        HL_1 = High[ i-1]-Low[ i-1];
        
        if( HL_0> HL_1) buf_1[ i] = HL_0;
        if( HL_0< HL_1) buf_2[ i] = HL_0;
        }
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Ibiss >> :

I get an error during compilation:

'WriteError' - function is not defined

maybe 'WriteError' should be defined in global variables? i don't get it yet)

thanks)



That's right, you don't have the WriteError(i) function. This is my personal custom error handling function
 
Why? The Sleep() function does not work in the tester???
 
AndBar писал(а) >>

:-)) Yes I can like You, but I dont think that every one can like us, than ...... ya dolgen pusat na translute, tak na rabote gde rabotayu vse klavu s Uspanskoj raskladkoj. Uzvunyajte.

'kogda je budet MQL5?

>> this thread will help you. ALL variants are available here.

 
RomanS >> :
Why? The Sleep() function doesn't work in the tester???

If I'm not mistaken, I read somewhere that it doesn't work.