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

 

The part is sorted out.

Why does it print zeros when writing bits to an array that is dynamic?

//---------------------
extern int MaxDrawTicks=100;
extern int Num_Aver_of_Ticks=5;  
double     xBuffer_Time []; // Массив значений  
                         // В котором индекс - номер тика, значение - это бид 
int SIZE=0;               // Вспомогательная переменная для массива                                  
int tickCounter, tickCounter_Current; 
//+------------------------------------------------------------------+
int init()
  {   
//--- устанавливаем размер динамического массива
   if(ArrayResize(xBuffer_Time,SIZE)<0) {Print(" Ошибка в изменении размера массива времени поступления тиков "); return(false);}
//--- установим индексацию для буфера как в таймсерии для динамического массива
  // ArraySetAsSeries(xBuffer_Time,true);    
//---   Возвращает количество элементов указанного массива. 
   SIZE=ArraySize(xBuffer_Time);
   if (SIZE>=0) Print("Размер массива: ",SIZE);
   else Print("Ошибка. Массив не создан ",SIZE);        
   ArrayInitialize(xBuffer_Time, 0);
   return(0);
  }  
//+------------------------------------------------------------------+
int start()
  {  
   //ArrayResize(ValueArr,size);
   //ValueArr[size-1] = GetValue();
   //size++; 
 //----------------------------------------  
   ArrayResize(xBuffer_Time,SIZE);
   xBuffer_Time[SIZE-1] = Bid; //NormalizeDouble((iTime (_Symbol,1,0)-_start), 2); 
   SIZE ++;
   Print (" Значение xBuffer_Time[SIZE-1] = ", DoubleToStr(xBuffer_Time[SIZE-1],Digits) );
   Print (" Значение SIZE = ", DoubleToStr(SIZE,2) );  
 //---------------------------------------      
//------------
   return(0);
  }

 

The issue has been resolved. Whoever needs to use it.

How to write data to a dynamic array.

//---------------------
extern int MaxDrawTicks=100;
extern int Num_Aver_of_Ticks=5;  
double     xBuffer_Time []; // Массив значений   динамический
                            // В котором индекс - номер тика, значение - это бид 
int SIZE=0;                 // Вспомогательная переменная для массива                                  
int tickCounter, tickCounter_Current; 
//+------------------------------------------------------------------+
int init()
  {   
//--- устанавливаем размер динамического массива
   if(ArrayResize(xBuffer_Time,2000000)<0) {Alert(" Ошибка в изменении размера массива времени поступления тиков "); return(false);}
//--- установим индексацию для буфера как в таймсерии для динамического массива
  // ArraySetAsSeries(xBuffer_Time,true);    
//---   Возвращает количество элементов указанного массива. 
   int S=ArraySize(xBuffer_Time);
   if (S>=0) Alert("Размер массива: ",S);
   else Print("Ошибка. Массив не создан ",S);        
   ArrayInitialize(xBuffer_Time, 0);
   return(0);
  }  
//+------------------------------------------------------------------+
int start()
  {  
   //ArrayResize(ValueArr,size);
   //ValueArr[size-1] = GetValue();
   //size++; 
 //----------------------------------------  
   ArrayResize(xBuffer_Time,SIZE);
   xBuffer_Time[SIZE-1] = Bid; //NormalizeDouble((iTime (_Symbol,1,0)-_start), 2); 
  
   if ( SIZE >= 0 && ArraySize(xBuffer_Time) < 2147483647)
      {
      Alert (" Значение xBuffer_Time[SIZE-1] = ", DoubleToStr(xBuffer_Time[SIZE-1],Digits) );
      Alert (" Значение SIZE = ", DoubleToStr(SIZE,2) );  
      } 
    SIZE ++;   
 //---------------------------------------      
//------------
   return(0);
  }
 

Hello, I trade on Renko chart "RenkoLiveChart_v4.13.mq4".

Can't run or open a trade via EA on offline chart.

 
Top2n:

Hello, I trade on Renko chart "RenkoLiveChart_v4.13.mq4".

Can't run or open a trade via EA on offline chart.

I have to emulate ticks on offline charts, the terminal does not send tick arrival signal on them.

For example like in this script:

#include <WinUser32.mqh>

#import "user32.dll"


//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
{
    int whdl=WindowHandle (Symbol(), Period());    
        while(!IsStopped())
         {
                PostMessageW (whdl, WM_COMMAND, 33324, 0);
                Sleep(100);
         }
        return(0);
}
 
Thank you all - I've figured it out.
 
_Roman:

The issue has been resolved. Whoever needs to use it.

How to write data to a dynamic array.


Thank you! For me, it's a dark forest, forest array, logging, etc. ;)
 
evillive:

In offline charts it is necessary to emulate ticks, the terminal does not send a signal of a new tick to them.

For example as in this script:

Any other suggestions?

I connect the script to an offline chart, the terminal hangs. May be possible to mount code in robot, then what to do with#import "user32.dll"

 

Hello. Please help. I want to write an EA: If there are no open trades and the open price of the first bar is less than the close price of the first bar and the open price of the second bar is less than the close price of the second bar, then open a deal... But the EA in the tester starts opening deals one after another, I can not understand what is wrong. I CAN NOT UNDERSTAND WHAT IS THE PROBLEM.


int init;

int start()
{

int bar1;
int bar2;
int   stoploss=100; 
int   takeprofit=100;
int       slipage=2;
int total;
//-------------------------------------------------------------------+
  
  if ( OrdersTotal()<1 &&  Open[bar1]>Close[bar1] && Open[bar2]>Close[bar2])
    
     {OrderSend("EURUSD",OP_BUY,0.1,Ask,slipage,Ask-stoploss*Point,Ask+takeprofit*Point,"",123,0,Red);}
     
    //-------------------------------------------------------------------+  
     
                   
 
 return;}
 
rylay:

Hello. Please help. I want to write an EA: If there are no open trades and the open price of the first bar is less than the close price of the first bar and the open price of the second bar is less than the close price of the second bar, then open a deal... But the EA in the tester starts opening deals one after another, I can not understand what is wrong. I CAN NOT UNDERSTAND WHAT IS THE PROBLEM.


int init;

int start()
{

int bar1;
int bar2;
int   stoploss=100; 
int   takeprofit=100;
int       slipage=2;
int total,ticket;

//-------------------------------------------------------------------+
  
  if ( OrdersTotal()<1 &&  Open[bar1]>Close[bar1] && Open[bar2]>Close[bar2])
      if(V1()==true) 
     {
       ticket = OrderSend("EURUSD",OP_BUY,0.1,Ask,slipage,Ask-stoploss*Point,Ask+takeprofit*Point,"",123,0,Red);
      }
     
    //-------------------------------------------------------------------+                    
 return;}
//+------------------------------------------------------------------+
bool V1(){
  int      i, k=OrdersTotal();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
     if (OrderType()==OP_BUY) {
      return(false);
   }
  }    
 }
 return(true); 
}

bool V2(){
  int      i, k=OrdersTotal();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
     if(OrderType()==OP_SELL) {
      return(false);
   }
  }
 }
 return(true); 
}
 
Top2n:

Thank you very much. It all works. I'll look into what you wrote...
Reason: