???//+------------------------------------------------------------------+
#property version "1.00"
#property strict
extern int LEN_TREND=100; //Main TREND length (bars)
extern bool USEMOVETOBREAKEVEN=true;//Enable "no loss"
extern double WHENTOMOVETOBE=10; //When to move break even
extern double PIPSTOMOVESL=5; //How much pips to move sl
extern double Lots=0.01; //Lots size
input double MaximumRisk =0.02;
input double DecreaseFactor=0.001;
extern double TrailingStop=40; //TrailingStop
extern double Stop_Loss=400; //Stop Loss
extern int MagicNumber=1234; //MagicNumber
input double TakeProfit=400; //TakeProfit
extern int FastMA=1; //FastMA
extern int SlowMA=20; //SlowMA
extern double Mom_Sell=0.3; //Momentum_Sell
extern double Mom_Buy=0.3; //Momentum_Buy
extern int FractalNum=10; // Number Of High And Low
int err;
int total=0;
double
Lot,Dmax,Dmin,// Amount of lots in a selected order
Lts, // Amount of lots in an opened order
Min_Lot, // Minimal amount of lots
Step, // Step of lot size change
Free, // Current free margin
One_Lot, // Price of one lot
Price, // Price of a selected order,
pips,
MA_1,MA_2,MA_3,MACD_SIGNAL;
int Type,freeze_level,Spread;
double priceopen,stoploss,takeprofit;
datetime timeTag;
int orderticket;
double Linenow=0;
double Lineprev=0;
double Linenow1=0;
double Lineprev1=0;
double Linenow2=0;
double Lineprev2=0;
int
Period_MA_2, Period_MA_3, // Calculation periods of MA for other timefr.
Period_MA_02, Period_MA_03, // Calculation periods of supp. MAs
K2,K3,T;
datetime dt=0;
datetime dt1=0;
datetime dt2=0;
datetime dt12=0;
datetime dt3=0;
datetime dt13=0;
int First_Low_Candel=0,Secund_Low_Candel=3,First_High_Candel=0,Secund_High_Candel=3,FractalHCandel[],FractalLCandel[];
double FractalHigh[],FractalLow[],LineValLow=0,LineValHigh=0;
int First_Low_Candel1=0,Secund_Low_Candel1=3,First_High_Candel1=0,Secund_High_Candel1=3,FractalHCandel1[],FractalLCandel1[];
double FractalHigh1[],FractalLow1[],LineValLow1=0,LineValHigh1=0;
int OnInit()
{
// код доступен только после оплаты
}
void OnDeinit(const int reason)
{
}
void OnTick(void)
{
// код доступен только после оплаты
}
void stop()
{
int cnt;
double middleBB=iBands(Symbol(),0,20, 2,0,0,MODE_MAIN,1);//middle
double lowerBB=iBands(Symbol(),0,20, 2,0,0,MODE_LOWER,1);//lower
double upperBB=iBands(Symbol(),0,20, 2,0,0,MODE_UPPER,1);//upper
for(cnt=0;cnt<total;cnt++)
{
if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
continue;
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
if(OrderType()==OP_BUY)
{
if(Close[1]==lowerBB)
exitbuys();
}
else // go to short position
{
if(Close[1]==lowerBB)
exitsells();
}
}
}
}
void Trail1()
{
total=OrdersTotal();
for(int cnt=0;cnt<total;cnt++)
{
if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
continue;
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
if(OrderType()==OP_BUY)
{
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>pips*TrailingStop)
{
if(OrderStopLoss()<Bid-pips*TrailingStop)
{
RefreshRates();
stoploss=Bid-(pips*TrailingStop);
takeprofit=OrderTakeProfit()+pips*TrailingStop;
double StopLevel=MarketInfo(Symbol(),MODE_STOPLEVEL)+MarketInfo(Symbol(),MODE_SPREAD);
if(stoploss<StopLevel*pips) stoploss=StopLevel*pips;
string symbol=OrderSymbol();
double point=SymbolInfoDouble(symbol,SYMBOL_POINT);
if(MathAbs(OrderStopLoss()-stoploss)>point)
if((pips*TrailingStop)>(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_FREEZE_LEVEL)*pips)
if(CheckStopLoss_Takeprofit(OP_BUY,stoploss,takeprofit))
if(OrderModifyCheck(OrderTicket(),OrderOpenPrice(),stoploss,takeprofit))
if(!OrderModify(OrderTicket(),OrderOpenPrice(),stoploss,takeprofit,0,Green))
Print("OrderModify error ",GetLastError());
return;
}
}
}
}
else // go to short position
{
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(pips*TrailingStop))
{
if((OrderStopLoss()>(Ask+pips*TrailingStop)) || (OrderStopLoss()==0))
{
RefreshRates();
stoploss=Ask+(pips*TrailingStop);
takeprofit=OrderTakeProfit()-pips*TrailingStop;
double StopLevel=MarketInfo(Symbol(),MODE_STOPLEVEL)+MarketInfo(Symbol(),MODE_SPREAD);
if(stoploss<StopLevel*pips) stoploss=StopLevel*pips;
if(takeprofit<StopLevel*pips) takeprofit=StopLevel*pips;
string symbol=OrderSymbol();
double point=SymbolInfoDouble(symbol,SYMBOL_POINT);
if(MathAbs(OrderStopLoss()-stoploss)>point)
if((pips*TrailingStop)>(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_FREEZE_LEVEL)*pips)
if(CheckStopLoss_Takeprofit(OP_SELL,stoploss,takeprofit))
if(OrderModifyCheck(OrderTicket(),OrderOpenPrice(),stoploss,takeprofit))
if(!OrderModify(OrderTicket(),OrderOpenPrice(),stoploss,takeprofit,0,Red))
Print("OrderModify error ",GetLastError());
return;
}
}
}
}
}
}
}
void MOVETOBREAKEVEN()
{
for(int b=OrdersTotal()-1;b>=0;b--)
{
if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()!=MagicNumber)continue;
if(OrderSymbol()==Symbol())
if(OrderType()==OP_BUY)
if(Bid-OrderOpenPrice()>WHENTOMOVETOBE*pips)
if(OrderOpenPrice()>OrderStopLoss())
if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+(PIPSTOMOVESL*pips),OrderTakeProfit(),0,CLR_NONE))
Print("eror");
}
for(int s=OrdersTotal()-1;s>=0;s--)
{
if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()!=MagicNumber)continue;
if(OrderSymbol()==Symbol())
if(OrderType()==OP_SELL)
if(OrderOpenPrice()-Ask>WHENTOMOVETOBE*pips)
if(OrderOpenPrice()<OrderStopLoss())
if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-(PIPSTOMOVESL*pips),OrderTakeProfit(),0,CLR_NONE))
Print("eror");
}
}
double LotsOptimized()
{
double lot=Lots;
int orders=OrdersHistoryTotal(); // history orders total
int losses=0; // number of losses orders without a break
if(MaximumRisk>0)
{
lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
}
if(DecreaseFactor>0)
{
for(int i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
{
Print("Error in history!");
break;
}
if(OrderSymbol()!=Symbol() /*|| OrderType()>OP_SELL*/)
continue;
if(OrderProfit()>0) break;
if(OrderProfit()<0) losses++;
}
if(losses>1)
lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
}
double minlot=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
if(lot<minlot)
{ lot=minlot; }
double maxlot=SymbolInfoDoПоказано первые 50% кода (символов: 20059)
Введите ваш email и нажмите кнопку, чтобы перейти к оплате.