Hi all,
ich wrote the following code, but i don't work somehow. I check if a position in the current symbol exists. Then i would like to have the "day of the year" for the recent moment (for ab) and the "day of the year" when the position has been opened (for ba). The difference of this two data points should be saved in "delta". Could anyone help me with this? THX
Well, then number from "delta" i use to generate exit orders. But the exit order with the following code don't execute in the strategy tester...
if(delta>0)
{
trReq.price=tick.bid;
trReq.type=ORDER_TYPE_SELL;
OrderSend(trReq,trRes);
}
Well, then number from "delta" i use to generate exit orders. But the exit order with the following code don't execute in the strategy tester...
if(delta>0)
{
trReq.price=tick.bid;
trReq.type=ORDER_TYPE_SELL;
OrderSend(trReq,trRes);
}
Is the open position a POSITION_TYPE_BUY?
An BUY position is closed by a SELL order and vice versa.
Are all required fields in trReq have been set?
- www.mql5.com
Is the open position a POSITION_TYPE_BUY?
An BUY position is closed by a SELL order and vice versa.
Are all required fields in trReq have been set?
Yes, the open position is a buy order und all fields in trReq are from my point of view allright...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
ich wrote the following code, but i don't work somehow. I check if a position in the current symbol exists. Then i would like to have the "day of the year" for the recent moment (for ab) and the "day of the year" when the position has been opened (for ba). The difference of this two data points should be saved in "delta". Could anyone help me with this? THX
if (PositionSelect(Symbol()))
{
long delta;
long ab;
long ba;
datetime date1=TimeCurrent();
datetime date2=PositionGetInteger(POSITION_TIME);
MqlDateTime str1,str2;
TimeToStruct(date1,str1);
TimeToStruct(date2,str2);
ab=str1.day_of_year;
ba=str2.day_of_year;
delta=ab-ba;
}