[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 80

 
tommy27:
Thanks, I did it with Close and as you advised:
but the result is updated only when a new bar appears and I want to see and record changes on every tick.

If the EA is not looped, the result will change on every tick
 

Thank you all, separately everything works:

//+------------------------------------------------------------------+
//|                                                        Delta.mq4 |
//|                                                          tommy27 |
//|                                                  tommy27@mail.ru |
//+------------------------------------------------------------------+
#property copyright "tommy27"
#property link      "tommy27@mail.ru"

double 
       StartPrice1,
       Delta1,
       Price00;


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   Price00 = 5000;
StartPrice1 =  iClose(0,0,0);
//StartPrice1 = Close[0];
Delta1 = MathAbs (Price00 - StartPrice1);
//if (Delta1>1000) Delta1=0;
Comment (Delta1);
Print ("Raznica= ",Delta1);
//----
   return(0);
  }
//+------------------------------------------------------------------+

But the main code only counts on bar closure, I'll look into it.

 
PapaYozh:

If the EA is not looped, the result will change on every tick
Thank you.
 
There are two options in OrderSelect():
MODE_TRADES - order is selected among open and pending orders,
MODE_HISTORY - order is selected among closed and deleted orders.

- Am I correct to understand that MODE_TRADES is used only with OrdersTotal(), and MODE_HISTORY - only with OrdersHistoryTotal()?
- If so, why are they needed at all?
Thank you!
 
chief2000:
There are two options in OrderSelect():
MODE_TRADES - order is selected among open and pending orders,
MODE_HISTORY - order is selected among closed and deleted orders.

- Am I correct to understand that MODE_TRADES is used only with OrdersTotal(), and MODE_HISTORY - only with OrdersHistoryTotal()?
- If so, why are they needed at all?
Thank you!


You understand correctly.

Your second question is not clear. If you select an order by its position, you need to know the total number of orders

 
PapaYozh:


You understand correctly.

Your second question is not clear. If you select an order by its position, you need to know the total number of orders

Both of these parameters (MODE_TRADES and MODE_HISTORY) are only used in case of SELECT_BY_PO, but you could remove them completely (use the default one in MT4 - for OrdersTotal() and OrdersHistoryTotal(), respectively).
It's not a matter of principle, the main thing for me was the answer to the first question.
Thank you!
 

alsu, open buy if price has risen more than 20 pips in the last 10 minutes; open sell if price has fallen more than 20 pips in the last 10 minutes.

And if it's not a problem: Open buy if the current price is by some more than the previous bar's maximum, open sell if the current price is by some less than the previous bar's minimum.

P.S. The code to open buy and sell is already in the board, so I don't need to describe them... I'm more interested in how to correctly write the opening conditions described above...

 
oDin48:

alsu, open buy if price has risen more than 20 pips in the last 10 minutes; open sell if price has fallen more than 20 pips in the last 10 minutes.

Do I open exactly at the moment when the level is crossed or after 10 minutes?)


And if it's not too much trouble, one more problem: Open buy if the current price is a bit higher than the high of the previous bar, open sell if the current price is a bit lower than the low of the previous bar.

extern int level = 10; //в пунктах

....
int start()
{
...

   RefreshRates();

   if(Bid>High[1]+level*Point)
   {
      //BUY
   }

   if(Bid<Low[1]-level*Point)
   {
      //SELL
   }
...
}
 

alsu, exactly when crossing, check the time and if it falls within the time range make a trade.

Thank you. Going to try it now.

 
oDin48:

alsu, exactly when you cross, check the time and if it falls in the time range make a trade.

In such a variant, you have to remember the tick history for the last 10 minutes... the code is not trivial