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

 

Why aren't the orders opening!

Please tell me why this code doesn't work.

I specifically chose a period of the chart in 2000 (when the fifth sign was 0 everywhere) in which there is a candle opened at a price that occurs among the values of the array.

According to my idea - at their opening should trigger an order - but it does not happen ......P O M U ????


int start()



{

 double Price=iOpen (Symbol (),0,0);        
 double SL=NormalizeDouble (Price-3000*Point, Digits);         
 double TP=NormalizeDouble (Price+100*Point, Digits);
 
 double massiv [4]={0.85370,0.85690,    0.85970 ,0.86170};//объявление и инициализация массива


 double value =  Bid ;// параметру value функции ArrayBsearch присваивается значение текущей цены
 int S = ArrayBsearch(  massiv[4],  value, WHOLE_ARRAY,  0, MODE_ASCEND); //функция ищет самое близкое к текущей цене значение
 if (Bid == massiv[S])//если текущая цена равна значению возвращенному  функцией .
 if (Bid==Price  )// и данная цена есть цена открытия нового бара
 OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP,"jfh",123 );//открыть ордер       
}
 
solnce600:

There are 100 values with a comma after the first character (i.e. price)

Highlighting a line

Home - find and replace

Changing all the commas to dots - successful.

Now I need to put commas between the values

Now do the following: File - Save as - select CSV file type (delimiters - commas). Save. As an output we have a text file of the necessary format...

 
solnce600:

Why aren't the orders opening!

Please tell me why this code doesn't work.

I specifically chose a period of the chart in 2000 (when the fifth sign was 0 everywhere) in which there is a candle opened at a price that occurs among the values of the array.

In my mind - at their opening order should work - but it does not happen ......P O M U????



int S = ArrayBsearch(  massiv,  value, WHOLE_ARRAY,  0, MODE_ASCEND); //функция ищет самое близкое к текущей цене значение

Massiv[4] means the 4th element of the array massiv, I need to pass an array into the function, to make a search...

 
alsu:

Now: File - Save as - select CSV file type (comma delimiters). Save. We have on an output a text file of the necessary format...



I got it. Thank you very much. Could you please tell me why my function doesn't work (post above).

Thank you very much. If I learn to program...... it will be because of you.....!

 
solnce600:

Why aren't the orders opening!

Please tell me why this code doesn't work.

I specifically chose a period of the chart in 2000 (when the fifth sign was 0 everywhere) in which there is a candle opened at a price that occurs among the values of the array.

In my mind - at their opening order should work - but it does not happen ......P O M U ????


It would also be nice if when comparing double numbers, we could write

 if (Bid == massiv[S])

like this:

 if (NormalizeDouble (Bid-massiv[S],Digits)==0)
 
alsu:

massiv[4] refers to the 4th element of the array massiv, and you need to pass the array itself into the function to do a search...

Got it. Thank you very much.
 
solnce600:

Why aren't the orders opening!

Please tell me why this code doesn't work.

I specifically chose a period of the chart in 2000 (when the fifth sign was 0 everywhere) in which there is a candle opened at a price that occurs among the values of the array.

In my mind - at their opening order should work - but it does not happen ......P O M U ????

It's already time to move on to the "grown-up" method!!! - Experiment with your code to get results.

Tip: get used to comparing variables through normalising their differences:

    double ld_Delta = 10. * Point;
    if (NormalizeDouble (MathAbs (Bid - Price), Digits) <= ld_Delta)// и данная цена есть цена открытия нового бара
    {OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP,"jfh",123);}//открыть ордер       

and for the experiment I mentioned, "play around" with ld_Delta.

 
solnce600:

I got it. Thank you very much. Could you please tell me why my function does not work (post above)?

Thank you very much. If I learn how to program...... it will be thanks to you.....!


If you learn, it will be because of your diligence and hard work. My role is very modest, and selfish goals (helping you, train their own ability to quickly find bugs and errors, which reduces their own time spent on programming, and at the same time keeps my brain toned. In addition, what if some valuable idea slips through? I'll steal it:)))
 
incluide
alsu:

If you learn, it's thanks to your diligence and hard work. My role is very modest, and goal self-serving (helping you, train your own ability to quickly find bugs and errors, which reduces your own time spent on programming, and at the same time keeps my brain toned. In addition, what if some valuable idea slips through? I'll steal it:)))

It can take a long time to find the answer to a question on your own (because you don't know which way to look).

Any other tips?

I want to declare and initialize an array in a include file.

Called the wizard.

Chose - Bibliotek functions.

Assigned a name.

Removed everything and declared and initialized the array.

I saved the file in the incluide folder with the extension mq4 instead of mqh.

I have inserted a line to call the file and specified the extension mqh in the code.

But the compiler gives an error

'UYTR.mqh' - cannot open the program file C:\Program Files\Alpari NZ MT4(2)\experts\hhhh.mq4 (12, 2)

int start()



{

 double Price=iOpen (Symbol (),0,0);        
 double SL=NormalizeDouble (Price-3000*Point, Digits);         
 double TP=NormalizeDouble (Price+100*Point, Digits);
 
 #include <UYTR.mqh> 


 double value =  Bid ;// параметру value функции ArrayBsearch присваивается значение текущей цены
 int S = ArrayBsearch(  massiv,  value, WHOLE_ARRAY,  0, MODE_ASCEND); //функция ищет самое близкое к текущей цене значение
 if (Bid == massiv[S])//если текущая цена равна значению возвращенному  функцией .
 if (Bid==Price  )// и данная цена есть цена открытия нового бара
 OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP,"jfh",123 );//открыть ордер       
}

Probably, the matter is different extensions between the file in the code call and the file in incluide folder.

Please, advise me what to do in this situation.

Thank you.

 
solnce600:
incluide

It can take a long time to find the answer to a question on your own (because you don't know which way to look).

Any other tips?

I want to declare and initialize an array in a include file.

Called the wizard.

Chose - Bibliotek functions.

Assigned a name.

I cleaned up everything and declared and initialized the array.

I saved the file in the incluide folder with the extension mq4 instead of mqh.

I have inserted a line to call the file and specified the extension mqh in the code.

But the compiler keeps crashing.

'UYTR.mqh' - cannot open the program file C:\Program Files\Alpari NZ MT4(2)\experts\hhhh.mq4 (12, 2)

Probably the difference in extensions between the file in code call and the one in incluide folder.

Please advise what to do in this situation.

Thank you.


If you are using wizard, you can create directly a include file, which will be saved with extension mqh in folder include. After this, you can add it into any program by #include <>.


that is
not select - bibliotek of functions,
a MQH header file