[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 509

 
Here,
int X=0;
double S = 0.0000;
extern double       lot=0.1;
extern double       koef=1.5;
extern int       SL=10;
extern int       TP=10;
double dl;
double a;

int init()
  {
  a=lot;
   return(0);
  }

int deinit()
  {

   return(0);
  }


int start()
 {   
               
              
              
                S=Open[0];
                Sleep(1000);
                
             
             if(OrdersTotal() == 0 && X==1)
              { 
              if (Close[0]>dl){lot=a;}
              X=0;
              }
              
              if(OrdersTotal() == 0 && X==2)
              { 
              if (Close[0]<dl){lot=a;}
              X=0;
              }
                
             
             
 
                   if (OrdersTotal() == 0 && Close[0]>S && Close[1]>Open[1]) 
                           {
                            dl=Close[0];
                            OrderSend(Symbol(),OP_BUY,lot,Ask,3,Ask-SL*0.0001,Ask+TP*0.0001,"",14774,0,Blue); 
                            lot=lot*koef;
                            X=1;            
                           }
                   
                    if(OrdersTotal() == 0 && Close[0]<S && Close[1]<Open[1]) 
                           {
                            dl=Close[0];
                            OrderSend(Symbol(),OP_SELL,lot,Bid,3,Bid+SL*0.0001,Bid-TP*0.0001,"",14774,0,Red); 
                            lot=lot*koef;
                            X=2;
                           }

   return(0);
 }
seems to have done everything as it should be.
 
Hello, could you please tell me if it is possible to use the values in the report generated when testing strategies in the script. For example, the profit that is displayed in the report tab.
 
ALigarx:
Here, I think I've done everything as it should be.
I think it's enough to swap the lines
OrderSend(Symbol(),OP_BUY,lot,Ask,3,Ask-SL*0.0001,Ask+TP*0.0001,"",14774,0,Blue);

и

OrderSend(Symbol(),OP_SELL,lot,Bid,3,Bid+SL*0.0001,Bid-TP*0.0001,"",14774,0,Red); 
 

Pro help.

Need a function to calculate the average spread, e.g. 1 minute ago, 3 minutes ago and 5 minutes ago. thanks.

 
T-G:

Pro help.

Need a function to calculate the average spread, e.g. 1 minute ago, 3 minutes ago and 5 minutes ago. thanks.


In order to count it, it needs to be stored as well.
 
Vinin:

In order to count it, it must also be stored.
For 3-5 min you can also store it in variables. you can count each minute as an average of the max-min, and then store it in a remeasured average of 1min or in an array.
 
T-G:
For 3-5 min you can also do it in variables. count each minute as an average of the max-min, and then store it in an over-measured average of 1min or in an array.

This has been around for a long time. And it was on the forum
 
Vinin:
It's been around for a long time. It's been on the forum too.
It can be taken as a basis.
 

Good afternoon.

A word of advice to a newbie.

There is such a script:

#property indicator_chart_window    // Индик. рисуется в основном окне
#property indicator_buffers 1       // Количество буферов
#property indicator_color1 Blue     // Цвет первой линии

double Buf_0[];     // Открытие индикаторных массивов
//--------------------------------------------------------------------
int init()                          // Специальная функция init()
  {
//--------------------------------------------------------------------
   SetIndexBuffer(0,Buf_0);         // Назначение массива буферу
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);// Стиль линии
//--------------------------------------------------------------------
   return;                          // Выход из спец. ф-ии init()
  }
//--------------------------------------------------------------------
int start()                         // Специальная функция start()
  {
   int i,                           // Индекс бара
       Counted_bars;                // Количество просчитанных баров 
   double Arr_1[9999], temp_A;
//--------------------------------------------------------------------
   Counted_bars=IndicatorCounted(); // Количество просчитанных баров 
   i=Bars-Counted_bars-1;           // Индекс первого непосчитанного
   while(i>=0)                      // Цикл по непосчитанным барам
     {
      Buf_0[i]=High[i];             // Значение 0 буфера на i-ом баре
      Arr_1[i]=Close[i]-Open[i];
      Alert(Arr_1[i]);
      i--;                          // Расчёт индекса следующего бара
     }
   ArraySort(Arr_1,WHOLE_ARRAY,0,MODE_DESCEND);
   temp_A=Arr_1[0];
   Comment(DoubleToStr("temp_A",8)," - ", Counted_bars);
//--------------------------------------------------------------------
   return;                          // Выход из спец. ф-ии start()
  }
//--------------------------------------------------------------------

Why does temp_A in Comment() output as 0.00000000, but Alert(Arr_1[i]) in the loop outputs as it should ?

 

How do I programmatically request a schedule download/update?