[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 424

 
gyfto:

Well, in theory, if additional indicator buffers are self-declared and further trend lines are used, then it will work...

Then why does the documentation say that
the number of buffers cannot exceed 8
It's not clear here. It doesn't say it's the number of main buffers, not all of them. It says the number of buffers and that's it. So I'm reading this and it's my understanding that this should apply to the total number of buffers for a given indicator.
 
gyfto:

No, I'm talking about ObjectCreate(), you have to set the window number there. I showed you how to set it if it is a subwindow (i.e. not zero, which is the main window).

So you have the function parameter WindowOnDropped there when creating an object, and it's already sort of the main window relatively. Or is main window the leftmostwindow in the terminal?
 

Hello! I can't understand why buystop orders are not deleted.

extern double Lots       =0.01;
extern int    Magic      =333;

extern int    StopLoss      = 100;      // Размер фиксированного стопа
extern int    TakeProfit    = 100;       // Размер фиксированного тэйка
extern int    DistanceSet   = 160;      // Расстояние от рынка
extern int    Slippage      = 3;       // Проскальзывание цены
color  clOpenBuy     = LightBlue;    // Цвет ордера BuyStop
color  clOpenSell    = LightCoral;   // Цвет ордера SellStop
string Name_Expert   = "Scalp";

string Symb;
bool Work=true;

extern bool   UseSound       = True;  // Использовать звуковой сигнал
extern string NameFileSound  = "expert.wav";  // Наименование звукового файла
//============================================================================================
int start()
  {
   int
   Total,
   Tip=-1,
   Ticket,
   TicketB,
   TicketS,
   TicketMB,
   TicketMS,
   buys,
   sells,
   mbuys,
   msells;
   double
   OP_PriceSell,
   OP_PriceBuy, 
   Lot,
   Lts,
   Min_Lot,
   Max_Lot,
   Step,
   Free,
   One_Lot,
   Price,
   SL,
   TP,
   TP1,
   PriceB,
   PriceS,
   SLB,
   SLS;
   bool
   Ans  =false,
   Opn_B=false,
   Opn_S=false,
   Cls_B=false,
   Cls_S=false;
//============================================================================================
   // Учёт ордеров
   Symb=Symbol();
   Total=0;
   buys=0;
   sells=0;
   mbuys=0;
   msells=0;                                    
   for(int i=1; i<=OrdersTotal(); i++)
     {
      if (OrderSelect(i-1,SELECT_BY_POS)==true)
        {
         Total++;
         if(OrderType()==OP_BUYSTOP)  buys++;
         if(OrderType()==OP_SELLSTOP) sells++;
         if(OrderType()==OP_BUY)  mbuys++;
         if(OrderType()==OP_SELL) msells++;
         if(OrderType()==OP_BUYSTOP) TicketB=OrderTicket();
         if(OrderType()==OP_SELLSTOP) TicketS=OrderTicket(); 
         Ticket=OrderTicket();
         Tip   =OrderType();
         TP    =OrderTakeProfit();
         Lot   =OrderLots();
        }
     }
//============================================================================================
   // Открытие ордеров
   while(true)                                  
     {
      if (Total==0)            
        {                                      
         star();
        }
      break;                                   
     }
//============================================================================================
  while(true)
     {
      if(Total==2)
        {
         if(msells==1)
           {
            if(buys==1)
              {
               if(OrderType()==OP_BUYSTOP && OrderLots()==Lots)
                 {
                  OrderDelete(Ticket);
                 }
              }
           }
        }
      if(Total==2)
        {
         if(mbuys==1)
           {
            if(sells==1)
              {
               if(OrderType()==OP_SELLSTOP && OrderLots()==Lots)
                 {
                  OrderDelete(Ticket);
                 }
              }
           }
        }
      break;
     }  
//============================================================================================
   return;
  }
//============================================================================================
//+------------------------------------------------------------------+
void star() {
  double ldStop=0, ldTake=0;
  double pAsk=Ask+DistanceSet*Point;
  double pBid=Bid-DistanceSet*Point;

  if (StopLoss!=0) ldStop=pAsk-StopLoss*Point;
  if (TakeProfit!=0) ldTake=pAsk+TakeProfit*Point;
  SetOrder(OP_BUYSTOP, pAsk, ldStop, ldTake);

  if (StopLoss!=0) ldStop=pBid+StopLoss*Point;
  if (TakeProfit!=0) ldTake=pBid-TakeProfit*Point;
  SetOrder(OP_SELLSTOP, pBid, ldStop, ldTake);
}

//+------------------------------------------------------------------+
//| Установка ордера                                                 |
//| Параметры:                                                       |
//|   op     - операция                                              |
//|   pp     - цена                                                  |
//|   ldStop - уровень стоп                                          |
//|   ldTake - уровень тейк                                          |
//+------------------------------------------------------------------+
void SetOrder(int op, double pp, double ldStop, double ldTake) {
  color  clOpen;
  string lsComm=GetCommentForOrder();

  if (op==OP_BUYSTOP) clOpen=clOpenBuy;
  else clOpen=clOpenSell;
  OrderSend(Symbol(),op,Lots,pp,Slippage,ldStop,ldTake,lsComm,0,0,clOpen);
  if (UseSound) PlaySound(NameFileSound);
}

//+------------------------------------------------------------------+
//| Генерирует и возвращает строку коментария для ордера или позиции |
//+------------------------------------------------------------------+
string GetCommentForOrder() {
  return(Name_Expert+" "+GetNameTF(Period()));
}

//+------------------------------------------------------------------+
//| Возвращает наименование таймфрейма                               |
//+------------------------------------------------------------------+
string GetNameTF(int TimeFrame) {
        switch (TimeFrame) {
                case PERIOD_MN1: return("Monthly");
                case PERIOD_W1:  return("Weekly");
                case PERIOD_D1:  return("Daily");
                case PERIOD_H4:  return("H4");
                case PERIOD_H1:  return("H1");
                case PERIOD_M30: return("M30");
                case PERIOD_M15: return("M15");
                case PERIOD_M5:  return("M5");
                case PERIOD_M1:  return("M1");
                default:                     return("UnknownPeriod");
        }
}
//+------------------------------------------------------------------+
 
hoz:

Then why does the documentation say that
the number of buffers cannot exceed 8
This is where it is unclear. It doesn't say the number of main buffers... not all buffers. It says the number of buffers and that's it. So I'm reading it and it's supposed to apply to the total number of buffers of a given indicator.

I'm not talking about the indicator buffers, I'm talking about the simulated indicator buffers. There ArrayResize(CustomBuffer, Bars) in the wrapper from IndicatorCounted(), and the ends of the rightmost trend lines should be redrawn by bid.

hoz:

So you have a function parameter there when creating an object - WindowOnDropped, and it's already sort of the main window relatively. Or is the main window leftmostamong windows in the terminal?
No, I was confused at first, too. For example, we have two charts open, euron and gold. So, they both have an index of zero. But if they have sub-windows, they are numbered from one. For example, I have thrown three indices on the eurenne chart, two on gold, and all five with #property separate_window and all different subwindows. Then eurene will have window numbers 0, 1, 2, 3 and gold 0, 1, 2.
 

I have a question. My brain is boiling, honestly. If you can - help me.

int n=1, limit=3;
double result;//или int result, что не столь сейчас важно
double temp[];
int start(){
        for(int slow=10; slow<=10*limit; slow++){
                for(int fast=10; fast<=slow; fast++){
                        for(int period=1; period<=slow/10; period++){
                                n++; Print(n-1, ": ", slow-9, ", ", fast-9, ", ", period);
                                //здесь идёт тестирование машки с параметрами slow, fast, period, а результаты тестирования заносим в массив:
                                ArrayResize(temp,n); temp[n-1]=result;
                        }
                }
        }
        //и находим максимальный результат:
        int max=ArrayMaximum(temp);
   return(0);
}

Now a question: how can I restore values slow, fast, period by max (which is position of an item in the array)? The order in which values are put in temp[] is given in Print(). I put 3 in limit, but any number can be used there. Here are the first 77 values (limit=2):

            10: 4, 4, 1  20: 6, 5, 1  30: 8, 2, 1  40: 9, 4, 1   50: 10, 5, 1   60: 11, 3, 1  70: 11, 8, 1
1: 1, 1, 1  11: 5, 1, 1  21: 6, 6, 1  31: 8, 3, 1  41: 9, 5, 1   51: 10, 6, 1   61: 11, 3, 2  71: 11, 8, 2
2: 2, 1, 1  12: 5, 2, 1  22: 7, 1, 1  32: 8, 4, 1  42: 9, 6, 1   52: 10, 7, 1   62: 11, 4, 1  72: 11, 9, 1
3: 2, 2, 1  13: 5, 3, 1  23: 7, 2, 1  33: 8, 5, 1  43: 9, 7, 1   53: 10, 8, 1   63: 11, 4, 2  73: 11, 9, 2
4: 3, 1, 1  14: 5, 4, 1  24: 7, 3, 1  34: 8, 6, 1  44: 9, 8, 1   54: 10, 9, 1   64: 11, 5, 1  74: 11, 10, 1
5: 3, 2, 1  15: 5, 5, 1  25: 7, 4, 1  35: 8, 7, 1  45: 9, 9, 1   55: 10, 10, 1  65: 11, 5, 2  75: 11, 10, 2
6: 3, 3, 1  16: 6, 1, 1  26: 7, 5, 1  36: 8, 8, 1  46: 10, 1, 1  56: 11, 1, 1   66: 11, 6, 1  76: 11, 11, 1
7: 4, 1, 1  17: 6, 2, 1  27: 7, 6, 1  37: 9, 1, 1  47: 10, 2, 1  57: 11, 1, 2   67: 11, 6, 2  77: 11, 11, 2
8: 4, 2, 1  18: 6, 3, 1  28: 7, 7, 1  38: 9, 2, 1  48: 10, 3, 1  58: 11, 2, 1   68: 11, 7, 1
9: 4, 3, 1  19: 6, 4, 1  29: 8, 1, 1  39: 9, 3, 1  49: 10, 4, 1  59: 11, 2, 2   69: 11, 7, 2
 
gyfto:

I have a question. My brain is boiling, honestly. If you can - help me.

Now a question: how can I restore values slow, fast, period by max (which is position of an item in the array)? The order in which values are put in temp[] is given in Print(). I put 3 in limit, but it can be any number.


Where "n++" check if result is maximal, if it is maximal, remember values of slow, fast, etc.
 
You could make three more arrays (or one three-dimensional array) for slow, fast... This is better, because in case you want to sort the results somehow, there will always be test parameters available.
 
If these actions are frequent, e.g. once per bar or 10 bars, it is better to scale arrays for results and three arrays with parameter values in the initem, scroll through these loops, fill the arrays with period values. Then scroll it all in one loop. Then we will be able to use the ArrayMaximum function, and sort things out. This will make the work as fast as possible.
 
gyfto:

No, I was confused at first too. For example, we have two charts open, the euro and gold. So, they both have an index of zero. But if they have sub-windows, they are numbered from one. For example, I have thrown three indices on the eurenne chart, two on gold, and all five with #property separate_window and all different subwindows. Then the eurene would have window numbers 0, 1, 2, 3 and gold would have 0, 1, 2.

Exactly! I just don't work with turkeys at all, so I didn't pay attention when I was studying the help. It all makes sense.

gyfto:

I am not talking about indicator buffers, I am talking about simulated indicator buffers. There ArrayResize(CustomBuffer, Bars) in the wrapper from IndicatorCounted(), and the ends of rightmost trend lines should be redrawn by Bid.

And I was asking specifically how to draw more than 6 lines on a graph. In which window (0 or other, it doesn't matter). This is what I'm most interested in right now and that's what I asked originally.
 
Integer:

Where "n++" make check for maximal result, if maximal, remember values of slow, fast, etc.

Didn't think about it.


Integer:
You can make three more arrays (or one three-dimensional array) for slow, fast... That's better, because in case you want to sort the results somehow, there will always be test parameters available.

Three-dimensional is ideal, but ArrayMaximum() only works on one-dimensional, so you'll have to converge the array into a linear one, and again you'll have to figure out where everything is. But I have fastMax=slow, and that's the trouble. But three different arrays... I have the same result, so it's either one three-dimensional or one linear.


Integer:
scale arrays for results

I don't know this terminology, please explain. Create a linear array of length in a cube?


Well, at least there's an option already. Via MathMax(result, resultPrev).