#include <stdlib.mqh>
extern string eaname = "MH-V1.3"; // Expert Name and first part of comment line
extern int Magic = 111140; // Magic Number ( 0 - for All positions)
extern bool Autotrade = true; // Set to false to prevent an entry after an exit
extern string Symbol1 = "USDCHF";
extern bool Symbol1isLong = true; // Set to true to put long orders on the second pair
extern double Ratio1 = 1;
extern string Symbol2 = "USDJPY";
extern bool Symbol2isLong = true; // Set to true to put long orders on the second pair
extern double Ratio2 = 1;
extern string Symbol3 = "EURUSD";
extern bool Symbol3isLong = true; // Set to true to put long orders on the second pair
extern double Ratio3 = 1;
extern string Symbol4 = "GBPUSD";
extern bool Symbol4isLong = true; // Set to true to put long orders on the second pair
extern double Ratio4 = 1;
extern double Slippage = 3;
extern string Lotsizes = "Set Ratio to 1 to use equal";
extern double Lots = 1; // Lots for first pair if MM is turned off
extern bool UseAutoRatio = true;
extern double SMA_Value_for_Range = 200;
extern string Data = " Input Data ";
extern bool StopManageAcc = false; // Stop of Manage Account switch(Close All Trades)
extern double MaxLoss = 0; // Maximum total loss in pips or USD
extern int cPeriod = 20; // If the correlation is used to check before put new Orders
extern string Data4 = "SWAP Settings";
extern bool UseSwap = true; // Select true if you want to use swap on profit calculation
extern string Data5 = "Money Management";
bool AccountIsMicro = true; // Set true if you use a micro account
extern double ProfitTarget = 50; // Profit target in pips or U
bool UsePips = false;
extern bool MoneyManagement = true;
extern double Risk = 20; // Risk
extern bool AutoProfit = true; // When the price of Bolliner pair passes the Upper Bollinger close all trades
extern double AutoProfitRatio = 1;
extern bool EmailReport = false;
string comment = "";
string eBody = "";
string eSubject = "";
string TradeSymbol ="";
int totalPips=0;
double totalProfits=0;
double BandsLower = 0;
double BandsUpper = 0;
bool CloseSignal=false;
bool signal1=true;
bool signal2=true;
double valueswap = 0;
double Correlation;
double Bands;
double OrderLots1,OrderLots2,OrderLots3,OrderLots4;
double AccountSize;
double Total_Lots;
int ticket1=0
,ticket2=0
,Symbol1SP
,Symbol2SP
,Order1=0
,Order2=0
,Order3=0
,Order4=0
,c1=0
,c2=0
,Symbol1OP
,Symbol2OP
,Symbol3OP
,Symbol4OP
,Symbol1Mode
,Symbol2Mode
,Symbol3Mode
,Symbol4Mode
,numords=0
;
string USD = "USD"; // Added so that PipCost could handle InterbankFx Mini accounts
int init()
{
// код доступен только после оплаты
}
int ScanOpenTrades()
{
Order1=0;Order2=0;Order3=0;Order4=0;
int total = OrdersTotal();
int numords = 0;
for(int cnt=0; cnt<=total-1; cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(Magic > 0) if(OrderMagicNumber() == Magic) numords++;
{
if(OrderType()==Symbol1OP && OrderMagicNumber() == Magic && OrderSymbol()==Symbol1)Order1 += 1;
if(OrderType()==Symbol2OP && OrderMagicNumber() == Magic && OrderSymbol()==Symbol2)Order2 += 1;
if(OrderType()==Symbol3OP && OrderMagicNumber() == Magic && OrderSymbol()==Symbol3)Order3 += 1;
if(OrderType()==Symbol4OP && OrderMagicNumber() == Magic && OrderSymbol()==Symbol4)Order4 += 1;
}
}
return(numords);
}
double PipCost (string TradeSymbol) {
double Base, Cost;
string TS_13, TS_46, TS_4L;
TS_13 = StringSubstr (TradeSymbol, 0, 3);
TS_46 = StringSubstr (TradeSymbol, 3, 3);
TS_4L = StringSubstr (TradeSymbol, 3, StringLen(TradeSymbol)-3);
Base = MarketInfo (TradeSymbol, MODE_LOTSIZE) * MarketInfo (TradeSymbol,
MODE_POINT);
if ( TS_46 == "USD" )
Cost = Base;
else if ( TS_13 == "USD" )
Cost = Base / MarketInfo (TradeSymbol, MODE_BID);
else if ( PairExists ("USD"+TS_4L) )
Cost = Base / MarketInfo ("USD"+TS_4L, MODE_BID);
else
Cost = Base * MarketInfo (TS_46+"USD" , MODE_BID);
return(Cost) ;
}
bool PairExists (string TradeSymbol) {
return ( MarketInfo (TradeSymbol, MODE_LOTSIZE) > 0 );
}
string GenerateComment(string eaname, int Magic)
{
return (StringConcatenate(eaname, "-", Magic));
}
void OpenOrdClose()
{
int total=OrdersTotal();
for (int cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS);
int mode=OrderType();
bool res = false;
bool condition = false;
if ( Magic>0 && OrderMagicNumber()==Magic ) condition = true;
else if ( Magic==0 ) condition = true;
if (condition && ( mode==OP_BUY || mode==OP_SELL ))
{
if (EmailReport) SendMail(eSubject,eBody);
if(mode==OP_BUY)
{
res = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),3,Yellow);
if( !res )
{
Print(" BUY: OrderClose failed with error #",GetLastError());
Print(" Ticket=",OrderTicket());
Sleep(3000);
}
break;
}
else
if( mode == OP_SELL)
{
res = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),3,White);
if( !res )
{
Print(" SELL: OrderClose failed with error #",GetLastError());
Print(" Ticket=",OrderTicket());
Sleep(3000);
}
break;
}
}
}
}
void TotalProfit()
{
int total=OrdersTotal();
totalPips = 0;
totalProfits = 0;
for (int cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS);
int mode=OrderType();
bool condition = false;
if ( Magic>0 && OrderMagicNumber()==Magic ) condition = true;
else if ( Magic==0 ) condition = true;
if (condition)
{
switch (mode)
{
Показано первые 50% кода (символов: 11117)
Введите ваш email и нажмите кнопку, чтобы перейти к оплате.