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

 
Chiripaha:

I've run into this interesting problem:

I write a trivial condition:

,,,

If your A and B prices are the same, the correct condition might look like this

if( А + 0.5 * Point < Б )
{
  // Выполнить действия
}
 
Aizec:

Can I have a little code example?

https://www.mql5.com/ru/code/10831
 


TarasBY:

Roger:
Fractional numbers need to be normalised before comparing them.
Mislaid:

If your A and B prices, the correct condition might look like this

Thank you very much for your help!

I normalise data all the time, which is why I was surprised by a similar phenomenon. But apparently not everything is taken into account in the writing process and by experience, so the advice to "normalise just before comparing the parameters being compared" is very effective. Everything has worked consistently.

 

Good evening all.

Can you please tell me why an order is not opening?

int last;

int start()

(

if (Hour( ) == 12) // if a 12-hour candle is formed on TF 60
last = iBarShift (Symbol (),0,iTime( NULL, 0, 0) ); // remember N of this candle
if (last == 10) // and when this candle is N10

int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,1,Bid-1500*Point,Bid+300*Point, "jfh",123 ); // open the order

)

return(0);

I think iBarShift does not work because the iTime( NULL, 0, 0) ) parameter returns the time in seconds, while I need it in the format D'04.04.2000 19:05 '.

QUESTION 1. Which function returns the opening time of a candle in the format D'04.04.2000 19:05 '

I checked - with this format the iBarShift function works and the order opens. But it only works if the first condition is missing if (Hour( ) == 12)

QUESTION 2 Why does iBarShift not work after the condition if (Hour( ) == 12)

THANK YOU.

 
solnce600:

Good evening all.

Can you please tell me why an order is not opening?

int last;

int start()

(

if (Hour( ) == 12) // if a 12-hour candle is formed on TF 60
last = iBarShift (Symbol (),0,iTime( NULL, 0, 0) ); // remember N of this candle
if (last == 10) // and when this candle is N10

int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,1,Bid-1500*Point,Bid+300*Point, "jfh",123 ); // open the order

)

return(0);

I think iBarShift does not work because the iTime( NULL, 0, 0) ) parameter returns the time in seconds, while I need it in the format D'04.04.2000 19:05 '.

QUESTION 1. Which function returns the opening time of a candle in the format D'04.04.2000 19:05 '

I checked - with this format the iBarShift function works and the order opens. But it only works if the first condition is missing if (Hour( ) == 12)

QUESTION 2 Why does iBarShift not work after the condition if (Hour( ) == 12)

THANK YOU.


i.e. you (if I understood you correctly) open a position on the 22nd bar of the hour frame

int start()
  {

if(iBarOfDayCalc(60)==22)
     int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,1,Bid-1500*Point,Bid+300*Point,"jfh",123 ); //открыть ордер

 return(0);
  }

//  фуннкцыя------------------------
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 26.02.2008                                                     |
//|  Описание : Возвращает расчётный номер бара от начала суток.               |
//|           : Нумерация баров начинается с 1 (единица).                      |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    tf - таймфрейм                       (0 - текущий таймфрейм)            |
//|    dt - дата и время открытия бара      (0 - текущее время)                |
//+----------------------------------------------------------------------------+
int iBarOfDayCalc(int tf=0, datetime dt=0) {
  if (tf<=0) tf=Period();
  if (dt<=0) dt=TimeCurrent();
  if (tf>PERIOD_D1) {
    Print("iBarOfDayCalc(): Таймфрейм должен быть меньше или равен D1");
    return(0);
  }
  double ms=MathMod(dt/60, 1440);      // количество минут от начала суток
  int    bd=MathFloor(ms/tf)+1;        // номер бара от начала суток

  return(bd);
}
 
r772ra:


That is, you (if I understand you correctly) open a position on the 22nd bar of the hour frame

In my example - exactly so, i.e. on the 22nd candle.

But in general - I would like to remember any (with the parameters I need) candle

and after it (memorized) candle will be moved at a desired distance (ie, will be - 5.6....100)

open an order.

Therefore, if I'm not mistaken, the above function of Kim will probably not work for me,

because it counts candles from the beginning of the day and only operates with 24 candles.

I think I need the iBarShift function which can remember any candle.

(For example every fiftieth or hundredth candlestick starting from any candlestick I need).

But this function for some reason I do not work(the details I outlined in the first post)

I would be grateful if you could help me find answers to my questions.

Thank you very much for your participation.

 

Good afternoon, could you please advise how to make sure that after opening this particular position the EA code starts working from the beginning, when I do

if (ticketbuy>0)
{
return;
}

I don't want it to open more orders by other conditions and I have a few more to open. I have to open several more orders. Thank you.

 
Vinin:

If there are enough indicator buffers, you can do it without objects


but how? if the indicator is windowed, how can you display the arrows on the chart? I only use 4 buffers

 

Good afternoon. Sorry to intrude on an ongoing conversation... If you have a minute ... I have an indicator that draws the arrow up and down I need to make an EA for it I can say I'm just getting started learning muell and not dealing with indicators

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 blue

#property indicator_color2 Red

//---- input parameters

extern int NumBars=500;

//---- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

double spread;

maybe someone has a template

 

Please advise if anyone knows. Gepard 5.0 Expert Advisor on Forex4you is opening some trades with big minus. Where can I adjust the settings?