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

 

Need to know the smallest and largest fractal for the last n bars, what's wrong here? Please help!

   for (ii = 0; ii = n; ii++)
      {
         i = iFractals(NULL, 0, MODE_LOWER, ii);
         if (i < StopLos_L) StopLos_L = i;
         i = iFractals(NULL, 0, MODE_UPPER, ii);
         if (i > StopLos_H) StopLos_H = i;
      }

 
solnce600:

I decided to take what I thought was a simpler route.

Not to delete the pending order - but to place a pending order only if a five-minute candle has not finished

That is, the pending order should be placed only when two conditions are met. If the first condition is met

- I checked, the order is set.

Of course it is because this condition is ALWAYS true, it simply cannot be false. It simply cannot be false since it means the zero bar exists at all.

How should we define the second condition, i.e. the pending order is set only if 5 minutes have not elapsed. if (---------- && ?????????)

Please clearly state the condition in words. It is not clear yet whether you want to place the pending order at the start of a new candlestick or what?
 
belozad:

Need to know the smallest and largest fractal for the last n bars, what's wrong here? Please help!

   for (ii = 0; ii = n; ii++)
      {
         i = iFractals(NULL, 0, MODE_LOWER, ii);
         if (i < StopLos_L) StopLos_L = i;
         i = iFractals(NULL, 0, MODE_UPPER, ii);
         if (i > StopLos_H) StopLos_H = i;
      }



how is the i variable declared, can we have a look?
 
alsu:

the i variable as declared, may I have a look?


int ii;

double i;

 
belozad:


It should work like this:

   int ii;
   double i;
   double StopLos_L,StopLos_H;

   for (ii = 0; ii <= n; ii++)
      {
         i = iFractals(NULL, 0, MODE_LOWER, ii);
         if (i < StopLos_L || ii==0) StopLos_L = i;
         i = iFractals(NULL, 0, MODE_UPPER, ii);
         if (i > StopLos_H || ii==0) StopLos_H = i;
      } 
 
alsu:

It should work like this:


Damn, it's obvious.
ii <=n


alsu - many, many thanks =)

 
artmedia70:
You can

Can you tell me if it is possible to paint the body of a desired candle in an EA?
Where can I see how to do this, I really need it.
 
beginner:
Can you tell me if it is possible to paint the body of the desired candle in the EA?
Where can I see how to do this, I really need it.

https://www.mql5.com/ru/code/7835 Only it is an indicator. You have to use objects in the EA
 
alsu:

Of course it is, because this condition is ALWAYS true, it simply cannot be false. As it means that the zero bar exists at all.

Please clearly state the condition in words. It is not clear yet, do you want to place the pending order at the start of a new candlestick or what?

Thank you. Sorry, I'm a bit confused. In this case I should not place a pending order but a market order at Open[0]+30 pips.

But we should only set the market order from the beginning of formation of a zero candle to the next following one.

I.e., not setting a market order within 5 minutes, according to my idea, is equivalent to the cancellation of a pending order if it is not opened within 5 minutes.

How should I write the second condition?

And did I correctly set the opening price of the market order?

Thank you.

 int start()

  {
 double Price=Open[0]+300*Point;        
 double SL=Price-300*Point;     
 double TP=Price+150*Point;
 if (Time[0]&& ???????)                         
 int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Price,3,SL,TP );
 
solnce600:

Thank you. Sorry, I'm a bit confused. In this case I should not set a pending order, but a market order at Open[0]+30 pips.

But we should only set the market order from the beginning of a zero candle to the next following one.

I.e., not setting a market order within 5 minutes, according to my idea, is equivalent to the cancellation of a pending order if it is not opened within 5 minutes.

How should I write the second condition?

And did I correctly set the opening price of the market order?

Thank you.


Okay, I have it now. If the price of the current bar reaches Open[0] + 30, we open. If the bar has ended, Open[0] has changed and the opening level is shifted accordingly. There should be only one trade in the market, right?

Then it is like this:

int start()

{

 double Price=Open[0]+300*Point;        
 double SL=NormalizeDouble (Price-300*Point, Digits);         
 double TP=NormalizeDouble (Price+150*Point, Digits);    
 
 if (OrdesTotal()==0 && Close[0]>=Price)                         
    int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP );

}

There is no need to track the new bar, because when it is formed, the system will automatically add a new value to Open[0] and this means that the new level will be calculated correctly. Please note that the BUY deal is opened at the current Ask price, while it is closed (TP and SL) at Bid price. In addition, price values must be normalized.

Reason: