<code>//*************************************************************//
for(int i=OrdersTotal()-1;i>=0;i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()==MagicNumber)
if(OrderSymbol()==Symbol())
{
op=NormalizeDouble(OrderOpenPrice(),Digits());
tp=NormalizeDouble(OrderTakeProfit(),Digits());
lt=NormalizeDouble(OrderLots(),2);
tk=OrderTicket();
if(OrderType()==OP_BUY)
{
if(b>=1 && tp==0)
if(!OrderModify(tk,op,OrderStopLoss(),NormalizeDouble(Ask+TakeProfit*Point(),Digits()),0,clrNONE))
Print("OrderModify error #",GetLastError());
if(b>=3)
{
if(tk==BuyPriceMaxTic || tk==BuyPriceMinTic)
if(Bid<AwerageBuyPrice && tp!=AwerageBuyPrice)
if(!OrderModify(tk,op,OrderStopLoss(),AwerageBuyPrice,0,clrNONE))
Print("OrderModify error #",GetLastError());
if(tk!=BuyPriceMaxTic && tk!=BuyPriceMinTic && tp!=0)
if(!OrderModify(tk,op,0,0,0,clrNONE))
Print("OrderModify error #",GetLastError());
}
if(Revers && Bid<=op-slv)
if(OrderSend(Symbol(),OP_SELL,lt,NormalizeDouble(Bid,Digits()),Slippage,0,0," ",MagicNumber,0,clrRed)<0)
Print("OrderSend error #",GetLastError());
}
//---
if(OrderType()==OP_SELL)
{
if(s>=1 && tp==0)
if(!OrderModify(tk,op,OrderStopLoss(),NormalizeDouble(Bid-TakeProfit*Point(),Digits()),0,clrNONE))
Print("OrderModify error #",GetLastError());
if(s>=3)
{
if(tk==SelPriceMaxTic || tk==SelPriceMinTic)
if(Ask>AwerageSelPrice && tp!=AwerageSelPrice)
if(!OrderModify(tk,op,OrderStopLoss(),AwerageSelPrice,0,clrNONE))
Print("OrderModify error #",GetLastError());
if(tk!=SelPriceMaxTic && tk!=SelPriceMinTic && tp!=0)
if(!OrderModify(tk,op,0,0,0,clrNONE))
Print("OrderModify error #",GetLastError());
if(Revers>0 && Ask>=op+slv)
if(OrderSend(Symbol(),OP_BUY,lt,NormalizeDouble(Ask,Digits()),Slippage,0,0," ",MagicNumber,0,clrBlue)<0)
Print("OrderSend error #",GetLastError());
}
}
}
/* //---
double Prof = GetProfit();
if((LevelStopLoss>0 && Prof<=-LevelStopLoss) || (LevelStopProfit>0 && Prof>=LevelStopProfit))
ClosePlus();
//---
if(LevelStopLoss<0 && Prof<=LevelStopLoss)
CloseMinus();
if(LevelStopProfit<0 && Prof>=-LevelStopProfit)
ClosePlus();
*/
}
//************************************************************************************************/
bool CheckVolumeValue(double volume)
{
//--- минимально допустимый объем для торговых операций
double min_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
if(volume<min_volume)
return(false);
//--- максимально допустимый объем для торговых операций
double max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
if(volume>max_volume)
return(false);
//--- получим минимальную градацию объема
double volume_step=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP);
int ratio=(int)MathRound(volume/volume_step);
if(MathAbs(ratio*volume_step-volume)>0.0000001)
return(false);
return(true);
}
//************************************************************************************************/
/*СИГНАЛ*/
//------------------------------------------------------------------
int Signal() // Создаем функцию получения сигнала на указанном ТФ и баре
{
double current_openprice = iOpen (Symbol(),TF , iB);
double Mashka =iMA(NULL,0,Per_MA,0,0,4,iB) ;
double Atrium=0;
Atrium = 0.2 * iATR(NULL,TF_ATR,Per_MA,iB);
if(Bid>=current_openprice)
{
SellBuff = (58000000.0 * (Bid - Mashka) * Atrium);
BuyBuff = (58000000.0 * (Low[iB] - Mashka) * Atrium);
}
if(Bid<current_openprice)
{
SellBuff = (58000000.0 * (High[iB] - Mashka) * Atrium);
BuyBuff = (58000000.0 * (Bid - Mashka) * Atrium);
}
if (SellBuff > LevelSell)
return OP_SELL;
if (BuyBuff < -LevelBuy)
return OP_BUY;
return -1; // Иначе нет сигнала. Возвращаем в int Signai () -1 (никаких сигналов)
}
//************************************************************************************************
double GetProfit()
{
double Profit=0;
for(int i=OrdersTotal()-1;i>=0;i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()==MagicNumber)
if(OrderSymbol()==Symbol())
Profit += OrderProfit() + OrderCommission() + OrderSwap();
return (Profit);
}
//************************************************************************************************
bool CloseAll()
{
for(int i=OrdersTotal()-1;i>=0;i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()==MagicNumber)
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
if(!OrderClose(OrderTicket(),OrderLots(),Bid,Slippage))
{
Sleep(500);
i=i+1;//??????????????
}
if(OrderType()==OP_SELL)
if(!OrderClose(OrderTicket(),OrderLots(),Ask,Slippage))
{
Sleep(500);
i=i+1;//??????????????
}
}
return true;
}
//************************************************************************************************
bool ClosePlus()
{
for(int i=OrdersTotal()-1;i>=0;i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()==MagicNumber)
if(OrderSymbol()==Symbol() && OrderProfit()>0)
{
if(OrderType()==OP_BUY)
if(!OrderClose(OrderTicket(),OrderLots(),Bid,Slippage))
{
Sleep(500);
i=i+1;//??????????????
}
if(OrderType()==OP_SELL)
if(!OrderClose(OrderTicket(),OrderLots(),Ask,Slippage))
{
Sleep(500);
i=i+1;//??????????????
}
}
return true;
}
//************************************************************************************************
bool CloseMinus()
{
for(int i=OrdersTotal()-1;i>=0;i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()==MagicNumber)
if(OrderSymbol()==Symbol() && OrderProfit()<=0)
{
if(OrderType()==OP_BUY)
if(!OrderClose(OrderTicket(),OrderLots(),Bid,Slippage))
{
Sleep(500);
i=i+1;//??????????????
}
if(OrderType()==OP_SELL)
if(!OrderClose(OrderTicket(),OrderLots(),Ask,Slippage))
{
Sleep(500);
i=i+1;//??????????????
}
}
return true;
}
//************************************************************************************************
</code>





Вообще-то мысль стоит внимания. Вот вам и работа на флетах и на новостях.
kvashnin007