[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 350

 

How do I memorise my index bar? When new bars appear, the index changes. For example: A wave crossing occurred, the next bar will be a zero bar. I need to memorize the wave value on this bar and use it in indicator calculations on the following bars. How do I initialize this index? Or how to do it ?

 
david2:

How do I memorise an index bar?

 datetime Time_bar;// в глобальных переменных


//запоминаем бар по времени открытия
 if(...пересечение машек...) Time_bar=Time[0];
 

// определяем индекс бара в любой момент
int bar=-1;
for(int i=0;i<1000;i++){
    if(Time[i]==Time_bar) { bar=i;break; }                   
                        }
 
KONDOR:

Thank you very much, I'll try it that way.
 
Can you advise whether there is a translator from C or C++ to MQL4? That is, it would be more convenient for me to write it in C and then translate it?
 
-xlapex-:

Tried this, the result is the same - zero.

int start() {

int mas2[10][2],min_1,min_2,min_V1,min_V2;


for(int i=1;i<Q_Bars;i++)
{
min_1 =ArrayMinimum(Volume, Q_Bars,1); //определяем индекс бара с минимальным объемом
min_V1=iVolume(0,0,min_1); //величина этого объема

mas2[i,0]=Volume[i]; //заполняем 1-ю часть двумерного массива объемами
mas2[i,1]=i; //вторую часть - соответствующими им индексами
}
ArraySort(mas2); //сортируем по величине объемов
min_V2=mas2[2,0]; //определяем второй после минимального объем
min_2=mas2[2,1]; //соответствующий ему индекс бара

H1= NormalizeDouble(High[min_2],4); //нормализуем level по знакам после запятой
create_line("", H1, Ex_col_2, 0, 2); //пытаемся нарисовать линию

return(0); //Bывод: ничего не рисуется, что еще ему надо - ????
}
//--------------------------------------------------------------------
void create_line(string name_line,double level,color c,int style,int w)
{
ObjectCreate(name_line, OBJ_HLINE, 0, 0,0);
ObjectSet(name_line, OBJPROP_PRICE1, level);
ObjectSet(name_line, OBJPROP_COLOR, c);
ObjectSet(name_line, OBJPROP_STYLE, style);
ObjectSet(name_line, OBJPROP_WIDTH, w);

}



And why is the object name empty? Write something: "Object_name" instead of "" when calling create_line("", H1, Ex_col_2, 0, 2 );


 
artmedia70:

Thank you, I've already done everything.
 

GBPUSD does not open

int start()
{
OrderSend("GBPUSD",OP_SELL,0.1,Ask,0,Ask+400*Point,Ask-100*Point);
Alert GetLastError();
return()

}

and at compilation it generates errors relating to Alert GetLastError();

Could it be that the broker's 100 points is too close (5 digits at the broker)?

 
Danil93:

GBPUSD does not open

int start()
{
OrderSend("GBPUSD",OP_SELL,0.1,Ask,0,Ask+400*Point,Ask-100*Point);
Alert GetLastError();
return();

}

and at compile time I get errors related to Alert GetLastError();

Could it be that the broker's 100 pips is too close (5 digits at the broker)?


Maybe, because at 4 digits it's only 10ppt. Put at least 101 instead of 100 and check.
 
Hi all. Can you tell me if the tester takes swaps into account? Because my profits on some pairs are melting suspiciously (especially on trades which are hanging on for a long time).
 
Danil93:

GBPUSD won't open


and when compiling it writes errors related to Alert GetLastError();

could it be that the broker's 100 pips is too close (5 digits at the broker)?


int start()
{
  OrderSend("GBPUSD",OP_SELL,0.1,Ask,0,Ask+400*Point,Ask-100*Point);
  Alert(GetLastError());
  return();

}
Reason: