顺水外汇EA交易网MT4
标题:
高手帮忙,搞了个EA,只有3档止损位,麻烦 帮忙加成5档 ...
[打印本页]
作者:
qq1850141942
时间:
2014-10-30 18:51
标题:
高手帮忙,搞了个EA,只有3档止损位,麻烦 帮忙加成5档 ...
高手帮忙,本人在论坛里搞了个EA,只有3档止损位,麻烦 帮忙加成5档 ... 高手,帮忙下 本人对程序不懂!!
需要改成 如下图 附上源码!
//+------------------------------------------------------------------+
//| TakeProfit.mq4 |
//| Modded slightly by verbtheory for verbtheory's day break system |
//| Copyright ?2006, Taylor Stockwell |
//| stockwet@yahoo.com |
//| Version: 2.4 |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2006, Taylor Stockwell"
#property link "stockwet@yahoo.com"
/*
Updates:
11/2/2006:: Fixed bug that caused the sl var to be set to 1 when a pending
order was > than the First_Stop_Target value.
1/23/2007:: Fixed pip calculation. The old way of calculating pips could be
off by 1 pip, resulting in missed TP or move stops. The new
calculation is more accurate.
4/07/2009:: Adding trailing stop, enhancing shortly.
*/
//=============== VARS external
extern int First_Target = 50;
extern int Target_Increment = 25;
extern double Close_Lots = 0;
extern bool Move_Stops = true;
extern int First_Stop_Target = 80;
extern int First_Stop = 20;
extern int Second_Stop_Target = 350;
extern int Second_Stop = 200;
extern int Third_Stop_Target = 650;
extern int Third_Stop = 500;
extern bool Use_Max_Loss = true;
extern int Max_Loss = 350;
extern int Magic_Number=0;
//=============== VARS internal
int nextTP;
bool sl;
int range = 5;
int multiplier;
// OrderType == 1 is OP_SELL
//=============== FUNCTION init
int init()
{
sl=0;
nextTP = First_Target;
getMaxLoss();
}
//== end function
//=============== FUNCTION deinit
int deinit()
{
//----
sl=0;
nextTP = First_Target;
//----
return(0);
}
//== end function
//========== FUNCTION Start
int start()
{
//----
getOpenOrders();
getSpread();
//Comment(sl);
//----
return(0);
}
//== end function
//========== FUNCTION getPipValue
double getPipValue(double ord,int dir)
{
double val;
RefreshRates();
if(dir == 1) val=(NormalizeDouble(ord,Digits) - NormalizeDouble(Ask,Digits));
else val=(NormalizeDouble(Bid,Digits) - NormalizeDouble(ord,Digits));
val = val/Point;
return(val);
}
//== end function
int getSpread()
{
int spread=MarketInfo(Symbol(),MODE_SPREAD);
return(spread);
}
int getMaxLoss()
{
int calcMaxLoss;
calcMaxLoss = Max_Loss;
return(calcMaxLoss);
}
//========== FUNCTION getOpenOrders
void getOpenOrders()
{
int nsl, nsd;
string mngMagic;
int totalorders = OrdersTotal();
for(int j=0; j 0) killTrade(val,OrderTicket());
if(Move_Stops) checkStops(val,OrderTicket());
takeProfit(val,OrderTicket());
}
if(Magic_Number == 0)
mngMagic = "All "+Symbol()+" trades.";
else
mngMagic = "Trades with magic number = "+Magic_Number;
if(sl==0)
{
nsl = First_Stop_Target;
nsd = First_Stop;
}
else
{
nsl = Second_Stop_Target;
nsd = Second_Stop;
}
//RefreshRates();
Comment("Order Open: ",OrderOpenPrice(),
"\nPip Count: ", val,
"\nNext Stop Target: ",nsl,
"\nNext Stop Differential: ", nsd,
"\nNext TP: ", nextTP,
"\nSL: ",sl,
"\nMax Loss: ", getMaxLoss(),
"\nManaging: ",mngMagic);
}
}
//========== FUNCTION takeProfit
void takeProfit(int pips, int ticket)
{
if(OrderSelect(ticket, SELECT_BY_TICKET)==true)
{
if(pips >= nextTP && pips = First_Stop_Target && pips = Second_Stop_Target)
{
if(pips >= Second_Stop_Target)
{
moveStops(ticket,Second_Stop);
}
}
else if(sl==1 || pips >= Third_Stop_Target)
{
if(pips >= Third_Stop_Target)
{
moveStops(ticket,Third_Stop);
}
}
}
//== end function
//========== FUNCTION moveStops
void moveStops(int ticket,int stopDiff)
{
if(OrderSelect(ticket, SELECT_BY_TICKET)==true)
{
Print("moveStops called ",ticket, " ",stopDiff);
if(OrderType()==1)
{
OrderModify(ticket,OrderOpenPrice(),OrderOpenPrice()-stopDiff*Point, OrderTakeProfit(),0,Plum);
sl=1;
}
else
{
OrderModify(ticket,OrderOpenPrice(),OrderOpenPrice()+stopDiff*Point, OrderTakeProfit(),0,Plum);
sl=1;
}
}
}
//== end function
//========== FUNCTION killTrades
void killTrade(int pips, int ticket)
{
if(OrderSelect(ticket, SELECT_BY_TICKET)==true)
{
if(pips <= -1*getMaxLoss())
{
if(OrderType()==1) OrderClose(ticket,OrderLots(),Ask,3,Red);
else OrderClose(ticket,OrderLots(),Bid,3,Red);
}
}
}
//== end function
需要加上 fourth stop target 3000
fourth stop 2000
fifth stop target 5000
fifth stop 4000
谢谢了
作者:
george2100
时间:
2014-10-30 18:58
11111111111111
作者:
olp
时间:
2014-10-30 18:58
看看路过
作者:
digit
时间:
2014-10-30 19:07
只有三档?现在都至少五档吧:
作者:
KSXJM
时间:
2014-10-30 20:11
真牛。。。。。。
作者:
ivan29
时间:
2014-10-30 20:27
打酱油的这么多 ,高手呢 ?
作者:
qq1850141942
时间:
2014-10-30 20:47
aaaaaaaaaaaaaa
作者:
li2816
时间:
2014-10-30 21:46
LAIKANKAN
作者:
ajie427
时间:
2014-10-31 10:36
打酱油的那么多,真的高手没见过,我需要一个真真正正的高手来帮我!!!
作者:
qq1850141942
时间:
2014-10-31 13:55
路过赚分
作者:
xiao1a
时间:
2014-10-31 16:00
小白表示看不懂
作者:
linux28
时间:
2014-10-31 18:16
路过
等有空也学一下
作者:
小明112
时间:
2014-10-31 20:19
高手 {:soso__ff2cd69fa6159eab-977787f8666a1d8e-d77c3ed4dc2c03e1bf2e7387c3b75016.jpg_1:}
作者:
qq1850141942
时间:
2014-11-1 15:57
谢谢分享
欢迎光临 顺水外汇EA交易网MT4 (http://waterforex.com/)
Powered by Discuz! X3.2