Discussion of article "Library for easy and quick development of MetaTrader programs (part XXIV): Base trading class - auto correction of invalid parameters" - page 2

 

Hi, these two subroutines run differently, where "Statistical Time Period Buy Loss" can get the desired result, while "Statistical Time Period Sell Loss" results in 0, why is this?

//Statistical time period history of the loss of single (has been closed single) number, lasttime for the start of time

double statistics time period buy loss(int 魔号,string buyOrSell, string as_8,datetime lasttime)

{

double Volume=0; double buyOrSell=0; double buyOrSell=0; double buyOrSell=0

double buyOrSell=0; int totalOrSell=0; int buyOrSell=0

int TotalOrders=0; int buyOrSell=0; datetime lasttime

for (int i=OrdersHistoryTotal()-1; i>=0; i--)

{

if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic Number )// only count the current corresponding currency pairs

{

if (buyOrSell == "buy")

{

if (OrderType() == OP_BUY )

{

if (OrderCloseTime()>lasttime)

{

if (OrderProfit()<0)

{

TotalOrders=TotalOrders+1;

Loss=Loss+OrderProfit();

Volume=Volume+OrderLots();

}

}

}

}


}

}}

if (as_8 == "total number of orders") return (total number of orders);

if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss)

if (as_8 == "Volume") return (Volume); return (0.0); if (as_8 == "Loss") return (Loss); if (as_8 == "Volume") return (Volume)


return (0.0);

}

double Statistics Session Sell Loss(int 魔号,string buyOrSell, string as_8,datetime lasttime)

{

double Volume=0;

double Sell Loss = 0; int Total Orders = 0; datetime lasttime

int TotalOrders=0; int buyOrSell=0; datetime lasttime

for (int i=OrdersHistoryTotal()-1; i>=0; i--)

{

if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic Number )// only count the current corresponding currency pairs

{

if (buyOrSell == "sell")

{

if (OrderType() == OP_SELL )

{

if (OrderCloseTime()>lasttime)

{

if (OrderProfit()<0)

{

TotalOrders=TotalOrders+1;

Loss=Loss+OrderProfit();

Volume=Volume+OrderLots();

}

}

}

}

}

}}

if (as_8 == "total number of orders") return (total number of orders);

if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss)

if (as_8 == "Volume") return (Volume); return (0.0); if (as_8 == "Loss") return (Loss); if (as_8 == "Volume") return (Volume)


return (0.0);

}

 

Hi, these two subroutines run differently, where "Statistical Time Period Buy Loss" can get the desired result, while "Statistical Time Period Sell Loss" results in 0, why is this?

//Statistical time period history of the loss of single (has been closed single) number, lasttime for the start of time

double statistics time period buy loss(int 魔号,string buyOrSell, string as_8,datetime lasttime)

{

double Volume=0; double buyOrSell=0; double buyOrSell=0; double buyOrSell=0

double buyOrSell=0; int totalOrSell=0; int buyOrSell=0

int TotalOrders=0; int buyOrSell=0; datetime lasttime

for (int i=OrdersHistoryTotal()-1; i>=0; i--)

{

if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic Number )// only count the current corresponding currency pairs

{

if (buyOrSell == "buy")

{

if (OrderType() == OP_BUY )

{

if (OrderCloseTime()>lasttime)

{

if (OrderProfit()<0)

{

TotalOrders=TotalOrders+1;

Loss=Loss+OrderProfit();

Volume=Volume+OrderLots();

}

}

}

}


}

}}

if (as_8 == "total number of orders") return (total number of orders);

if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss)

if (as_8 == "Volume") return (Volume); return (0.0); if (as_8 == "Loss") return (Loss); if (as_8 == "Volume") return (Volume)


return (0.0);

}

double Statistics Session Sell Loss(int 魔号,string buyOrSell, string as_8,datetime lasttime)

{

double Volume=0;

double Sell Loss = 0; int Total Orders = 0; datetime lasttime

int TotalOrders=0; int buyOrSell=0; datetime lasttime

for (int i=OrdersHistoryTotal()-1; i>=0; i--)

{

if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic Number )// only count the current corresponding currency pairs

{

if (buyOrSell == "sell")

{

if (OrderType() == OP_SELL )

{

if (OrderCloseTime()>lasttime)

{

if (OrderProfit()<0)

{

TotalOrders=TotalOrders+1;

Loss=Loss+OrderProfit();

Volume=Volume+OrderLots();

}

}

}

}

}

}}

if (as_8 == "total number of orders") return (total number of orders);

if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss)

if (as_8 == "Volume") return (Volume); return (0.0); if (as_8 == "Loss") return (Loss); if (as_8 == "Volume") return (Volume)


return (0.0);

}

 
Artyom Trishkin:
OK

Hi, these two subroutines run differently, where "Statistical Time Period Buy Loss" can get the desired result, while "Statistical Time Period Sell Loss" results in 0, why is this?

//Statistical time period history of the loss of single (has been closed single) number, lasttime for the start of time

double statistics time period buy loss(int 魔号,string buyOrSell, string as_8,datetime lasttime)

{

double Volume=0; double buyOrSell=0; double buyOrSell=0; double buyOrSell=0

double buyOrSell=0; int totalOrSell=0; int buyOrSell=0

int TotalOrders=0; int buyOrSell=0; datetime lasttime

for (int i=OrdersHistoryTotal()-1; i>=0; i--)

{

if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic Number )// only count the current corresponding currency pairs

{

if (buyOrSell == "buy")

{

if (OrderType() == OP_BUY )

{

if (OrderCloseTime()>lasttime)

{

if (OrderProfit()<0)

{

TotalOrders=TotalOrders+1;

Loss=Loss+OrderProfit();

Volume=Volume+OrderLots();

}

}

}

}


}

}}

if (as_8 == "total number of orders") return (total number of orders);

if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss)

if (as_8 == "Volume") return (Volume); return (0.0); if (as_8 == "Loss") return (Loss); if (as_8 == "Volume") return (Volume)


return (0.0);

}

double Statistics Session Sell Loss(int 魔号,string buyOrSell, string as_8,datetime lasttime)

{

double Volume=0;

double Sell Loss = 0; int Total Orders = 0; datetime lasttime

int TotalOrders=0; int buyOrSell=0; datetime lasttime

for (int i=OrdersHistoryTotal()-1; i>=0; i--)

{

if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)

{

if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic Number )// only count the current corresponding currency pairs

{

if (buyOrSell == "sell")

{

if (OrderType() == OP_SELL )

{

if (OrderCloseTime()>lasttime)

{

if (OrderProfit()<0)

{

TotalOrders=TotalOrders+1;

Loss=Loss+OrderProfit();

Volume=Volume+OrderLots();

}

}

}

}

}

}}

if (as_8 == "total number of orders") return (total number of orders);

if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss); if (as_8 == "Loss") return (Loss)

if (as_8 == "Volume") return (Volume); return (0.0); if (as_8 == "Loss") return (Loss); if (as_8 == "Volume") return (Volume)


return (0.0);

}

 

This is a discussion thread for the article, and not for resolving issues not related to the library described in the article.

To insert the code into the message, you need to use the Alt + S combination or this button.


 
Hi, is it possible that this programme does not support the search of historical traded sell orders?
 
hsyhsy863 :
Hello, does the programme not support the search of historical sell orders?

And even much more.

 
Hi, I've noticed that when loading a custom indicator and then deleting the custom indicator the buttons don't work and I can't get it to work. Why is this? How can I fix it?
 
hsyhsy863 :
Hi, I've noticed that when loading a custom indicator and then deleting the custom indicator the buttons don't work and I can't get it to work. Why is this? How can I fix it?

During use - what?

Which keys do not work?
 
I'd like to send you a custom indicator, you load it and delete it, try it and you'll see.
Files:
jh720-03-3.ex4  214 kb
 
hsyhsy863:
I'd like to send you a custom indicator, you load it and delete it, try it and you'll understand.
Hi, did you find the problem I mentioned?