Quote:
Originally Posted by neta1o
Glad to hear you guys are still testing, I'm going to be working on this later tonight so I should have some updates.
-neta1o
EDIT: I found a few bugs with this where it doesn't close all orders, also I need to make sure the target profit is in
ratio to the pip step or even when it succeeds it will fail. You may see a lot of no market to open. It will give this message every
time it checks. I'll update this later as well.
|
Hi neta1o, there is also a little bug here :
PHP Code:
for(cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
LastTicket=OrderTicket();
LastPrice=OrderOpenPrice();
LastLots=OrderLots();
if (OrderType()==OP_BUY)
{
Profit=OrderProfit();
lastType=1;
}
if (OrderType()==OP_SELL)
{
Profit=OrderProfit();
lastType=2;
}
OpenOrders++;
}
One cannot assume that the last opened order will always be the latest of the scan loop; this may not to be a problem in BT, but it could be when working on the terminal as the order depends of the sorted column of the trade tab.
An easy and safe way to check if the order is the last one is to compare the TicketNumbers.
Another mistake seems a bad computation of the total profit.
So I suggest something like this :
PHP Code:
LastTicket = 0;
for(cnt=0;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
Profit += OrderProfit();
OpenOrders ++;
if(OrderTicket() > LastTicket)
{
LastTicket = OrderTicket();
LastPrice = OrderOpenPrice();
LastLots = OrderLots();
LastType = OrderType();
LastTime = OrderOpenTime();
}
}
}