I guess Ilnar had some difficulties with fractal price levels. That's why I suggest using my function:
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 07.10.2006 |//| Описание : Поиск ближайшего фрактала. |//+----------------------------------------------------------------------------+//| Параметры: |//| sy - наименование инструмента (NULL - текущий символ) |//| tf - таймфрейм ( 0 - текущий ТФ) |//| mode - тип фрактала (MODE_LOWER|MODE_UPPER) |//+----------------------------------------------------------------------------+doubleFindNearFractal(stringsy="0", inttf=0, intmode=MODE_LOWER){ if(sy=="" || sy=="0")sy=Symbol();
doublef=0;
intd=MarketInfo(sy, MODE_DIGITS), s;
if(d==0)if(StringFind(sy, "JPY")<0)d=4; elsed=2;
for(s=2; s<100; s++){ f=iFractals(sy, tf, mode, s);
if(f!=0)return(NormalizeDouble(f, d));
} Print("FindNearFractal(): Фрактал не найден");
return(0);
}
Function FindNearFractal() searches for the nearest fractal of the specified type at the specified symbol, at the given timeframe, and returns its price level. Knowing the price level of the location of the fractal, it is already easy to place an order at that level.
Is it possible for the function to return two values, e.g., the number of the bar where the fractal is located, or should we connect another one?
xrust писал (а): Is it possible for the function to return two values, e.g. also the bar number where the fractal is located, or should I connect another one?
And why return two values when one - the bar number - is enough? For this purpose, in the statement:
return(NormalizeDouble(f, d));
write the value of the bar counter s instead of the price level. On the output you will get the bar number of the fractal. And you will get the price level with one of iHigh () or iLow() functions depending on the fractal type.
ah... Well, if in principle, you can use an array passed by reference. Then the number of returned parameters would be limited by the size of the array.
Returns a flag for the existence of an order with the specified lot size. True - order exists (set), False - order doesn't exist (not set). You can limit the list of orders to be checked using the function parameters:
sy - Name of instrument. If you set this parameter, the function will only check the orders of the specified instrument. NULL means current instrument, and "" (by default) means any instrument.
op - Operation, 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.
lo - Size of a lot with an accuracy of two decimal places. The default value is 0 - any lot size.
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 28.11.2006 |//| Описание : Возвращает флаг существования ордера по размеру лота. |//+----------------------------------------------------------------------------+//| Параметры: |//| sy - наименование инструмента ("" - любой символ, |//| NULL - текущий символ) |//| op - операция (-1 - любой ордер) |//| mn - MagicNumber (-1 - любой магик) |//| lo - лот ( 0 - любой лот) |//+----------------------------------------------------------------------------+boolExistOrdersByLot(stringsy="", intop=-1, intmn=-1, doublelo=0){inti, k=OrdersTotal(), ot;
lo=NormalizeDouble(lo, 2);
if(sy=="0")sy=Symbol();
for(i=0; i<k; i++){if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){ot=OrderType();
if(ot>1 && ot<6){if((OrderSymbol()==sy || sy=="") && (op<0 || ot==op)){if(mn<0 || OrderMagicNumber()==mn){if(lo<=0 || NormalizeDouble(OrderLots(), 2)==lo)return(True);
}}}}}return(False);
}
Returns the lot size of the last placed order or -1. You can limit the list of orders to be checked using the function parameters:
sy - Name of the 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 - Operation, type of pending order. Valid values: OP_BUYLIMIT, OP_BUYSTOP, OP_SELLLIMIT, OP_SELLSTOP or -1. The default value of -1 means any order.
mn - Order identifier (MagicNumber). Default value -1 means any MagicNumber.
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 28.11.2006 |//| Описание : Возвращает размер лота последнего выставленного ордера или -1 |//+----------------------------------------------------------------------------+//| Параметры: |//| sy - наименование инструмента ("" - любой символ, |//| NULL - текущий символ) |//| op - операция (-1 - любая позиция) |//| mn - MagicNumber (-1 - любой магик) |//+----------------------------------------------------------------------------+doubleGetLotLastOrder(stringsy="", intop=-1, intmn=-1){datetimeo;
doublel=-1;
inti, 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==""){if(OrderType()>1 && OrderType()<6){if(op<0 || OrderType()==op){if(mn<0 || OrderMagicNumber()==mn){if(o<OrderOpenTime()){o=OrderOpenTime();
l=OrderLots();
}}}}}}}return(l);
}
Returns the setting price of the last opened order or 0. You can limit the list of orders to be checked with function parameters:
sy - Name of the 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 - Operation, type of pending order. Valid values: OP_BUYLIMIT, OP_BUYSTOP, OP_SELLLIMIT, OP_SELLSTOP or -1. The default value of -1 means any order.
mn - Order identifier (MagicNumber). Default value -1 means any MagicNumber.
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 28.11.2006 |//| Описание : Возвращает цену установки последнего ордера или 0. |//+----------------------------------------------------------------------------+//| Параметры: |//| sy - наименование инструмента ("" - любой символ, |//| NULL - текущий символ) |//| op - операция (-1 - любая позиция) |//| mn - MagicNumber (-1 - любой магик) |//+----------------------------------------------------------------------------+doubleGetOrderOpenPrice(stringsy="", intop=-1, intmn=-1){datetimet;
doubler=0;
inti, 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==""){if(OrderType()>1 && OrderType()<6){if(op<0 || OrderType()==op){if(mn<0 || OrderMagicNumber()==mn){if(t<OrderOpenTime()){t=OrderOpenTime();
r=OrderOpenPrice();
}}}}}}}return(r);
}
Every man has the right to the left... hee... I'm going to have a bit of fun with this
Ilnar, in the topic Pending Fractal Orders, asked, How to make pending orders on fractals?
I guess Ilnar had some difficulties with fractal price levels. That's why I suggest using my function:
Function FindNearFractal() searches for the nearest fractal of the specified type at the specified symbol, at the given timeframe, and returns its price level. Knowing the price level of the location of the fractal, it is already easy to place an order at that level.
Is it possible for the function to return two values, e.g. also the bar number where the fractal is located, or should I connect another one?
No, it's clear, I'm basically asking.
Function ExistOrdersByLot().
Returns a flag for the existence of an order with the specified lot size. True - order exists (set), False - order doesn't exist (not set). You can limit the list of orders to be checked using the function parameters:
Examples of how to use the ExistOrdersByLot() function.
Attached, as usual, is a working script with the above examples.
GetLotLastOrder() function.
Returns the lot size of the last placed order or -1. You can limit the list of orders to be checked using the function parameters:
Examples of how to use GetLotLastOrder().
Attached here is a traditionally working script with the above examples.
GetOrderOpenPrice() function.
Returns the setting price of the last opened order or 0. You can limit the list of orders to be checked with function parameters:
Examples of how to use GetOrderOpenPrice().
Attached is a perfectly working script with the above examples.