Useful features from KimIV - page 48

 

I.e. adding a constant does not affect the result

I wanted to make a quick indicator, but it didn't work (

 
Prival писал (а) >>

It is a good rule of thumb to distrust. Check it in any maths package. We'll post the results. I'll do it in MathCade right now.

Good, but you have to check before you express disbelief. >> Excuse me.

 
TheXpert писал (а) >>

A good one, but you have to check before expressing disbelief. I beg your pardon.

If you have any doubts, express them and be sure to do so. After all, you don't want to go back to them, you don't want to look for errors. You need to be sure that everything was done correctly. But all the same there are no guarantees http://www.citforum.ru/programming/digest/scofdebug/.

 

Good afternoon! It turns out that the fractal functions have been disjointed all over the branch.

We have found two of them:

one returns the number of bars between the last fractals (BarsBetweenLastFractals(string sy="", int tf=0)),

the other one, the price level of the last fractal (p.37).

In order to close the fractal subject in a harmonious way, we need one more function. It returns the bar number of the top of the last fractal!

Igor! If it is not too difficult for you. Could you produce and display such a function ?

 

Function ExistOrdersByPrice().

Returns a flag for the existence of an order at the given set price. True - order exists (set), False - order does not exist (not set). You can limit the list of orders to be checked using the function parameters:

  • sy - Name of market instrument. If this parameter is given, the function will only check the orders of the specified instrument. NULL means the current instrument, and "" (by default) means any instrument.
  • op - Type of trade, type of pending order. Valid values: OP_BUYLIMIT, OP_BUYSTOP, OP_SELLLIMIT, OP_SELLSTOP or -1. The default value of -1 indicates any order type.
  • mn - Order identifier (MagicNumber). The default value of -1 means any MagicNumber.
  • pp - The price level at which the order is set. The default value of -1 is any price.
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 30.07.2008                                                     |
//|  Описание : Возвращает флаг существования ордеров по цене установки        |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любая позиция)                  |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//|    pp - цена                       (-1   - любая цена)                     |
//+----------------------------------------------------------------------------+
bool ExistOrdersByPrice(string sy="", int op=-1, int mn=-1, double pp=-1) {
  int d, i, k=OrdersTotal();

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) {
        if (OrderType()>1 && OrderType()<6) {
          d=MarketInfo(OrderSymbol(), MODE_DIGITS);
          pp=NormalizeDouble(pp, d);
          if (pp<0 || pp==NormalizeDouble(OrderOpenPrice(), d)) {
            if (mn<0 || OrderMagicNumber()==mn) return(True);
          }
        }
      }
    }
  }
  return(False);
}
 

Examples of how to use the ExistOrdersByPrice() function.

  • Check availability of any order at setup price 1.4
    Message(IIFs(ExistOrdersByPrice("", -1, -1, 1.4), "Есть", "Нет"));
  • Check any order at setup price 1.5 for the current chart instrument
    Message(IIFs(ExistOrdersByPrice(NULL, -1, -1, 1.5), "Есть", "Нет"));
  • Check if there is a BuyLimit order at setup price 1.5 for any instrument
    Message(IIFs(ExistOrdersByPrice("", OP_BUYLIMIT, -1, 1.5), "Есть", "Нет"));
  • Check presence of SellStop order at setup price 1.4 with magic number 123456 on EURUSD
    Message(IIFs(ExistOrdersByPrice("EURUSD", OP_SELLSTOP, 123456, 1.4), "Есть", "Нет"));
  • Check presence of any order at setup price 106 with magic number 987 on USDJPY
    Message(IIFs(ExistOrdersByPrice("USDJPY", -1, 987, 106), "Есть", "Нет"));

P.S. Attached is a script to test the ExistOrdersByPrice() function.

 
rid писал (а) >>
To "close" the fractal theme in a harmonious way, another function is needed. Returning the bar number of the top of the last fractal!

On 13 August 2008 I posted the GetFractalBar function (p.41).

 

The b-Orders library has been posted.

 
KimIV писал (а) >>

On 13 August 2008, I posted the GetFractalBar function (page 41).

Yes indeed! >> Thank you!

 
KimIV писал (а) >>

The b-Orders library has been posted.

A very useful library! On behalf of everyone here "thanks a lot!"