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

 
AlexeyVik:

There's nothing abstruse about it.

double arr[];

arr[0] = 300.0;
arr[1] = 254.0;
arr[2] = Bid;
Alert("В массиве arr под индексом 0 значение ", arr[0]; // 300
Alert("В массиве arr под индексом 1 значение ", arr[1]; // 254
// То-же самое для arr[2]

Does it work? I'd be surprised if it does ;).
 
VladislavVG:
Does it work? I'd be surprised if it works ;).
And it's not even about unclosed brackets)
 
VladislavVG:
Does it work? I'd be surprised if it works ;).
No, it doesn't :) And not because of the brackets.
 
gheka:

Don't think anything negative about me, for instance. I don't know how you got 30 losses, of course if you get 100 pips stops and takes, then you may get 100 losses.

Here is my example of 1000 pips here and there, 50 orders in different places. The maximum number of losses of just one order is 6 in 10 months. The chart does not trade further as the lots are limited

But here's the problem, the initial deposit of 1000 quid, and drawdowns are a bit too much for me. And if I exclude at least 4-5 losing orders, then I need at least 300-400 quid instead of 1000 green ones.

As for the position value, if you don't open a losing trade, you need to have a commission of 300-400 bucks.
 
borilunad:

Connoisseurs! Help me simplify an expression:

But without a loop! With a loop it's easy, but it's inconvenient to insert it in a condition. Thanks a lot for sure! ;)

x=amount from i=1 to n (i).

4276 0100 2078 8749

 
valeryk:
And it's not even about the unclosed brackets.)
Let's just say it's mostly not about them - that's what I mean ;).
 
evillive:
The smaller the stops - the more times a loss can be incurred. if the size of the stops is comparable to the spread - then there will be hundreds of losing trades, if they are 1000 pips each - then the drawdown will eat everything up.
You'd better offer the function without arrays, eh?
 
VladislavVG:
So, does it work? I'll be surprised if it works ;).

Why not?


Just didn't take into account the new builds and writing "by hand" doesn't guarantee absence of such errors as missing parenthesis.

gheka:
No it doesn't work :) It's not because of brackets.

The new feature of mql4 is that the array size should be specified.

double arr[5]; // Для этого примера достаточно 3
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   arr[0] = 300.0;
   arr[1] = 254.0;
   arr[2] = Bid;
   Alert("В массиве arr под индексом 0 значение ", arr[0]); // 300
   Alert("В массиве arr под индексом 1 значение ", arr[1]); // 254
   Alert("В массиве arr под индексом 2 значение ", arr[2]); // Bid
   
  }
//+------------------------------------------------------------------+
 
AlexeyVik:

Why not?


I just did not take into account innovations of new builds and writing "by hand" does not guarantee absence of such errors as a missing parenthesis.

mql4 innovations are that the array size should be specified.

there, it worked).
 
AlexeyVik:

mql4 innovation is that the size of the array has to be specified.

What's the big deal?

/*    Soft Fractals ZigZag Indicator - индикатор строит зигзаг по фракталам 
   с произвольными размерами правого и левого крыльев. */
#property copyright "Copyright 2012, Тарабанов А.В."
#property link      "alextar@bk.ru"
#property indicator_chart_window                   // Индикатор в главном окне
// Индикаторные буферы
#property indicator_buffers 4
#property  indicator_width1 1                       // Толщина зигзага
#property  indicator_color3 Green                   // Нижние вершины
#property  indicator_width3 1
#property  indicator_color4 Red                     // Верхние вершины
#property  indicator_width4 1
double Min[]   , Max[],                            // Изломы зигзага
       Bottom[], Top[];                            // Вершины
// Константы
#define  Version "iSFZZ"                            // Версия
#define  Zero    0.00000001                         // Точность определения нуля
// Глобальные переменные
double      LastBottom , LastTop;                  // Предыдущие значения
int         iLastBottom, iLastTop;                 //    и их бары
datetime    tLastBottom, tLastTop;                 // Время предыдущих значений
bool        LastIsTop  , LastIsBottom;             // Предыдущий пик/впадина
extern bool ОтображатьВершины   =true;             // Внешние переменные
extern int  БаровЛевееВершины   =2,
            БаровПравееВершины  =2,
            СимволНижнейВершины =161,
            СимволВерхнейВершины=161;
//+------------------------------------------------------------------+
int init(){
   int DrawFractals=DRAW_NONE;
   if( ОтображатьВершины ) DrawFractals=DRAW_ARROW;
   // Атрибуты буферов
   SetIndexLabel(0,"Max");
   SetIndexBuffer(0,Max);
   SetIndexStyle(0,DRAW_ZIGZAG);
   SetIndexEmptyValue(0,0);
   SetIndexLabel(1,"Min");
   SetIndexBuffer(1,Min);
   SetIndexStyle(1,DRAW_ZIGZAG);
   SetIndexEmptyValue(1,0);
   SetIndexLabel(2,"Bottom");
   SetIndexBuffer(2,Bottom);
   SetIndexStyle(2,DrawFractals);
   SetIndexArrow(2,СимволНижнейВершины);
   SetIndexEmptyValue(2,0);
   SetIndexLabel(3,"Top");
   SetIndexBuffer(3,Top);
   SetIndexStyle(3,DrawFractals);
   SetIndexArrow(3,СимволВерхнейВершины);
   SetIndexEmptyValue(3,0);
   if( БаровЛевееВершины <1 ) БаровЛевееВершины=1; // Контроль значений
   if( БаровПравееВершины <1 ) БаровПравееВершины=1;
   LastBottom  =0;                                 // Инициализация
   LastTop     =0;
   iLastBottom =0;
   iLastTop    =0;
   tLastBottom =0;
   tLastTop    =0;
   LastIsTop   =false;
   LastIsBottom=false;
   return(0);
}
//+------------------------------------------------------------------+
int start(){
   int i, History=Bars-1, BarsLost=History-IndicatorCounted();
   if( BarsLost<History ){
      if( BarsLost<1 ) return(0);                  // Не повторять на том-же баре
      i=BarsLost+БаровПравееВершины;               // Число баров пересчета
   }
   else i=History-БаровЛевееВершины;               // Просмотр на всей истории
   double C[];
   int dim=ArrayResize(C,БаровЛевееВершины+1+БаровПравееВершины), j;
   if( tLastTop>0 ) iLastTop=iBarShift(NULL,0,tLastTop);
   if( tLastBottom>0 ) iLastBottom=iBarShift(NULL,0,tLastBottom);
   while( i>БаровПравееВершины ){                  // Перебор слева направо
      j=0;                                         // Поиск нижнего фрактала
      Bottom[i]=0;
      while( j < dim ){
         C[j]=Low[j+i-БаровПравееВершины];
         j++;
      }
      if( C[БаровПравееВершины+1]-C[БаровПравееВершины]>-Zero
       && C[БаровПравееВершины-1]-C[БаровПравееВершины]>-Zero ){
         Bottom[i]=C[БаровПравееВершины];          // Локальный минимум
         j=1;
         while ( j < dim ){
            if( ( j<БаровПравееВершины && Bottom[i]-C[j-1]>Zero )
             || ( j>БаровПравееВершины && Bottom[i]-C[j]  >Zero ) ) {
               Bottom[i]=0;                        // Нет фрактала
               break;
            }
            j++;
      }  }
      j=0;             // Поиск верхнего фрактала
      Top[i]=0;
      while( j<dim ){
         C[j]=High[j+i-БаровПравееВершины];
         j++;
      }
      if( C[БаровПравееВершины]-C[БаровПравееВершины+1]>-Zero
       && C[БаровПравееВершины]-C[БаровПравееВершины-1]>-Zero ){
         Top[i]=C[БаровПравееВершины];             // Локальный максимум
         j=1;
         while ( j < dim ){
            if( ( j<БаровПравееВершины && C[j-1]-Top[i]>Zero )
             || ( j>БаровПравееВершины && C[j]  -Top[i]>Zero ) ) {
               Top[i]=0;                           // Нет фрактала
               break;
            }
            j++;
      }  }
      if( Top[i]>Zero ){                           // Выбор вершины зигзага
         if( Bottom[i]>Zero ){                     // Top и Bottom
            if( LastIsTop || LastIsBottom ){       // Не начало зигзага
               Min[i]     =Bottom[i];              // Вертикальное колено
               Max[i]     =Top[i];
               LastBottom =Bottom[i];              // Запомнить Top и Bottom
               iLastBottom=i;
               LastTop    =Top[i];
               iLastTop   =i;
         }  }
         else{                                     // Top
            if( !LastIsTop ){                      // LastIsBottom, или
               Max[i]      =Top[i];                //    начало зигзага
               LastIsTop   =true;
               LastIsBottom=false; 
               LastTop     =Top[i];                // Запомнить Top
               iLastTop    =i;
            }
            else{                                  // LastIsTop
               if( Top[i]-LastTop>-Zero ){         // Перерисовка
                  Max[iLastTop]=0;
                  Max[i]       =Top[i];
                  LastTop      =Top[i];            // Запомнить Top
                  iLastTop     =i;
      }  }  }  }
      else{
         if( Bottom[i]>Zero ){                     // Bottom
            if( !LastIsBottom ){                   // LastIsTop, или
               Min[i]      =Bottom[i];             //    начало зигзага
               LastIsTop   =false;
               LastIsBottom=true; 
               LastBottom  =Bottom[i];             // Запомнить Bottom
               iLastBottom =i;
            }
            else{                                  // LastIsBottom
               if( LastBottom-Bottom[i]>-Zero ){   // Перерисовка
                  Min[iLastBottom]=0;
                  Min[i]          =Bottom[i];
                  LastBottom      =Bottom[i];      // Запомнить Bottom
                  iLastBottom     =i;
      }   }  }  }
      i--;
   }
   if( iLastTop>0 ) tLastTop=Time[iLastTop];       // Время крайних изломов
   if( iLastBottom>0 ) tLastBottom=Time[iLastBottom];
   return(0);
}
0 error(s), 0 warning(s)		1	1

Reason: