Bull_vs_Medved(1)
Bull_vs_Medved(1)

Bull_vs_Medved(1)最新版

更新日期:
2022-03-01
分类标签:
语言:
中文
平台:
没限制

28 人已下载 手机查看

//+——————————————————————+
//| Bull vs Medved.mq4 |
//| Copyright ?2008, Andrey Kuzmenko (Foxbat) |
//| mailto:foxbat-b@mail.ru |
//+——————————————————————+
//| 湾觐蝾瘥?”钺镱脲珥” 趔黻鲨?觐溧, 蝠彘腓磴 耱铒, 磬镳桁屦, |
//| 猁腓 膻徨珥?镱玎桁耱忸忄睇 桤 漯筱桴 耧屦蝾? |
//+——————————————————————+
#property copyright “Copyright ?2008, Andrey Kuzmenko (Foxbat)”
#property link “foxbat-b@mail.ru”
//—-
#define MAGIC 612453
//—-
extern double Lots = 0.10; // 疣珈屦 腩蜞
extern double CandleSize =75; // 疣珈屦 蝈豚 疋鬻?
extern double k_sl=0.8; // 羽钼屙?StopLoss 铒疱溴?弪? 赅?CandleSize*k_sl
extern double k_tp=0.8; // 羽钼屙?TakeProfit 铒疱溴?弪? 赅?CandleSize*k_tp
extern double popravka_up=16; // 铗耱箫 铗 蝈牦?鲥睇 潆 铗腩驽眄钽?铕溴疣 Buylimit
extern double popravka_down=20; // 铗耱箫 铗 蝈牦?鲥睇 潆 铗腩驽眄钽?铕溴疣 Selllimit
extern bool flag = true;
extern string StartTime=”0:05″;// 吗屐 耱囵蜞 镱 沭桧忤黧
extern string StartTime1=”4:05″;
extern string StartTime2=”8:05″;
extern string StartTime3=”12:05″;
extern string StartTime4=”16:05″;
extern string StartTime5=”20:05″;
datetime TimeStart;
datetime TimeStart1;
datetime TimeStart2;
datetime TimeStart3;
datetime TimeStart4;
datetime TimeStart5;
bool trade=false;
bool trade1=false;
//—-
double Limit = 400;
color clOpenBuy = Blue;
color clCloseBuy = Aqua;
color clOpenSell = Red;
color clCloseSell = Violet;
color clModiBuy = Blue;
color clModiSell = Red;
string Name_Expert = “Bull vs Medved”;
int Slippage = 0;
bool UseSound = True;
string NameFileSound = “alert.wav”;
//+——————————————————————+
//| |
//+——————————————————————+
bool IsBull()
{
if
((Close[3]>Open[2])&&
(Close[2]-Open[2] >= 10*Point)&&
(Close[1]-Open[1] >= CandleSize*Point) )
return(true);
else
return(false);
}

bool IsBadBull()
{
if
((Close[3]-Open[3] >= 10*Point)&&
(Close[2]-Open[2] >= 10*Point)&&
(Close[1]-Open[1] >= CandleSize*Point) )
return(true);
else
return(false);
}
bool IsCoolBull()
{
if
((Open[2]-Close[2] >= 20*Point)&&
(Close[2]<=Open[1])&&
(Close[1]>Open[2])&&
(Close[1]-Open[1] >= 0.4*CandleSize*Point) )
return(true);
else
return(false);
}
//+——————————————————————+
//| |
//+——————————————————————+
bool IsBear()
{
if((Open[1] – Close[1] >= CandleSize*Point))
return(true);
else
return(false);
}
//+——————————————————————+
//| |
//+——————————————————————+
int start()
{

// 襄疱忸滂?怵屐 桤 耱痤黜铋 忮腓麒睇 StartTime 忸 怵屐屙碛?TimeStart
TimeStart=StrToTime(StartTime);
TimeStart1=StrToTime(StartTime1);
TimeStart2=StrToTime(StartTime2);
TimeStart3=StrToTime(StartTime3);
TimeStart4=StrToTime(StartTime4);
TimeStart5=StrToTime(StartTime5);
// 篷腓 蝈牦?怵屐 戾睃 耱囵蝾忸泐 桦?犷朦 邈?磬 5 扈眢? 蝾 恹躅滂??龛麇泐 礤 溴豚屐.
// 皖 镳邃忄痂蝈朦眍 溴豚屐 镥疱戾眄簋 trade 腩骓铋. 橡铖蝾 襻疣覃忄屐 桧纛痨圉棹 ?蝾? 黩?箧?铗牮嚯桉?
if(CurTime()<TimeStart || CurTime()>TimeStart+300 &&
CurTime()<TimeStart1 || CurTime()>TimeStart1+300 &&
CurTime()<TimeStart2 || CurTime()>TimeStart2+300 &&
CurTime()<TimeStart3|| CurTime()>TimeStart3+300 &&
CurTime()<TimeStart4|| CurTime()>TimeStart4+300 &&
CurTime()<TimeStart5 || CurTime()>TimeStart5+300 )
{ trade=false; return(0); }

if(trade) return(0);

//橡钼屦桁 礤?腓 ?磬?铗腩驽眄 铕溴痤? 觐蝾瘥? 忤???徨玟彘耱怏 4 鬣襦. 篷腓 蜞觐恹?羼螯 箐嚯桁 桴.
{
int total =OrdersTotal();
int ticket=OrderTicket();
{
for(int i=0;i<=total;i++)
{
if(OrderSelect(i,SELECT_BY_POS))
{if(OrderSymbol()==Symbol())
{if(OrderType()>1)
{if(TimeCurrent()-OrderOpenTime()>230*60)
{

ticket=OrderTicket();
OrderDelete(OrderTicket());
}
}
}
}
break;
}
}

{

if(AccountFreeMargin() < (1000*Lots))
{
Print(“We have no money. Free Margin = “, AccountFreeMargin());
return(0);
}
if(!ExistPositions())
{

if(IsBull() == true && IsBadBull() == false)
{
OpenBuy();
return(0);
}

}

if(!ExistPositions())
{

if(IsCoolBull() == true )
{
OpenBuy();
return(0);
}

}

if(!ExistPositions())
{

if(IsBear() == true)
{
OpenSell();
return(0);
}

}

return (0);
}

}

}
//+——————————————————————+
//| |
//+——————————————————————+
bool ExistPositions()
{
for(int i = 0; i < OrdersTotal(); i++)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if(OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC)
{
return(True);
}
}
}
return(false);
}
//+——————————————————————+
//| |
//+——————————————————————+

void OpenBuy()
{
{
double ldLot, ldStop, ldTake;
string lsComm;
int i = 1;
int orders = HistoryTotal();
ldLot = Lots;
ldStop = GetStopLossBuy();
ldTake = GetTakeProfitBuy();
lsComm = GetCommentForOrder();
OrderSend(Symbol(), OP_BUYLIMIT, ldLot, Ask-popravka_up*Point, Slippage,ldStop, ldTake, lsComm, MAGIC,0, clOpenBuy);
if(UseSound)
PlaySound(NameFileSound);
}
}
//+——————————————————————+
//| |
//+——————————————————————+
void OpenSell()
{
double ldLot, ldStop, ldTake;
string lsComm;
int i = 1;
int orders = HistoryTotal();
ldLot = Lots;
ldStop = GetStopLossSell();
ldTake = GetTakeProfitSell();
lsComm = GetCommentForOrder();
OrderSend(Symbol(), OP_SELLLIMIT, ldLot, Bid+popravka_down*Point, Slippage, ldStop, ldTake, lsComm, MAGIC,0, clOpenSell);
if(UseSound)
PlaySound(NameFileSound);
}

//+——————————————————————+
//| |
//+——————————————————————+
string GetCommentForOrder()
{
return(Name_Expert);
}
//+——————————————————————+
//| |
//+——————————————————————+
double GetStopLossBuy()
{
int sl;
sl=MathRound((Close[1]-Open[1])*10000*k_sl);
return(Bid – sl*Point);
}
//+——————————————————————+
//| |
//+——————————————————————+
double GetStopLossSell()
{
int sl;
sl=MathRound((Open[1]-Close[1])*10000*k_sl);

return(Ask + sl*Point);
}
//+——————————————————————+
//| |
//+——————————————————————+
double GetTakeProfitBuy()
{
int tp;
tp=MathRound((Close[1]-Open[1])*10000*k_tp);
return(Ask + tp*Point);
}
//+——————————————————————+
//| |
//+——————————————————————+
double GetTakeProfitSell()
{
int tp;
tp=MathRound((Open[1]-Close[1])*10000*k_tp);
return(Bid – tp*Point);
}
//—-
return(0);
//+——————————————————————+

 

 

如果你对文件有了解,请帮助投票!

If you are familiar with the file, please help vote!

平均评分 0 / 5. 投票数: 0

到目前为止还没有投票!成为第一位投票人。

相关资源

暂无评论

none
暂无评论...