If you know the function for calculating the total balance of loss of CLOSED positions by SL and the total balance of OPEN profitable trades, please write.
Loss balance calculation should start from the last maximum deposit value
Hello, my Expert Advisor puts pending stops. When checking in the tester only SELL_STOP is working, instead of BUY_STOP an error Order Send error/ Error opening Buy order:130 appears.
externint TrailingStop=30;
//-----------------------------------------------------------------------------------------------+for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELLSTOP && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
if(OrderType()==OP_BUY) // long position is opened
{
// check for trailing stopif(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
return(0);
}
}
}
else// go to short position
{
// check for trailing stopif(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
return(0);
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELLSTOP && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
if(OrderType()==OP_BUY) // long position is opened
{
How to understand? If CELLSTOP, what does BAI have to do with it?
How do I know if the last 1-2-3 orders were losing?
And in general, how do I know what the last order was?
Recently I have written a function that, in case of the last losing order, returns the type of this order. In other words, if fHistory() == 0, the last losing order was Buy, fHistory() == 1, the last losing order was Sell. If we want to track the profitable orders, then change the sign in the line like this: if(OrderProfit() > 0 ).
//+----------------------------------------------------------------------------+// Прибыльно или убыточно закрылся последний ордер, и возврат типа такого ордераint fHistory(){
for(int i=OrdersHistoryTotal(); i >= 0; i--){ // Выборка в историиif (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true){ // Если есть следующий в историиif(OrderMagicNumber()!=magN) continue; // Ордера не нашего экспертаif(OrderProfit() < 0 ) return (OrderType()); // Если убыток по посл.ордеру вернем тип ордера
}
}
return(-1);
}
The variable magN is the Magic order declared globally.
If you know the function for calculating the total balance of loss of CLOSED positions by SL and the total balance of OPEN profitable trades, please write.
Loss balance calculation should start from the last maximum deposit value
Good afternoon!!! My function is swearing with forty cuss words - I obviously didn't know very much, and also forgot how to make it up
Good afternoon!!! My function is swearing with forty cuss words - I obviously didn't know very much, and also forgot how to make it up
Diman! Good night! You need a rest, for not a function, but some bullshit you wrote...
I'm telling you, I don't remember. I'll write it in. Ordersends. What doesn't the compiler like?
That's not how f-i's are written. Read the textbook.
Hello, my Expert Advisor puts pending stops. When checking in the tester only SELL_STOP is working, instead of BUY_STOP an error Order Send error/ Error opening Buy order:130 appears.
Help me to find the reason!
The reason is a lack of logic!
How to understand? If CELLSTOP, what does BAI have to do with it?How do I know if the last 1-2-3 orders were losing?
And in general, how do I know what the last order was?
Recently I have written a function that, in case of the last losing order, returns the type of this order. In other words, if fHistory() == 0, the last losing order was Buy, fHistory() == 1, the last losing order was Sell. If we want to track the profitable orders, then change the sign in the line like this: if(OrderProfit() > 0 ).
The variable magN is the Magic order declared globally.