Can you please tell me how MT5 knows from the history the price and time of the first trade when opening a position and the price and time of the first trade when closing that position? The purpose is to get an array of entry points from the history, because I sometimes equity when trading manually, so I want to understand if it is effective or not. I don't know anything about trading - I'm using a class, where these functions have not been implemented :(
void OnTick()
{
//---
double o1 = iOpen(Symbol(),Period(),1);
double h1 = iHigh(Symbol(),Period(),1);
double l1 = iLow(Symbol(),Period(),1);
double c1 = iClose(Symbol(),Period(),1);
double c0 = iClose(Symbol(),Period(),0);
double rt = 0;
double rs1 = 0;
double rs2 = 0;
rt=MathAbs(c1-o1)/_Point; //размер тела свечи
rs1=MathAbs(h1-c1)/_Point;// размер верхней тени свечи
rs2=MathAbs(l1-c1)/_Point; // размер нижней тени свечи
ObjectDelete(0,"HL");
if ((rs1>=rt)&&(c1>o1)) //[для ростовых свечей] условие для построения уровней (если верхняя тень предыдущей свечи, больше, или равна телу этой же свечи, то...
{
double PRH=iHigh(Symbol(),_Period,1); // то это будет максимум
ObjectCreate(0,"HL",OBJ_HLINE,0,_Period,PRH); // и строим по этому максимуму, горизонтальную линию
}
ObjectDelete(0,"lL");
if ((rs2>=rt)&&(c1<o1)) // [для падающих свечей]условие для построения уровней (если нижняя тень предыдущей свечи, больше, или равна телу этой же свечи, то...
{
double PRL=iLow(Symbol(),_Period,1); // то это будет минимум
ObjectCreate(0,"lL",OBJ_HLINE,0,_Period,PRL); // и строим по этому минимум, горизонтальную линию
}
}
Considered option 1, something close. But not correct somehow happens. At first stages according to plan, then in a tailspin.
Well, sort of, yes. If you add conditions just a little bit, there's a problem. It draws one line. What it needs is: if there is no new high/low, it is saved.
Well, sort of, yes. If you add conditions just a little bit, there's a problem. It draws one line. What it needs is: if there is no new high/low, it is saved.
I don't know, who's stopping you from adding another line for Low...?
Aleksey Vyazmikin: Please, advise how to get the price and time of the first deal when opening a position and the price and time of the first deal to close this position from the history. My purpose is to get an array of entry points from the history, because I sometimes equity when trading manually, so I want to know if it is effective or not. I don't know anything about trading operations, I use a class, where these functions have not been implemented :(
Take trades, check theDEAL_ENTRY_IN or DEAL_ENTRY_OUT property to enter or exit the market and take the price and time of that trade.
Take orders. With index 0 this is an entry into the market, respectively OrdersTotal()-1 an exit from the market.
The best way is to take both. The point is that if the position is opened with a slippage, the deal price ≠ the order price. Accordingly, take what you need.
Не следует путать между собой ордера из торговой истории и действующие отложенные ордера, которые отображаются на вкладке "Торговля" в панели "Инструменты". Список ордеров, которые были отменены или привели к проведению торговой операции, можно посмотреть в закладке "История" на панели "Инструменты" клиентского терминала. Функция...
Good afternoon!
I am struggling with one question. Could you please tell me how to solve it?
The idea is the following: I draw a line at the previous maximum of the candle. I want the line to be shifted depending on the previous maximum.
Who prevents me from changing the line price on ticks when I need it?
There are 2 options
Hi namesake!)
void OnTick() { //--- double o1 = iOpen(Symbol(),Period(),1); double h1 = iHigh(Symbol(),Period(),1); double l1 = iLow(Symbol(),Period(),1); double c1 = iClose(Symbol(),Period(),1); double c0 = iClose(Symbol(),Period(),0); double rt = 0; double rs1 = 0; double rs2 = 0; rt=MathAbs(c1-o1)/_Point; //размер тела свечи rs1=MathAbs(h1-c1)/_Point;// размер верхней тени свечи rs2=MathAbs(l1-c1)/_Point; // размер нижней тени свечи ObjectDelete(0,"HL"); if ((rs1>=rt)&&(c1>o1)) //[для ростовых свечей] условие для построения уровней (если верхняя тень предыдущей свечи, больше, или равна телу этой же свечи, то... { double PRH=iHigh(Symbol(),_Period,1); // то это будет максимум ObjectCreate(0,"HL",OBJ_HLINE,0,_Period,PRH); // и строим по этому максимуму, горизонтальную линию } ObjectDelete(0,"lL"); if ((rs2>=rt)&&(c1<o1)) // [для падающих свечей]условие для построения уровней (если нижняя тень предыдущей свечи, больше, или равна телу этой же свечи, то... { double PRL=iLow(Symbol(),_Period,1); // то это будет минимум ObjectCreate(0,"lL",OBJ_HLINE,0,_Period,PRL); // и строим по этому минимум, горизонтальную линию } }Considered option 1, something close. But not correct somehow happens. At first stages according to plan, then in a tailspin.
And who prevents you from simply changing the line price on the ticks when you need to?
Well, sort of, yes. If you add conditions just a little bit, there's a problem. It draws one line. What it needs is: if there is no new high/low, it is saved.
Well, sort of, yes. If you add conditions just a little bit, there's a problem. It draws one line. What it needs is: if there is no new high/low, it is saved.
I don't know, who's stopping you from adding another line for Low...?
You can add a whole array of lines or other objects and mark every Low and High with it. What's the problem...?
Please, advise how to get the price and time of the first deal when opening a position and the price and time of the first deal to close this position from the history. My purpose is to get an array of entry points from the history, because I sometimes equity when trading manually, so I want to know if it is effective or not. I don't know anything about trading operations, I use a class, where these functions have not been implemented :(
HistorySelectByPosition will help you
Then there are several options:
I don't know, who's stopping you from adding another line for Low...?
You can add a whole array of lines or other objects and mark every Low and High with them. What's the problem...?
Yes! It's working properly! Thanks Mihail!
And if you have pierced the bottom line and need to delete it after the piercing, like:
Right?
Yes! It works like it should! Thanks Mihail!
And if the bottom line is punched and you have to delete on the fact of punching, like:
Right?
The program only uses two lines to highlight levels. Why delete and then create it again if you can just set it to 0...?
The line will not be visible on the chart... And then you can show it again:
lLine.Price(0, PRL);The programme only uses two lines to highlight the levels. Why delete and then recreate when you can just set it to 0...?
The line will not be visible on the chart... And then you can show it again:
Like this? Or is it necessary to declare something else in OnInit?