e-Trailing

e-Trailing 最新版

官方版 无广告 57

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

14 人已下载 手机查看

//+------------------------------------------------------------------+
//| e-Trailing.mq4 |
//| 疏?茹铕?? aka KimIV |
//| http://www.kimiv.ru |
//| |
//| 12.09.2005 棱蝾爨蜩麇耜栝 Trailing Stop 怦艴 铗牮 镱玷鲨? |
//| 洛螯 蝾朦觐 磬 钿桧 沭圄桕 |
//| 21.01.2006 相疣戾蝠 AllPositions |
//+------------------------------------------------------------------+
#property copyright "疏?茹铕?? aka KimIV"
#property link "http://www.kimiv.ru"
//------- 马屮龛?镟疣戾蝠?------------------------------------------
extern bool AllPositions =False; // 语疣怆螯 怦屐?镱玷鲨扈
extern bool ProfitTrailing=True; // 茵嚯栩?蝾朦觐 镳铘栩
extern int TrailingStop =15; // 澡犟桊钼囗睇?疣珈屦 蝠嚯?
extern int TrailingStep =2; // 剜?蝠嚯?
extern bool UseSound =True; // 锐镱朦珙忄螯 玮箨钼铋 耔沩嚯
extern string NameFileSound ="expert.wav"; // 袜桁屙钼囗桢 玮箨钼钽?羿殡?
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
void start()
{
for(int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (AllPositions || OrderSymbol()==Symbol())
{
TrailingPositions();
}
}
}
}
//+------------------------------------------------------------------+
//| 杨镳钼铈溴龛?镱玷鲨?镳铖螓?蝠嚯铎 |
//+------------------------------------------------------------------+
void TrailingPositions()
{
double pBid, pAsk, pp;
//----
pp=MarketInfo(OrderSymbol(), MODE_POINT);
if (OrderType()==OP_BUY)
{
pBid=MarketInfo(OrderSymbol(), MODE_BID);
if (!ProfitTrailing || (pBid-OrderOpenPrice())>TrailingStop*pp)
{
if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep-1)*pp)
{
ModifyStopLoss(pBid-TrailingStop*pp);
return;
}
}
}
if (OrderType()==OP_SELL)
{
pAsk=MarketInfo(OrderSymbol(), MODE_ASK);
if (!ProfitTrailing || OrderOpenPrice()-pAsk>TrailingStop*pp)
{
if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep-1)*pp || OrderStopLoss()==0)
{
ModifyStopLoss(pAsk+TrailingStop*pp);
return;
}
}
}
}
//+------------------------------------------------------------------+
//| 襄疱眍?箴钼? StopLoss |
//| 相疣戾蝠? |
//| ldStopLoss - 箴钼屙?StopLoss |
//+------------------------------------------------------------------+
void ModifyStopLoss(double ldStopLoss)
{
bool fm;
fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);
if (fm && UseSound) PlaySound(NameFileSound);
}
//+------------------------------------------------------------------+

相关资源

暂无评论

暂无评论...