#property version "1.01"
#property strict
/*-- These variables are shown in the EA and can be changed --*/
extern int Take_Profit=30; // TP value of each trade in this Martingale EA
extern int PipStep = 30; // Distance in pips which will open a new trade
extern double Lots = 0.1; // The value of the initial lots , will be duplicated every step
extern double Multiply = 2.0; // Multiplier value every step of new trade
extern int MaxTrade=4; // Maximum trades that can run
extern bool CLOSEMAXORDERS=true; // Close Maximum Orders
extern int EAMagicNumber=8095; // Magic Number
double SetPoint=0; // Variable SetPoint to code 4 or 5 digit brokers
double pips;
int T=0;
int Count_one_message=0;
int Tp,err,ntp,result;
double priceopen,stoploss,takeprofit;
/*--These parameters are to be displayed on the screen --*/
string EAName = "Martingale ver 1.0"; // EA name , to be displayed on the screen
string EAComment = "Martingale"; // This variable will we put in each trade as a Comment
int OnInit()
{
// код доступен только после оплаты
}
void OnDeinit(const int reason)
{
}
void OnTick()
{
// код доступен только после оплаты
}
/*--so EA can be running at 4 Digits Broker or 5 Digits--*/
void SetBroker()
{
if(Digits==3 || Digits==5) // Command to brokers 5 Digits
{SetPoint=Point*10;}
else // Command to brokers 4 Digits
{SetPoint=Point;}
}
int GoMartingale()
{
int iCount = 0;
double LastOP = 0;
double LastLots = 0;
bool LastIsBuy = FALSE;
int iTotalBuy = 0;
int iTotalSell = 0;
double Spread=0;
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ",AccountFreeMargin());
return(0);
}
Spread=MarketInfo(Symbol(),MODE_SPREAD);
for(iCount=0;iCount<OrdersTotal();iCount++)
{
if(!OrderSelect(iCount,SELECT_BY_POS,MODE_TRADES))
Print("eror");
if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
{
if(LastOP==0) {LastOP=OrderOpenPrice();}
if(LastOP>OrderOpenPrice()) {LastOP=OrderOpenPrice();}
if(LastLots<OrderLots()) {LastLots=OrderLots();}
LastIsBuy=TRUE;
iTotalBuy++;
if(iTotalBuy==MaxTrade) //{return(0);}
{
if(CLOSEMAXORDERS==1)
{
exitbuys();
return(0);
}
}
}
if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderComment()==EAComment && OrderMagicNumber()==EAMagicNumber)
{
if(LastOP==0) {LastOP=OrderOpenPrice();}
if(LastOP<OrderOpenPrice()) {LastOP=OrderOpenPrice();}
if(LastLots<OrderLots()) {LastLots=OrderLots();}
LastIsBuy=FALSE;
iTotalSell++;
if(iTotalSell==MaxTrade) //{return(0);}
{
if(CLOSEMAXORDERS==1)
{
exitsells();
return(0);
}
}
}
}
/* If the Price is downtrend .... direction , check the Bid (*/
if(LastIsBuy)
{
if(Bid<=LastOP-(Spread*SetPoint)-(PipStep*SetPoint))
{
if(((AccountStopoutMode()==1) &&
(AccountFreeMarginCheck(Symbol(),OP_BUY,Lots)>AccountStopoutLevel()))
|| ((AccountStopoutMode()==0) &&
((AccountEquity()/(AccountEquity()-AccountFreeMarginCheck(Symbol(),OP_BUY,Lots))*100)>AccountStopoutLevel())))
if(CheckMoneyForTrade(Symbol(),LotsOptimized(Multiply*LastLots),OP_BUY))
if(!OrderSend(Symbol(),OP_BUY,Multiply*LastLots,ND(Ask),3,0,NDTP(Ask+Take_Profit*SetPoint),EAComment,EAMagicNumber))
Print("eror",GetLastError());
ModifyTP();
LastIsBuy=FALSE;
return(0);
}
}
/* If the direction is Sell Price .... , check the value of Ask(*/
else if(!LastIsBuy)
{
if(Ask>=LastOP+(Spread*SetPoint)+(PipStep*SetPoint))
{
if(((AccountStopoutMode()==1) &&
(AccountFreeMarginCheck(Symbol(),OP_SELL,Lots)>AccountStopoutLevel()))
|| ((AccountStopoutMode()==0) &&
Показано первые 50% кода (символов: 12277)
Введите ваш email и нажмите кнопку, чтобы перейти к оплате.