Please tell me the way out. I have an indicator called Average Directional Movement Index and it draws dashed lines. I want to catch crossover lines. I don't think it's necessary to draw dashed lines.
TarasBY: Well, maybe this function should return this very price level (as in the previous variant)! Besides, your code contains an undeclared variable "T".
Well, it returns it)
about undeclared variables - sorry. I stand corrected.
double M - crossing price level. This variable is declared at the beginning.
This function closes a position at the market price if the price stomps for a number of bars in the zone close to the TakeProfit or tries to exit this zone. Selection of positions to be closed is specified using external parameters:
sy - Name of instrument. If we set this parameter, the function will only check positions of the specified instrument. NULL means the current instrument, while "" (by default) means any instrument.
op - Trade operation, position type. Valid values: OP_BUY, OP_SELL or -1. The default value -1 means any position.
mn - Position identifier (MagicNumber). The default value of -1 means any MagicNumber.
tf - Chart timeframe, on which to count the bars, during which the price stomps in the TakeProfit zone. The default value 0 is the current timeframe.
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 01.04.2012 |//| Описание : Закрытие позиций при нахождении цены в зоне TakeProfit |//| в течение заданного количества баров, |//| а также при попыте выйти из этой зоны. |//+----------------------------------------------------------------------------+//| Параметры: |//| sy - наименование инструмента ("" - любой символ, |//| NULL - текущий символ) |//| op - операция (-1 - любая позиция) |//| mn - MagicNumber (-1 - любой магик) |//| tf - таймфрейм ( 0 - текущий таймфрейм) |//+----------------------------------------------------------------------------+void ClosePosByTakeProfitZone(string sy="", int op=-1, int mn=-1, int tf=0) {
double pa, pb, po, pp, tp;
int i, k=OrdersTotal();
if (sy=="0") sy=Symbol();
for (i=k-1; i>=0; i--) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) {
if ((mn<0 || OrderMagicNumber()==mn) && OrderTakeProfit()>0) {
po=MarketInfo(OrderSymbol(), MODE_POINT);
if (po==0) Message("В обзоре рынка отсутствует символ "+OrderSymbol());
else {
if (OrderType()==OP_BUY) {
RefreshRates();
pb=MarketInfo(OrderSymbol(), MODE_BID);
pp=iLow(OrderSymbol(), tf, iLowest(OrderSymbol(), tf, MODE_LOW, TP.ZoneBars, 0));
tp=OrderTakeProfit()-TP.ZonePoint*po;
if (pp>tp || (pb<tp && (iHigh(OrderSymbol(), tf, 0)>tp) || (iHigh(OrderSymbol(), tf, 1)>tp))) ClosePosBySelect();
}
if (OrderType()==OP_SELL) {
RefreshRates();
pa=MarketInfo(OrderSymbol(), MODE_ASK);
pp=iHigh(OrderSymbol(), tf, iHighest(OrderSymbol(), tf, MODE_HIGH, TP.ZoneBars, 0));
tp=OrderTakeProfit()+TP.ZonePoint*po;
if (pp<tp || (pb>tp && (iLow(OrderSymbol(), tf, 0)<tp) || (iLow(OrderSymbol(), tf, 1)<tp))) ClosePosBySelect();
}
}
}
}
}
}
}
Attached is an Expert Advisor for testing the ClosePosByTakeProfitZone() function. you can test it both in the tester and online.
Started studying your functions not too long ago, on page 36 I didn't quite understand the functions, please help me to understand:
Function GetArrowInterval().
//+------------------------------------------------------------------+ //| Returns signal pointer setting interval | //+------------------------------------------------------------------+ int GetArrowInterval() { int p = Period();
switch (p) { case 1: return(4); case 5: return(5); case 15: return(6); case 30: return(8); case 60: return(10); case 240: return(20); case 1440: return(40); case 10080: return(80); case 43200: return(150); } xml-ph-0015@deep
i.e. this function was used to set arrows using SetArrow() function, namely instead of price level in the line ObjectCreate(nm, OBJ_ARROW, 0, 0,0), tell me how it happened, it's not clear to me what the return values mean (4,5,6,8,10....)
The new version of the function also remains unclear:
//+----------------------------------------------------------------------------+ //| Author : Kim Igor V. aka KimIV, http://www.kimiv.ru | //+----------------------------------------------------------------------------+ //| Version : 12.10.2007 | //+----------------------------------------------------------------------------+ //| Description : Returns signal pointer interval | //| Parameters: | //| pr - percentage relative to window price size | //+-------------------
Started studying your functions not so long ago, on page 36 I didn't quite understand the functions, please help me to understand:
i.e. this function was used to set arrows using the SetArrow() function, namely instead of the price level in the line ObjectCreate(nm, OBJ_ARROW, 0, 0,0), tell me how this was done...
You must have misunderstood the purpose of these functions. They do not operate with prices and do not put icons; they only return distance in pips depending on the current timeframe. Please refer to the image below.
If you place such a marker not close to the price, but at a certain distance and for example on the H1 timeframe, and then you switch to M1, you will probably not see the marker. The scale will change and the icon will go either far down or up. The functions you mentioned are designed to ensure that the icons are always visible on the chart at any timeframe.
Lisi4ka330:
...what do the return values (4,5,6,8,10....) mean
Distance in pips, depending on the current timeframe.
Lisi4ka330:
WindowPriceMax() function returns the maximum value of the vertical scale, i.e. it is the maximum price value, but over what period?
Not for any period... Just in the current window. For example, in the figure below, the maximum price is 97.35
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Input Parameters: |
nm1 - name of the first line |
nm2 - second line name
output M is the price level.
PS. Sorry to the author of this thread for posting my code here. Just thought, maybe someone struggled with crossings too...
It comes to mind (already in the Annals):
PS. I apologise to the author of this thread for posting my code here. Just thought that maybe someone also struggled with intersections...
I tweaked the function a bit. Now it calculates intersections without crashing.
Input Parameters: |
nm1 - first line name |
nm2 - second line name
output M - price level.
PS. I'm sorry to the author of this thread for posting my code here. Just thought, maybe someone struggled with crossing too...
Well, maybe this function should return this very price level (as in the previous variant)! Besides, your code contains an undeclared variable "T".
Well, it returns it)
about undeclared variables - sorry. I stand corrected.
double M - crossing price level. This variable is declared at the beginning.
The trailer is an Expert Advisor to see how the function works.
I couldn't get it to load right away...
I couldn't get it to load right away...
You should not stir the waters, IMHO - bombard the function libraries with descriptions here and that's all...
Those who need it will find it.
The ClosePosByTakeProfitZone() function.
This function closes a position at the market price if the price stomps for a number of bars in the zone close to the TakeProfit or tries to exit this zone. Selection of positions to be closed is specified using external parameters:
Good evening, Igor!
Started studying your functions not too long ago, on page 36 I didn't quite understand the functions, please help me to understand:
Function GetArrowInterval().
//+------------------------------------------------------------------+
//| Returns signal pointer setting interval |
//+------------------------------------------------------------------+
int GetArrowInterval() {
int p = Period();
switch (p) {
case 1: return(4);
case 5: return(5);
case 15: return(6);
case 30: return(8);
case 60: return(10);
case 240: return(20);
case 1440: return(40);
case 10080: return(80);
case 43200: return(150);
} xml-ph-0015@deep
i.e. this function was used to set arrows using SetArrow() function, namely instead of price level in the line ObjectCreate(nm, OBJ_ARROW, 0, 0,0), tell me how it happened, it's not clear to me what the return values mean (4,5,6,8,10....)
The new version of the function also remains unclear://+----------------------------------------------------------------------------+
//| Author : Kim Igor V. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Version : 12.10.2007 |
//+----------------------------------------------------------------------------+
//| Description : Returns signal pointer interval |
//| Parameters: |
//| pr - percentage relative to window price size |
//+-------------------
return((WindowPriceMax()-WindowPriceMin())/100*pr/Point);
The WindowPriceMax() function returns the maximum value of the vertical scale, i.e. this is the maximum price value, but over what period?
And thanks for your hard work....))))
Started studying your functions not so long ago, on page 36 I didn't quite understand the functions, please help me to understand:
i.e. this function was used to set arrows using the SetArrow() function, namely instead of the price level in the line ObjectCreate(nm, OBJ_ARROW, 0, 0,0), tell me how this was done...
You must have misunderstood the purpose of these functions. They do not operate with prices and do not put icons; they only return distance in pips depending on the current timeframe. Please refer to the image below.
If you place such a marker not close to the price, but at a certain distance and for example on the H1 timeframe, and then you switch to M1, you will probably not see the marker. The scale will change and the icon will go either far down or up. The functions you mentioned are designed to ensure that the icons are always visible on the chart at any timeframe.
Lisi4ka330:
...what do the return values (4,5,6,8,10....) mean
Distance in pips, depending on the current timeframe.
Lisi4ka330:
WindowPriceMax() function returns the maximum value of the vertical scale, i.e. it is the maximum price value, but over what period?
Not for any period... Just in the current window. For example, in the figure below, the maximum price is 97.35