Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 74

 
Semionn:
Greetings all, I have a question: is it possible to open a position at the close of a bar (working on 15-minute bars), if yes, how to implement it using mt4?

It is impossible to know if this is the last tick on this bar or not. It is better to open a position at the next bar opening.
 
people help with a trailing stop, does anyone have a function?
 

I need to calculate the volumes of all open by and sell positions

I try to do it, but it doesn't work(((


//+--2.1 determination of order quality
int vb=v,vs=v, io, ko=OrdersTotal();

for (io=0; io<ko; io++)
{if (OrderSelect(io, SELECT_BY_POS, MODE_TRADES))
if (OrderType()==OP_BUY) { vb=vb+OrderLots( ); // add buy volumes
}
if (OrderType()==OP_SELL ) { vs=vs+OrderLots( ) ; // add the sell volumes
}
}

Print("Orders buy ",Koob," by ",vb," lot," Sell orders = ",Koos," by ", vs," lot );

vb and vs sum of by and sell orders are always zeroed out for some reason

 
sdm:

vb and vs the sum of by and sell volumes respectively are always zeroed out for some reason

Try vb and vs with type double.
 

Oh, Semyon Semyonych.

Thank you.

 

Guys help with the following question...
Is it possible to delete Global Variable (GlovalVariable) only if EA is deleted from chart ?

If yes, how ? Just by adding GlobalVariableDelete (name) to deinit, the variable is deleted when switching between Timeframes....

 
MisterD:

Guys help with the following question...
Is it possible to delete Global Variable (GlovalVariable) only if EA is deleted from chart ?

If yes, how ? Simply adding GlobalVariableDelete (name) to deinit deletes the variable when switching between Timeframes....

Analyse the reason for deinitialisation:

UninitializeReason()

 
PapaYozh:

Analyse the reason for deinitialisation:

UninitializeReason()

Thanks, I thought I've seen this section somewhere, but I couldn't find it... This is it :)
 
Hi again, could you please tell me where there is a mistake in the following code ?
I call the loop at the moment "deinit"
The order deletes all but the last one.
I think this line is most likely an error >> for (int i=1; i<=OrdersTotal(); i++) <<
However, logically everything seems to be correct... what did I miss ?

Thanks in advance!

//-------------------------------------------------------------------------------------------
for (int i=1; i<=OrdersTotal(); i++)
{
if(OrderSelect(i-1,SELECT_BY_POS)==true)
{
int Type=OrderType();
if (OrderSymbol()!= Symbol() || Type <2)continue;
int Ticket=OrderTicket();
Modify=OrderDelete(Ticket);
if (Modify == true) Alert ("Order Deleted"); continue;
if (Modify != true) Alert ("Order deleted failed");
continue;
}
}
//-------------------------------------------------------------------------------------------
Reason: