I tried to write it the way you said, but it works... it still opens positions at the close of the previous one...((
maybe you don't understand what i mean, i want it to open a position no earlier than 1 hour after the previous one was closed ... and in your case, it excludes the possibility of re-opening, but as soon as it closes, it immediately opens the next one
if (SecondsAfterOpenLastPos(NULL, OP_SELL, MAGIC)>=(Period()*Interval)*60) {
OpenSell();
}
I tried to write it the way you said, it works... it still opens a position at the close of the previous one...(
Maybe you don't understand what I mean, it needs to open a trade not earlier than 1 hour after the previous one was closed...and in your case, it excludes the possibility of opening a repeat trade, but as soon as it is closed, the next one is opened immediately
And think about the function code? Find four differences :) :
//+----------------------------------------------------------------------------+datetime SecondsAfterCloseLastPos(string sy, int op, int mn)
{
datetime t;
int i, k=OrdersHistoryTotal();
if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderSymbol()!=sy) continue;
if (OrderType()!=op) continue;
if (OrderMagicNumber()!=mn) continue;
if (t<OrderCloseTime()) t=OrderCloseTime();
}
}
return(TimeCurrent()-t);
}
//+----------------------------------------------------------------------------+
Don't ask, check with a tester... :)
the expert draws one line.
if the code says "draw line 1 if it's not drawn; draw line 2 if it's not drawn" - they can't not be drawn:)
Can you tell me why all the percentages are 0 in the test report? I.e. relative drawdown, maximum drawdown, etc.?
For example, like this:
Call like this:
I hope you can turn minutes into hours ... :)I tried to write it the way you said, but it works... it still opens positions at the close of the previous one...((
maybe you don't understand what i mean, i want it to open a position no earlier than 1 hour after the previous one was closed ... and in your case, it excludes the possibility of re-opening, but as soon as it closes, it immediately opens the next one
guys help: I need a deal to be opened if a certain amount of time has passed after the previous one was closed....help
for (int i=0; i<OrdersTotal(); i++)
{ if(OrderSelect(i, SELECT_BY_POS)==true)
{
TC = TimeCurrent();
OM = OrderMagicNumber();
if (TC-OM>86400 && (OrderType()==OP_SELL)){
CLOSEORDER("Sell");
}
if (TC-OM>86400 && (OrderType()==OP_BUY)){
CLOSEORDER("Buy");
}
}
}
In OrderMagicNumber() when opening an order it writes: Magic = TimeCurrent();
for (int i=0; i<OrdersTotal(); i++)
{ if (OrderSelect(i, SELECT_BY_POS)==true)
{
TC = TimeCurrent();
OM = OrderMagicNumber();
if (TC-OM>86400 && (OrderType()==OP_SELL)){
CLOSEORDER("Sell");
}
if (TC-OM>86400 && (OrderType()==OP_BUY)){
CLOSEORDER("Buy");
}
}
}
In OrderMagicNumber(), when opening an order, it's written: Magic = TimeCurrent();
I forgot =) 86400 - this is the number of seconds after which the position is closed
Can you tell me why all the percentages are 0 in the test report? I.e. relative drawdown, maximum drawdown, etc.?
All figured out - the deposit was too big)
I tried to write it the way you said, it works... it still opens a position at the close of the previous one...(
Maybe you don't understand what I mean, it needs to open a trade not earlier than 1 hour after the previous one was closed...and in your case, it excludes the possibility of opening a repeat trade, but as soon as it is closed, the next one is opened immediately
And think about the function code? Find four differences :) :