Kalkin писал(а):Вот функция для поиска точки нулевого профита, учитывающая комиссии и накапливающиеся свопы. При локе точка профита будет "0" (отсутствовать).
- Код: выделить все
double ZeroLevel()
{
double BuyLots=0;
double SellLots=0;
double BuyProfit=0;
double SellProfit=0;
int Total=OrdersTotal();
for (int i=Total-1;i>=0;i--)
{
if (OrderSelect(i,SELECT_BY_POS))
{
if (OrderSymbol()!=Symbol()) continue;
if (OrderType()==OP_BUY)
{
BuyLots=BuyLots+OrderLots();
BuyProfit=BuyProfit+OrderProfit()+OrderCommission()+OrderSwap();
}
if (OrderType()==OP_SELL)
{
SellLots=SellLots+OrderLots();
SellProfit=SellProfit+OrderProfit()+OrderCommission()+OrderSwap();
}
}
}
double Price=0;
double TickValue=MarketInfo(Symbol(),MODE_TICKVALUE)/(MarketInfo(Symbol(),MODE_TICKSIZE)/Point);
if ((BuyLots-SellLots)>0) Price=NormalizeDouble(Bid-((BuyProfit+SellProfit)/(TickValue*(BuyLots-SellLots))*Point),Digits);
if ((SellLots-BuyLots)>0) Price=NormalizeDouble(Ask+((BuyProfit+SellProfit)/(TickValue*(SellLots-BuyLots))*Point),Digits);
return (Price);
}
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 4
Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения