中国人
发表于 2022-10-9 20:24:55
{:1_186:}
笑看华尔街
发表于 2022-10-9 22:42:47
顶下
元杰
发表于 2022-10-11 13:50:29
顶下
福哥
发表于 2022-10-13 16:24:10
支持下
山石之间
发表于 2022-10-14 19:59:32
{:1_179:}
空之轨迹
发表于 2022-10-15 12:54:32
{:1_179:}
交易乐趣
发表于 2022-10-19 15:53:01
支持下
triple3
发表于 2024-10-29 15:57:55
//+------------------------------------------------------------------+
//| ProjectName |
//| Copyright 2018, CompanyName |
//| http://www.companyname.net |
//+------------------------------------------------------------------+
string 受限联系QQ号="2358587193";
bool 是否限制使用时间=true;
datetime 允许运行到终止时间=D'2021.03.28 00:00';
bool 是否开启账号绑定限制他人使用=false;
int 允许运行此EA的账号= {10068018,137411,8088091,134903,630105,131891}; //允许多个账号时,账号间请用分号隔开,如下:允许运行此EA的账号={12345,11111,22222,33333,44444,55555};
input double 单量相对原来的倍率=0.1;
extern int MaxTicket = 16;//最大开仓层数
extern int AddPoint = 60;//加仓间隔
string 灬b1="---------";
input string 建仓手数_可增减="0.2/0.2/0.3/0.45/0.68/1.01/1.52/2.28/3.42/5.13/7.69/9.45/11.54/17.43/25.89/25.89";
input int A_单边持仓达到N单后=5;
input int A_价格间隔应大于N微点=100;
input double A_单量相对原来的倍率=0.1;
input int B_单边持仓达到N单后=9;
input int B_价格间隔应大于N微点=150;
input double B_单量相对原来的倍率=0.1;
input int C_单边持仓达到N单后=12;
input int C_价格间隔应大于N微点=200;
input double C_单量相对原来的倍率=0.1;
input string 灬d1="---------";
input bool 是否开启收盘时加仓=false;
int B_单向均价盈利N微点后_0为关闭=0;
int B_追踪止损于盈利回撤N微点平仓_0为关闭=0;
extern double KongStopPrice = 2000.0; //止损N微点
extern int WinPoint = 30;//获利目标
input string 灬d2="---------";
input string 说明1: = "最大开仓数量,本EA基于五位报价";
input string 说明2: = "基础参数";
extern bool Duo = TRUE;//多单开关
extern bool Kong = TRUE;//空单开关
extern double DuoStopPrice = 0.1;
extern string 说明3: = "";
extern double XiShu = 0.1;
extern string 说明4: = "";
string 说明5: = "智能功能区,默认开启";
extern bool IsCloseByTotal = TRUE;
int Gi_164 = 6;
extern bool IsCloseByTime = TRUE;
int Hours = 24;
bool IsSendMail = FALSE;
string 说明7: = "";
int Slippage = 10;//最大滑点
string Flags = "QQ2358587193";
extern int Magic = 501371;
double Money = 10000000000000000.0;
datetime Gt_212 = 0;
double Gd_216 = 0.1;
int ZH_01 = 5010541;//真实账号绑定
string Gs_buy_224 = "Buy";
string Gs_sell_232 = "Sell";
int Gi_240 = 0;
int Gi_244 = 0;
double Gd_248 = 0.0;
int Gi_256 = 0;
//int Gi_tm2 = D'201.01.28';//时间年.月.日(EA的到期时间)
int Gi_260 = 0;
int Gi_264 = 0;
bool Gi_268 = TRUE;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
double minlot=MarketInfo(Symbol(), MODE_MINLOT);
double maxlot=MarketInfo(Symbol(), MODE_MAXLOT);
int init()
{
Gi_256= (TimeCurrent());
/*/if(Gi_256>=Gi_tm2) {
Gi_268 = FALSE;
Alert("EA停止工作,原因是EA过期");
}/*/
if(MaxTicket > 25)
{
Gi_268 = FALSE;
Alert("MaxTicket最大值是25。");
}
if(MaxTicket > 25)
MaxTicket = 25;//(MaxTicket > 16) MaxTicket = 16;
Gs_buy_224 = Symbol() + "Buy" + Flags;
Gs_sell_232 = Symbol() + "Sell" + Flags;
Gi_260 = 0;
Gi_264 = 0;
Gd_248 = f0_25();
Print("微信:2358587193" + Gd_248);
Print("加载完成!" + Magic);
f0_26("message2", Flags + " :标识", 5, 5, 10, "Verdana", Orchid, 3);
f0_26("message4", WinPoint + " :止盈", 5, 45, 10, "Verdana", Orchid, 3);
f0_26("message5", AccountLeverage() + " :杠杆", 5, 65, 10, "Verdana", Orchid, 3);
return (0);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return (0);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//-------------------------------------------------------------
int start()
{
bool isAllowTrade=false;
for(int i=0; i<100; i++)
{
if(((TimeCurrent()<允许运行到终止时间&&TimeLocal()<允许运行到终止时间)||!是否限制使用时间)&&(AccountNumber()==允许运行此EA的账号||!是否开启账号绑定限制他人使用))
{
isAllowTrade=True;
break;
}
}
if(!isAllowTrade&&AccountNumber()>0)
{
Alert("请联系QQ"+受限联系QQ号+",获取使用权限");
Sleep(5000);
return(0);
}
//订单统计 NormalizeDouble规范小数点 注意:除法的分母必须为小数,%余数必须整数。
double ArrayProfit[];
ArrayResize(ArrayProfit,OrdersTotal());
int NewKBuyVol=0,NewKSellVol=0,NewKAllVol=0;
int BuyVol=0,SellVol=0,AllVol=0,FirstAllType=8,LastAllType=8;
double BuyLots=0,SellLots=0,AllLots=0,BuyLowestLots=0,SellLowestLots=0,BuyHighestLots=0,SellHighestLots=0,BuyHighLots=0,SellHighLots=0,BuyLowLots=0,SellLowLots=0,BuyProfit=0,SellProfit=0,AllProfit=0,AllSwap=0,FirstAllProfit=0,LastAllProfit=0;
double AllBuyOpenPrice=0,AllSellOpenPrice=0,AllTPHighest=0,AllTPLowest=0,AllTPHighestPoint=0,AllTPLowestPoint=0;
double BuyLowest=0,SellLowest=0,BuyHighest=0,SellHighest=0,AllLowest=0,AllHighest=0;
double FirstBuyOpenPrice=0,FirstSellOpenPrice=0,FirstAllOpenPrice=0,LastBuyOpenPrice=0,LastSellOpenPrice=0,FirstBuyLots=0,FirstSellLots=0,FirstAllLots=0,LastAllOpenPrice=0,LastBuyLots=0,LastSellLots=0,LastAllLots=0,Last2BuyLots=0,Last2SellLots=0,Last2AllLots=0;
datetime FirstBuyOpenTime=0,FirstSellOpenTime=0,FirstAllOpenTime=0,LastBuyOpenTime=0,LastSellOpenTime=0,LastAllOpenTime=0;
int PendAllVol=0;
double PendAllLots=0;
int PendCutBuyVol=0,PendCutSellVol=0;
int PendBuyVol=0,PendSellVol=0;
double PendBuyLots=0,PendSellLots=0,PendBuyLowest=0,PendBuyHighest=0,PendFirstBuyLots=0,PendFirstBuyOpenPrice=0,PendLastBuyOpenPrice=0,PendLastBuyLots=0,PendBuyHighestLots=0,PendBuyLowestLots=0,PendSellLowestLots=0,PendSellHighestLots=0;
double PendSellLowest=0,PendSellHighest=0,PendFirstSellLots=0,PendFirstSellOpenPrice=0,PendLastSellOpenPrice=0,PendLastSellLots=0;
double PendCutSellLowest=0,PendCutSellHighest=0,PendCutBuyLowest=0,PendCutBuyHighest=0;
datetime PendFirstBuyOpenTime=0,PendLastBuyOpenTime=0,PendFirstSellOpenTime=0,PendLastSellOpenTime=0;
if(OrdersTotal()>=0)
{
for(i=OrdersTotal()-1; i>=0; i--) //和历史统计一样,从0表示First首单。 for(int i=0;i<OrdersTotal();i++)//从First首单开始扫描。
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic) //&&OrderOpenTime()>=StartTime
{
if(OrderType()==0||OrderType()==1)
{
if(OrderOpenTime()>=Time)
{
NewKAllVol++;//当前K线中已建仓数量
}
ArrayProfit=OrderProfit()+OrderCommission()+OrderSwap();
AllVol++;
if(AllVol==2)
{
Last2AllLots=OrderLots();
}
AllLots=AllLots+OrderLots();//MarketInfo(Symbol(), MODE_MARGINREQUIRED)1标准手所需保证金
AllProfit=AllProfit+OrderProfit()+OrderCommission()+OrderSwap();
AllSwap=AllSwap+OrderCommission()+OrderSwap();
if((AllTPHighest<OrderProfit())||AllTPHighest==0)
{
AllTPHighest=OrderProfit();
AllTPHighestPoint=MathAbs(OrderOpenPrice()-Bid)/Point;
}
if((AllTPLowest>OrderProfit())||AllTPLowest==0)
{
AllTPLowest=OrderProfit();
AllTPLowestPoint=MathAbs(OrderOpenPrice()-Bid)/Point;
}
if(FirstAllOpenTime>OrderOpenTime()||FirstAllOpenTime==0)
{
FirstAllOpenTime=OrderOpenTime(); //最后单的入场时间。
FirstAllLots=OrderLots();
FirstAllOpenPrice=OrderOpenPrice();
FirstAllType=OrderType();
FirstAllProfit=OrderProfit();
}
if(LastAllOpenTime<OrderOpenTime())
{
LastAllOpenTime=OrderOpenTime(); //最后单的入场时间。
LastAllLots=OrderLots();
LastAllOpenPrice=OrderOpenPrice();
LastAllType=OrderType();
LastAllProfit=OrderProfit();
}
if(AllLowest>OrderOpenPrice()||AllLowest==0)
{
AllLowest=OrderOpenPrice();//建仓最低价格。
}
if(AllHighest<OrderOpenPrice())
{
AllHighest=OrderOpenPrice();//建仓最高价格。
}
}
if(OrderType()==0)
{
if(OrderOpenTime()>=Time)
{
NewKBuyVol++;
}
BuyVol++; //if(BuyVol==2) {Last2BuyOpenPrice=OrderOpenPrice();}
if(BuyVol==2)
{
Last2BuyLots=OrderLots();
}
BuyLots=BuyLots+OrderLots();
if(BuyHighLots<OrderLots())
{
BuyHighLots=OrderLots();
}
if(BuyLowLots>OrderLots()||BuyLowLots==0)
{
BuyLowLots=OrderLots();
}
AllBuyOpenPrice=AllBuyOpenPrice+OrderOpenPrice()*OrderLots();
BuyProfit=BuyProfit+OrderProfit()+OrderCommission()+OrderSwap();
if(FirstBuyOpenTime>OrderOpenTime()||FirstBuyOpenTime==0)
{
FirstBuyOpenTime=OrderOpenTime(); //最先交易的多单入场时间与价格。
FirstBuyLots=OrderLots();
FirstBuyOpenPrice=OrderOpenPrice();
}
if(LastBuyOpenTime<OrderOpenTime()||LastBuyOpenTime==0)
{
LastBuyOpenTime=OrderOpenTime(); //最后交易的多单入场时间。if(BuyVol==1)也可以。
LastBuyLots=OrderLots();
LastBuyOpenPrice=OrderOpenPrice();
}
if(BuyLowest>OrderOpenPrice()||BuyLowest==0)
{
BuyLowest=OrderOpenPrice(); //买单中建仓最低价格。
BuyLowestLots=OrderLots();
}
if(BuyHighest<OrderOpenPrice())
{
BuyHighest=OrderOpenPrice(); //买单中建仓最高价格。
BuyHighestLots=OrderLots();
}
}
if(OrderType()==1)
{
if(OrderOpenTime()>=Time)
{
NewKSellVol++;
}
SellVol++;
if(SellVol==2)
{
Last2SellLots=OrderLots();
}
SellLots=SellLots+OrderLots();
if(SellHighLots<OrderLots())
{
SellHighLots=OrderLots();
}
if(SellLowLots>OrderLots()||SellLowLots==0)
{
SellLowLots=OrderLots();
}
AllSellOpenPrice=AllSellOpenPrice+OrderOpenPrice()*OrderLots();
SellProfit=SellProfit+OrderProfit()+OrderCommission()+OrderSwap();
if(FirstSellOpenTime>OrderOpenTime()||FirstSellOpenTime==0)
{
FirstSellOpenTime=OrderOpenTime(); //最先交易的卖单入场时间与价格。
FirstSellLots=OrderLots();
FirstSellOpenPrice=OrderOpenPrice();
}
if(LastSellOpenTime<OrderOpenTime()||LastSellOpenTime==0)
{
LastSellOpenTime=OrderOpenTime(); //最后交易的卖单入场时间。if(SellVol==1)也可以。
LastSellLots=OrderLots();
LastSellOpenPrice=OrderOpenPrice();
}
if(SellLowest>OrderOpenPrice()||SellLowest==0)
{
SellLowest=OrderOpenPrice(); //卖单中建仓最低价格。
SellLowestLots=OrderLots();
}
if(SellHighest<OrderOpenPrice())
{
SellHighest=OrderOpenPrice(); //卖单中建仓最高价格。
SellHighestLots=OrderLots();
}
}
PendAllVol++;
PendAllLots=PendAllLots+OrderLots();
if(OrderType()==0||OrderType()==2||OrderType()==4)
{
PendBuyVol++;
PendBuyLots=PendBuyLots+OrderLots();
if(PendBuyLowest>OrderOpenPrice()||PendBuyLowest==0)
{
PendBuyLowest=OrderOpenPrice(); //买单中建仓最低价格。
PendBuyLowestLots=OrderLots();
}
if(PendBuyHighest<OrderOpenPrice())
{
PendBuyHighest=OrderOpenPrice(); //买单中建仓最高价格。
PendBuyHighestLots=OrderLots();
}
if(PendFirstBuyOpenTime>OrderOpenTime()||PendFirstBuyOpenTime==0)
{
PendFirstBuyOpenTime=OrderOpenTime(); //最先交易的多单入场时间与价格。
PendFirstBuyLots=OrderLots();
PendFirstBuyOpenPrice=OrderOpenPrice();
}
if(PendLastBuyOpenTime<OrderOpenTime()||PendLastBuyOpenTime==0)
{
PendLastBuyOpenTime=OrderOpenTime(); //最后交易的多单入场时间。if(BuyVol==1)也可以。
PendLastBuyLots=OrderLots();
PendLastBuyOpenPrice=OrderOpenPrice();
}
}
if(OrderType()==1||OrderType()==3||OrderType()==5)
{
PendSellVol++;
PendSellLots=PendSellLots+OrderLots();
if(PendSellLowest>OrderOpenPrice()||PendSellLowest==0)
{
PendSellLowest=OrderOpenPrice(); //卖单中建仓最低价格。
PendSellLowestLots=OrderLots();
}
if(PendSellHighest<OrderOpenPrice())
{
PendSellHighest=OrderOpenPrice(); //卖单中建仓最高价格。
PendSellHighestLots=OrderLots();
}
if(PendFirstSellOpenTime>OrderOpenTime()||PendFirstSellOpenTime==0)
{
PendFirstSellOpenTime=OrderOpenTime(); //最先交易的卖单入场时间与价格。
PendFirstSellLots=OrderLots();
PendFirstSellOpenPrice=OrderOpenPrice();
}
if(PendLastSellOpenTime<OrderOpenTime()||PendLastSellOpenTime==0)
{
PendLastSellOpenTime=OrderOpenTime(); //最后交易的卖单入场时间。if(SellVol==1)也可以。
PendLastSellLots=OrderLots();
PendLastSellOpenPrice=OrderOpenPrice();
}
}
if(OrderType()==2||OrderType()==4)
{
PendCutBuyVol++;
if(PendCutBuyLowest>OrderOpenPrice()||PendCutBuyLowest==0)
{
PendCutBuyLowest=OrderOpenPrice();//买单中建仓最低价格。
}
if(PendCutBuyHighest<OrderOpenPrice())
{
PendCutBuyHighest=OrderOpenPrice();//买单中建仓最高价格。
}
}
if(OrderType()==3||OrderType()==5)
{
PendCutSellVol++;
if(PendCutSellLowest>OrderOpenPrice()||PendCutSellLowest==0)
{
PendCutSellLowest=OrderOpenPrice();//卖单中建仓最低价格。
}
if(PendCutSellHighest<OrderOpenPrice())
{
PendCutSellHighest=OrderOpenPrice();//卖单中建仓最高价格。
}
}
}
}
}
}
if(AllVol>0)
{
ArraySort(ArrayProfit,WHOLE_ARRAY,0,MODE_ASCEND);
}
double BuyMAPrice=0;//请应用时确保 BuyMAPrice>0
if(BuyLots>0)
{
BuyMAPrice=NormalizeDouble(AllBuyOpenPrice/BuyLots,Digits);
}
double SellMAPrice=0; //请应用时确保 SellMAPrice>0
if(SellLots>0)
{
SellMAPrice=NormalizeDouble(AllSellOpenPrice/SellLots,Digits);
}
static double Profitest=0;
if(AllVol>0&&Profitest<AllProfit)
{
Profitest=AllProfit;
}
if(AllVol==0)
{
Profitest=0;
}
//建仓条件
int B间隔=AddPoint,S间隔=AddPoint;
double B单量相对倍率=单量相对原来的倍率,S单量相对倍率=单量相对原来的倍率;
if(BuyVol>=A_单边持仓达到N单后)
{
B间隔=A_价格间隔应大于N微点;
B单量相对倍率=A_单量相对原来的倍率;
}
if(BuyVol>=B_单边持仓达到N单后)
{
B间隔=B_价格间隔应大于N微点;
B单量相对倍率=B_单量相对原来的倍率;
}
if(BuyVol>=C_单边持仓达到N单后)
{
B间隔=C_价格间隔应大于N微点;
B单量相对倍率=C_单量相对原来的倍率;
}
if(SellVol>=A_单边持仓达到N单后)
{
S间隔=A_价格间隔应大于N微点;
S单量相对倍率=A_单量相对原来的倍率;
}
if(SellVol>=B_单边持仓达到N单后)
{
S间隔=B_价格间隔应大于N微点;
S单量相对倍率=B_单量相对原来的倍率;
}
if(SellVol>=C_单边持仓达到N单后)
{
S间隔=C_价格间隔应大于N微点;
S单量相对倍率=C_单量相对原来的倍率;
}
bool BuyOrder=false,SellOrder=false;
string B备注="No",S备注="No";
if(B备注=="No"&&BuyVol==0)
{
BuyOrder=true;
}
if(S备注=="No"&&SellVol==0)
{
SellOrder=true;
}
if(B备注=="No"&&BuyVol>0&&BuyLowest-Ask>=B间隔*Point&&(!是否开启收盘时加仓||BuyLowest-Close>=B间隔*Point))
{
BuyOrder=true;
}
if(S备注=="No"&&SellVol>0&&Bid-SellHighest>=S间隔*Point&&(!是否开启收盘时加仓||Close-SellHighest>=S间隔*Point))
{
SellOrder=true;
}
if(OrdersTotal()>0)
{
for(i=OrdersTotal()-1; i>=0; i--) //--写成++会卡且100%漏平
{
RefreshRates();
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
double point=MarketInfo(OrderSymbol(), MODE_POINT);
double profit=OrderProfit()+OrderCommission()+OrderSwap();
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)
{
//标准移动止损
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)
{
continue;
}
RefreshRates();
if(OrderType()==0&&B_单向均价盈利N微点后_0为关闭!=0&&Bid-BuyMAPrice>=B_单向均价盈利N微点后_0为关闭*Point&&B_追踪止损于盈利回撤N微点平仓_0为关闭!=0&&(OrderStopLoss()<Bid-B_追踪止损于盈利回撤N微点平仓_0为关闭*Point-3*Point||OrderStopLoss()==0)) //OrderStopLoss()<Bid-移动止损于回撤多少微点平仓*Point+每盈利N微点移动一次*Point
{
if(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-B_追踪止损于盈利回撤N微点平仓_0为关闭*Point,OrderTakeProfit(),0,clrBlue))
{
Print("移损失败。如还有疑问,请联系QQ837708761。");
}
}
if(OrderType()==1&&B_单向均价盈利N微点后_0为关闭!=0&&SellMAPrice-Ask>=B_单向均价盈利N微点后_0为关闭*Point&&B_追踪止损于盈利回撤N微点平仓_0为关闭!=0&&(OrderStopLoss()>Ask+B_追踪止损于盈利回撤N微点平仓_0为关闭*Point+3*Point||OrderStopLoss()==0))
{
if(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+B_追踪止损于盈利回撤N微点平仓_0为关闭*Point,OrderTakeProfit(),0,clrRed))
{
Print("移损失败。如还有疑问,请联系QQ837708761。");
}
}
}
}
}
}
//全平
CreateButton("CloseAllYCEA","全部平仓?","在全平中",10,40,90,25,13,2,ANCHOR_LEFT,clrWhite,clrBrown,clrGold);
if(ObjectGetInteger(0,"CloseAllYCEA",OBJPROP_STATE)==true)
{
if(OrdersTotal()>0)
{
for(i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true&&OrderSymbol()==Symbol())
{
if(OrderType()==0)
{
if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),500,0))
{
Print("订单号为",OrderTicket(),"平仓失败",GetLastError());
}
}
if(OrderType()==1)
{
if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),500,0))
{
Print("订单号为",OrderTicket(),"平仓失败",GetLastError());
}
}
if(OrderType()>1)
{
if(!OrderDelete(OrderTicket(),0))
{
Print("订单号为",OrderTicket(),"平仓失败",GetLastError());
}
}
}
}
}
ObjectSetInteger(0,"CloseAllYCEA",OBJPROP_STATE,false); //恢复未按下状态
}
//平多:
CreateButton("CloseBuyYCEA","平仓多单?","在平多中",10,80,90,25,13,2,ANCHOR_LEFT,clrWhite,clrPurple,clrGold);
if(ObjectGetInteger(0,"CloseBuyYCEA",OBJPROP_STATE)==true)
{
if(OrdersTotal()>0)
{
for(i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true&&OrderSymbol()==Symbol())
{
if(OrderType()==0)
{
if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),500,0))
{
Print("订单号为",OrderTicket(),"平仓失败",GetLastError());
}
}
}
}
}
ObjectSetInteger(0,"CloseBuyYCEA",OBJPROP_STATE,false); //恢复未按下状态
}
//平空:
CreateButton("CloseSellYCEA","平仓空单?","在平多中",10,120,90,25,13,2,ANCHOR_LEFT,clrWhite,clrTeal,clrGold);
if(ObjectGetInteger(0,"CloseSellYCEA",OBJPROP_STATE)==true)
{
if(OrdersTotal()>0)
{
for(i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true&&OrderSymbol()==Symbol())
{
if(OrderType()==1)
{
if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),500,0))
{
Print("订单号为",OrderTicket(),"平仓失败",GetLastError());
}
}
}
}
}
ObjectSetInteger(0,"CloseSellYCEA",OBJPROP_STATE,false); //恢复未按下状态
}
int Li_40;
int Li_44;
int Li_48;
int Li_52;
/*/if (AccountNumber() != ZH_01 && IsDemo() == FALSE){
Gi_268 = FALSE;
Alert("测试版EA仅能在模拟账号运行");
}
if (!Gi_268) {
Print("EA不符合运行条件,故终止运行。");
return (0);
}/*/
int Li_0 = 0;
int Li_4 = 0;
Li_0 = f0_4();
Li_4 = f0_13();
double Ld_8 = f0_20("Profit");
double Ld_16 = f0_20("Lots");
double Ld_24 = f0_2("Profit");
double Ld_32 = f0_2("Lots");
if(Li_0 > 1 || Li_4 > 1)
{
if(IsCloseByTotal)
{
if(Li_0 >= Gi_164)
{
if(Ld_8 >= f0_14(Li_0) * Ld_16)
{
f0_28("Buy");
return (0);
}
if(Li_0 > Gi_264)
{
if(IsSendMail)
{
SendMail(Symbol() + "盈亏:" + DoubleToStr(Ld_8, 2) + "仓位:" + DoubleToStr(Ld_16, 2) + "方向:Buy保证金:" + DoubleToStr(AccountMargin(), 2) + "单量:" + Li_0,
"EA邮寄提醒");
}
f0_27(Ld_16, "Buy", AccountMargin(), Li_0);
Gi_264 = Li_0;
}
}
if(Li_4 >= Gi_164)
{
if(Ld_24 >= f0_14(Li_4) * Ld_32)
{
f0_28("Sell");
return (0);
}
if(Li_4 > Gi_260)
{
if(IsSendMail)
{
SendMail(Symbol() + "盈亏:" + DoubleToStr(Ld_24, 2) + "仓位:" + DoubleToStr(Ld_32, 2) + "方向:Sell保证金:" + DoubleToStr(AccountMargin(), 2) + "单量:" + Li_4,
"EA邮寄提醒");
}
f0_27(Ld_32, "Sell", AccountMargin(), Li_4);
Gi_260 = Li_4;
}
}
}
if(IsCloseByTime)
{
Li_40 = f0_6("Buy");
if(Li_0 > 1 && TimeCurrent() - Li_40 >= 3600000 * Hours && Li_40 > 0 && Ld_8 >= 5.0 * Ld_16)
{
f0_28("Buy");
return (0);
}
Li_44 = f0_6("Sell");
if(Li_4 > 1 && TimeCurrent() - Li_44 >= 3600000 * Hours && Li_44 > 0 && Ld_24 >= 5.0 * Ld_32)
{
f0_28("Sell");
return (0);
}
}
}
f0_26("message9", DoubleToStr(Ask, Digits) + " :Buy", 5, 185, 15, "Verdana", Fuchsia, 3);
f0_26("message10", DoubleToStr(Bid, Digits) + " :Sell", 5, 205, 15, "Verdana", Fuchsia, 3);
if(Gt_212 == Time && Li_0 > 0 && Li_4 > 0)
{
if(Duo)
f0_12();
if(Kong)
f0_3();
f0_26("message1", "浮动点差:" + f0_0(), 5, 100, 20, "Verdana", Plum, 0);
f0_26("message16", DoubleToStr(Ld_24, 2) + " :盈亏Sell", 5, 165, 10, "Verdana", Teal, 3);
f0_26("message15", DoubleToStr(Ld_8, 2) + " :盈亏Buy", 5, 125, 10, "Verdana", Teal, 3);
return (0);
}
Gt_212 = Time;
if(Duo)
{
if(Li_0 == 0) //Li_0 买单数量
{
if(Gd_248 >= Money)
{
if(TimeMinute(TimeLocal()) % 10 != 0)
return (0);
Print("已经达到本日最大赢利金额:" + Money);
return (0);
}
if(Duo == TRUE && Bid <= DuoStopPrice)
{
if(TimeMinute(TimeLocal()) % 10 != 0)
return (0);
Print("多单止损价不符合开仓要求,故EA停止开仓。StopPrice=" + KongStopPrice);
return (0);
}
}
if(Li_0 < 1)
{
if(Duo)
{
Gi_240 = f0_8(Gd_216 * XiShu*B单量相对倍率); //f0_8发送做空命令
Print("满足开多首单条件。ID=" + Gi_240);
}
}
else
{
if(Li_0 < MaxTicket)
{
Gi_240 = f0_10();
Li_48 = f0_24(Gi_240);
if(Li_48 <= -f0_9(Li_0)&&BuyOrder) //★★★★★加仓做多的条件
{
Print(Gi_240 + " = " + Li_48);
Gi_240 = f0_18("加仓",B单量相对倍率);
}
}
}
}
if(Kong)
{
if(Li_4 == 0) //Li_4 卖单数量
{
if(Gd_248 >= Money)
{
if(TimeMinute(TimeLocal()) % 10 != 0)
return (0);
Print("已经达到本日最大赢利金额:" + Money);
return (0);
}
if(Kong == TRUE && Ask >= KongStopPrice)
{
if(TimeMinute(TimeLocal()) % 10 != 0)
return (0);
Print("空单止损价不符合开仓要求,故EA停止开仓。KongStopPrice=" + KongStopPrice);
return (0);
}
}
if(Li_4 < 1)
{
if(Kong)
{
Gi_244 = f0_29(Gd_216 * XiShu*S单量相对倍率); //f0_29发送做空命令
Print("满足开空首单条件。ID=" + Gi_244);
}
}
else
{
if(Li_4 < MaxTicket)
{
Gi_244 = f0_19();
Li_52 = f0_24(Gi_244);
if(Li_52 <= -f0_9(Li_4)&&SellOrder) //★★★★★加仓做空的条件
{
Print(Gi_244 + " = " + Li_52);
Gi_244 = f0_23("加仓",S单量相对倍率);
}
}
}
}
f0_26("message6", DoubleToStr(AccountMargin(), 2) + " :使用保证金", 5, 85, 10, "Verdana", Orchid, 3);
f0_26("message7", DoubleToStr(Ld_16, 2) + " :单量Buy", 5, 105, 10, "Verdana", Orchid, 3);
f0_26("message8", DoubleToStr(Ld_32, 2) + " :单量Sell", 5, 145, 10, "Verdana", Orchid, 3);
f0_26("message11", "买编号:" + f0_11(), 5, 20, 10, "Verdana", Plum, 0);
f0_26("message12", "卖编号:" + f0_16(), 5, 40, 10, "Verdana", Plum, 0);
f0_26("message13", "账户名称:" + AccountName(), 5, 60, 13, "Verdana", Plum, 0);
f0_26("message14", "账户ID:" + AccountNumber(), 5, 80, 13, "Verdana", Plum, 0);
return (0);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
int f0_9(int Ai_0)
{
return (AddPoint);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
int f0_14(int Ai_0)
{
if(Ai_0 == Gi_164)
return (WinPoint);//Gi_164 = 6;
if(Ai_0 == Gi_164 + 1)
return (WinPoint - 13);//13
if(Ai_0 == Gi_164 + 2)
return (WinPoint - 13);//20
if(Ai_0 == Gi_164 + 3)
return (WinPoint - 13);//24
if(Ai_0 == Gi_164 + 32)
return (WinPoint - 13);//22
if(Ai_0 == Gi_164 + 5)
return (WinPoint - 13);//40
if(Ai_0 == Gi_164 + 6)
return (WinPoint - 15);//50
if(Ai_0 >= 13)
return (16);//28
return (0);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
/*/
double f0_15(int Ai_0) {
if (Ai_0 == 0) return (手数0);//ifxishu=0.2 return=0.02(xishu/10)=ai_0
if (Ai_0 == 1) return (手数1);//ifxishu=0.2 return=0.02
if (Ai_0 == 2) return (手数2);//ifxishu=0.2 return=0.04
if (Ai_0 == 3) return (手数3);//ifxishu=0.2 return=0.1
if (Ai_0 == 4) return (手数4);//ifxishu=0.2 return=0.16
if (Ai_0 == 5) return (手数5);//ifxishu=0.2 return=0.26
if (Ai_0 == 6) return (手数6);
if (Ai_0 == 7) return (手数7);
if (Ai_0 == 8) return (手数8);
if (Ai_0 == 9) return (手数9);//if (Ai_0 == 9) return (8.5)
if (Ai_0 == 10) return (手数10);//if (Ai_0 == 10) return (12.8)
if (Ai_0 == 11) return (手数11);//if (Ai_0 == 11) return (17.1)
if (Ai_0 == 12) return (手数12);//if (Ai_0 == 12) return (19.2)
if (Ai_0 == 13) return (手数13);//if (Ai_0 == 13) return (29.8)
if (Ai_0 == 14) return (手数14);//if (Ai_0 == 14) return (46.2)
if (Ai_0 == 15) return (手数15);//if (Ai_0 == 15) return (71.6)
if (Ai_0 == 16) return (手数16);
if (Ai_0 == 17) return (手数17);
if (Ai_0 == 18) return (手数18);
if (Ai_0 == 19) return (手数19);
if (Ai_0 == 20) return (手数20);//if (Ai_0 == 15) return (71.6)
return (0.0);
}/*/
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
int f0_6(string As_0)
{
string Ls_12;
for(int Li_8 = 0; Li_8 < OrdersTotal(); Li_8++)
{
if(OrderSelect(Li_8, SELECT_BY_POS, MODE_TRADES))
{
Ls_12 = OrderComment();
if(Gs_buy_224 == StringSubstr(Ls_12, 0, StringFind(Ls_12, "-", 0)))
{
if(As_0 == "Buy")
{
if(!(OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == Magic && OrderLots() == f0_21(XiShu / 10.0)))
continue;
return (OrderOpenTime());
}
if(As_0 == "Sell")
if(OrderSymbol() == Symbol() && OrderType() == OP_SELL && OrderMagicNumber() == Magic && OrderLots() == f0_21(XiShu / 10.0))
return (OrderOpenTime());
}
}
}
return (0);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
void f0_28(string As_0)
{
string Ls_12 = "";
if(As_0 == "Buy")
{
for(int Li_8 = OrdersTotal() - 1; Li_8 >= 0; Li_8--)
{
if(OrderSelect(Li_8, SELECT_BY_POS, MODE_TRADES))
{
Ls_12 = OrderComment();
if(Gs_buy_224 == StringSubstr(Ls_12, 0, StringFind(Ls_12, "-", 0)))
{
if(OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == Magic)
{
RefreshRates();
//bool result = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0);
}
}
}
}
}
if(As_0 == "Sell")
{
for(Li_8 = OrdersTotal(); Li_8 >= 0; Li_8--)
{
if(OrderSelect(Li_8, SELECT_BY_POS, MODE_TRADES))
{
Ls_12 = OrderComment();
if(Gs_sell_232 == StringSubstr(Ls_12, 0, StringFind(Ls_12, "-", 0)))
{
if(OrderSymbol() == Symbol() && OrderType() == OP_SELL && OrderMagicNumber() == Magic)
{
RefreshRates();
//bool results = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0);
}
}
}
}
}
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
double f0_20(string As_0)
{
double Ld_8 = 0;
string Ls_16 = "";
RefreshRates();
for(int Li_24 = 0; Li_24 < OrdersTotal(); Li_24++)
{
if(OrderSelect(Li_24, SELECT_BY_POS, MODE_TRADES))
{
Ls_16 = OrderComment();
if(Gs_buy_224 == StringSubstr(Ls_16, 0, StringFind(Ls_16, "-", 0)))
{
if(OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == Magic)
{
if(As_0 == "Lots")
{
Ld_8 += OrderLots();
continue;
}
if(As_0 == "Profit")
Ld_8 += OrderProfit();
}
}
}
}
return (Ld_8);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
double f0_2(string As_0)
{
double Ld_8 = 0;
string Ls_16 = "";
RefreshRates();
for(int Li_24 = 0; Li_24 < OrdersTotal(); Li_24++)
{
if(OrderSelect(Li_24, SELECT_BY_POS, MODE_TRADES))
{
Ls_16 = OrderComment();
if(Gs_sell_232 == StringSubstr(Ls_16, 0, StringFind(Ls_16, "-", 0)))
{
if(OrderSymbol() == Symbol() && OrderType() == OP_SELL && OrderMagicNumber() == Magic)
{
if(As_0 == "Lots")
{
Ld_8 += OrderLots();
continue;
}
if(As_0 == "Profit")
Ld_8 += OrderProfit();
}
}
}
}
return (Ld_8);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
void f0_12()
{
string Ls_12;
RefreshRates();
double Ld_0 = f0_5();
for(int Li_8 = 0; Li_8 < OrdersTotal(); Li_8++)
{
if(OrderSelect(Li_8, SELECT_BY_POS, MODE_TRADES))
{
Ls_12 = OrderComment();
if(OrderSymbol() == Symbol() && OrderType() == OP_BUY
//&& StringSubstr(Ls_12, 0, StringFind(Ls_12, "-", 0)) == Gs_buy_224
&& OrderMagicNumber() == Magic
//&& Ld_0 > 0.0
)
{
if((OrderTakeProfit() != Ld_0 || OrderStopLoss() != f0_21(DuoStopPrice))
&&(B_单向均价盈利N微点后_0为关闭==0||(OrderStopLoss()==0&&OrderTakeProfit()==0)))
{
bool result = OrderModify(OrderTicket(), OrderOpenPrice(), f0_21(DuoStopPrice), Ld_0, 0, White);//如果没有到达止盈和止损位置,新修改的订单止盈止损
}
}
}
}
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
double f0_5()
{
string Ls_20;
int Li_0 = 0;
double Ld_4 = 0;
int Li_12 = f0_4();
for(int Li_16 = 0; Li_16 < OrdersTotal(); Li_16++)
{
if(OrderSelect(Li_16, SELECT_BY_POS, MODE_TRADES))
{
Ls_20 = OrderComment();
if(OrderSymbol() == Symbol() && OrderType() == OP_BUY && StringSubstr(Ls_20, 0, StringFind(Ls_20, "-", 0)) == Gs_buy_224 && OrderMagicNumber() == Magic)
{
if(Li_12 >= Gi_164)
Ld_4 += OrderOpenPrice() * OrderLots();
else
Ld_4 += OrderOpenPrice();
Li_0++;
}
}
}
if(Li_0 > 0)
{
if(Li_12 >= Gi_164)
return (f0_21(Ld_4 / f0_20("Lots") + WinPoint * MarketInfo(Symbol(), MODE_POINT)));//前开价中这个最小价格改变被称为 点
return (f0_21(Ld_4 / Li_0 + WinPoint * MarketInfo(Symbol(), MODE_POINT)));
}
return (0);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
void f0_3()
{
string Ls_12;
RefreshRates();
double Ld_0 = f0_7();
for(int Li_8 = 0; Li_8 < OrdersTotal(); Li_8++)
{
if(OrderSelect(Li_8, SELECT_BY_POS, MODE_TRADES))
{
Ls_12 = OrderComment();
if(OrderSymbol() == Symbol() && OrderType() == OP_SELL && StringSubstr(Ls_12, 0, StringFind(Ls_12, "-", 0)) == Gs_sell_232 && OrderMagicNumber() == Magic && Ld_0 > 0.0)
if((OrderTakeProfit() != Ld_0 || OrderStopLoss() != f0_21(KongStopPrice))&&(B_单向均价盈利N微点后_0为关闭==0||(OrderStopLoss()==0&&OrderTakeProfit()==0)))
bool result = OrderModify(OrderTicket(), OrderOpenPrice(), f0_21(KongStopPrice), Ld_0, 0, White);
}
}
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
double f0_7()
{
string Ls_20;
int Li_0 = 0;
double Ld_4 = 0;
int Li_12 = f0_13();
for(int Li_16 = 0; Li_16 < OrdersTotal(); Li_16++)
{
if(OrderSelect(Li_16, SELECT_BY_POS, MODE_TRADES))
{
Ls_20 = OrderComment();
if(OrderSymbol() == Symbol() && OrderType() == OP_SELL && StringSubstr(Ls_20, 0, StringFind(Ls_20, "-", 0)) == Gs_sell_232 && OrderMagicNumber() == Magic)
{
if(Li_12 >= Gi_164)
Ld_4 += OrderOpenPrice() * OrderLots();
else
Ld_4 += OrderOpenPrice();
Li_0++;
}
}
}
if(Li_0 > 0)
{
if(Li_12 >= Gi_164)
return (f0_21(Ld_4 / f0_2("Lots") - WinPoint * MarketInfo(Symbol(), MODE_POINT)));
return (f0_21(Ld_4 / Li_0 - WinPoint * MarketInfo(Symbol(), MODE_POINT)));
}
return (0);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
int f0_10()
{
string Ls_4;
Gi_240 = 0;
for(int Li_0 = 0; Li_0 < OrdersTotal(); Li_0++)
{
if(OrderSelect(Li_0, SELECT_BY_POS, MODE_TRADES))
{
Ls_4 = OrderComment();
if(OrderSymbol() == Symbol() && OrderType() == OP_BUY && StringSubstr(Ls_4, 0, StringFind(Ls_4, "-", 0)) == Gs_buy_224 && OrderMagicNumber() == Magic)
if(OrderTicket() > Gi_240)
Gi_240 = OrderTicket();
}
}
return (Gi_240);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
string f0_11()
{
string Ls_12;
Gi_240 = 0;
string Ls_0 = "";
for(int Li_8 = 0; Li_8 < OrdersTotal(); Li_8++)
{
if(OrderSelect(Li_8, SELECT_BY_POS, MODE_TRADES))
{
Ls_12 = OrderComment();
if(OrderSymbol() == Symbol() && OrderType() == OP_BUY && StringSubstr(Ls_12, 0, StringFind(Ls_12, "-", 0)) == Gs_buy_224 && OrderMagicNumber() == Magic)
{
if(OrderTicket() > Gi_240)
{
Gi_240 = OrderTicket();
Ls_0 = OrderComment();
}
}
}
}
return (Ls_0);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
int f0_19()
{
string Ls_4;
Gi_244 = 0;
for(int Li_0 = 0; Li_0 < OrdersTotal(); Li_0++)
{
if(OrderSelect(Li_0, SELECT_BY_POS, MODE_TRADES))
{
Ls_4 = OrderComment();
if(OrderSymbol() == Symbol() && OrderType() == OP_SELL && StringSubstr(Ls_4, 0, StringFind(Ls_4, "-", 0)) == Gs_sell_232 && OrderMagicNumber() == Magic)
if(OrderTicket() > Gi_244)
Gi_244 = OrderTicket();
}
}
return (Gi_244);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
string f0_16()
{
string Ls_12;
Gi_244 = 0;
string Ls_0 = "";
for(int Li_8 = 0; Li_8 < OrdersTotal(); Li_8++)
{
if(OrderSelect(Li_8, SELECT_BY_POS, MODE_TRADES))
{
Ls_12 = OrderComment();
if(OrderSymbol() == Symbol() && OrderType() == OP_SELL && StringSubstr(Ls_12, 0, StringFind(Ls_12, "-", 0)) == Gs_sell_232 && OrderMagicNumber() == Magic)
{
if(OrderTicket() > Gi_244)
{
Gi_244 = OrderTicket();
Ls_0 = OrderComment();
}
}
}
}
return (Ls_0);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
int f0_18(string As_0,double Ad_0)
{
string StringAryLots_1[];
StringSplit(建仓手数_可增减,StringGetCharacter("/",0),StringAryLots_1); //","是分隔符。过指定分隔符,获得字符串数组,返回子字符串数量。
double AryLots_1[];
ArrayResize(AryLots_1,ArraySize(StringAryLots_1)+100);
ArrayInitialize(AryLots_1,0); //初始化非字符串数组
for(int i=0; i<ArraySize(StringAryLots_1)+100; i++)
{
if(i<ArraySize(StringAryLots_1))
{
if(ArraySize(StringAryLots_1)==0||StringAryLots_1=="")
{
break;
}
AryLots_1=StringToDouble(StringAryLots_1);
}
if(i>=ArraySize(StringAryLots_1))
{
AryLots_1=AryLots_1;
}
//if(后续递增N手_0为关闭!=0&&i>=ArraySize(StringAryLots_1)) {AryLots_1=AryLots_1+后续递增N手_0为关闭;}
}
//简单统计
int AllVol_1=0,BuyVol_1=0,SelVol_1=0;
double AllLots_1=0,BuyLots_1=0,SelLots_1=0;
if(OrdersTotal()>=0)
{
for(int j=OrdersTotal()-1; j>=0; j--)
{
if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES)==true)
{
if(OrderSymbol()==Symbol()&&(OrderMagicNumber()==Magic||Magic==1))
{
if(OrderType()==0||OrderType()==1)
{
AllVol_1++;
AllLots_1+=OrderLots();
}
if(OrderType()==0)
{
BuyVol_1++;
BuyLots_1+=OrderLots();
}
if(OrderType()==1)
{
SelVol_1++;
SelLots_1+=OrderLots();
}
}
}
}
}
bool Li_8 = FALSE;
if(Duo)
{
Li_8 = AryLots_1;
f0_8(1 * XiShu*Ad_0);
Print("满足开多" + As_0 + "条件。ID=" + Li_8);
}
return (Li_8);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
int f0_23(string As_0,double Ad_0)
{
string StringAryLots_1[];
StringSplit(建仓手数_可增减,StringGetCharacter("/",0),StringAryLots_1); //","是分隔符。过指定分隔符,获得字符串数组,返回子字符串数量。
double AryLots_1[];
ArrayResize(AryLots_1,ArraySize(StringAryLots_1)+100);
ArrayInitialize(AryLots_1,0); //初始化非字符串数组
for(int i=0; i<ArraySize(StringAryLots_1)+100; i++)
{
if(i<ArraySize(StringAryLots_1))
{
if(ArraySize(StringAryLots_1)==0||StringAryLots_1=="")
{
break;
}
AryLots_1=StringToDouble(StringAryLots_1);
}
if(i>=ArraySize(StringAryLots_1))
{
AryLots_1=AryLots_1;
}
//if(后续递增N手_0为关闭!=0&&i>=ArraySize(StringAryLots_1)) {AryLots_1=AryLots_1+后续递增N手_0为关闭;}
}
//简单统计
int AllVol_1=0,BuyVol_1=0,SelVol_1=0;
double AllLots_1=0,BuyLots_1=0,SelLots_1=0;
if(OrdersTotal()>=0)
{
for(int j=OrdersTotal()-1; j>=0; j--)
{
if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES)==true)
{
if(OrderSymbol()==Symbol()&&(OrderMagicNumber()==Magic||Magic==1))
{
if(OrderType()==0||OrderType()==1)
{
AllVol_1++;
AllLots_1+=OrderLots();
}
if(OrderType()==0)
{
BuyVol_1++;
BuyLots_1+=OrderLots();
}
if(OrderType()==1)
{
SelVol_1++;
SelLots_1+=OrderLots();
}
}
}
}
}
bool Li_8 = FALSE;
if(Kong)
{
Li_8 = AryLots_1;
f0_29(1 * XiShu*Ad_0);
Print("满足开空" + As_0 + "条件。ID=" + Li_8);
}
return (Li_8);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int f0_8(double Ad_0)
{
return (f0_1(Ad_0, 0, 0, Gs_buy_224, Magic));
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int f0_29(double Ad_0)
{
return (f0_17(Ad_0, 0, 0, Gs_sell_232, Magic));
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int f0_1(double Ad_0, double Ad_8, double Ad_16, string As_24, int Ai_32)
{
string StringAryLots_1[];
StringSplit(建仓手数_可增减,StringGetCharacter("/",0),StringAryLots_1); //","是分隔符。过指定分隔符,获得字符串数组,返回子字符串数量。
double AryLots_1[];
ArrayResize(AryLots_1,ArraySize(StringAryLots_1)+100);
ArrayInitialize(AryLots_1,0); //初始化非字符串数组
for(int i=0; i<ArraySize(StringAryLots_1)+100; i++)
{
if(i<ArraySize(StringAryLots_1))
{
if(ArraySize(StringAryLots_1)==0||StringAryLots_1=="")
{
break;
}
AryLots_1=StringToDouble(StringAryLots_1);
}
if(i>=ArraySize(StringAryLots_1))
{
AryLots_1=AryLots_1;
}
//if(后续递增N手_0为关闭!=0&&i>=ArraySize(StringAryLots_1)) {AryLots_1=AryLots_1+后续递增N手_0为关闭;}
}
//简单统计
int AllVol_1=0,BuyVol_1=0,SelVol_1=0;
double AllLots_1=0,BuyLots_1=0,SelLots_1=0;
if(OrdersTotal()>=0)
{
for(int j=OrdersTotal()-1; j>=0; j--)
{
if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES)==true)
{
if(OrderSymbol()==Symbol()&&(OrderMagicNumber()==Magic||Magic==1))
{
if(OrderType()==0||OrderType()==1)
{
AllVol_1++;
AllLots_1+=OrderLots();
}
if(OrderType()==0)
{
BuyVol_1++;
BuyLots_1+=OrderLots();
}
if(OrderType()==1)
{
SelVol_1++;
SelLots_1+=OrderLots();
}
}
}
}
}
RefreshRates();
int Li_36 = OrderSend(Symbol(), OP_BUY, MathCeil((AryLots_1-0.000001)/minlot)*minlot, Ask, Slippage, 0, 0, As_24 + "-" + ((f0_4() + 1)), Magic, 0, White);//开多单
if(Li_36 > 0)
return (Li_36);
return (0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int f0_17(double Ad_0, double Ad_8, double Ad_16, string As_24, int Ai_32)
{
string StringAryLots_1[];
StringSplit(建仓手数_可增减,StringGetCharacter("/",0),StringAryLots_1); //","是分隔符。过指定分隔符,获得字符串数组,返回子字符串数量。
double AryLots_1[];
ArrayResize(AryLots_1,ArraySize(StringAryLots_1)+100);
ArrayInitialize(AryLots_1,0); //初始化非字符串数组
for(int i=0; i<ArraySize(StringAryLots_1)+100; i++)
{
if(i<ArraySize(StringAryLots_1))
{
if(ArraySize(StringAryLots_1)==0||StringAryLots_1=="")
{
break;
}
AryLots_1=StringToDouble(StringAryLots_1);
}
if(i>=ArraySize(StringAryLots_1))
{
AryLots_1=AryLots_1;
}
//if(后续递增N手_0为关闭!=0&&i>=ArraySize(StringAryLots_1)) {AryLots_1=AryLots_1+后续递增N手_0为关闭;}
}
//简单统计
int AllVol_1=0,BuyVol_1=0,SelVol_1=0;
double AllLots_1=0,BuyLots_1=0,SelLots_1=0;
if(OrdersTotal()>=0)
{
for(int j=OrdersTotal()-1; j>=0; j--)
{
if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES)==true)
{
if(OrderSymbol()==Symbol()&&(OrderMagicNumber()==Magic||Magic==1))
{
if(OrderType()==0||OrderType()==1)
{
AllVol_1++;
AllLots_1+=OrderLots();
}
if(OrderType()==0)
{
BuyVol_1++;
BuyLots_1+=OrderLots();
}
if(OrderType()==1)
{
SelVol_1++;
SelLots_1+=OrderLots();
}
}
}
}
}
RefreshRates();
int Li_36 = OrderSend(Symbol(), OP_SELL, MathCeil((AryLots_1-0.000001)/minlot)*minlot, Bid, Slippage, 0, 0, As_24 + "-" + ((f0_13() + 1)), Magic, 0, Red);//开空单
if(Li_36 > 0)
return (Li_36);
return (0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int f0_24(int Ai_0)
{
string Ls_4;
RefreshRates();
if(OrderSelect(Ai_0, SELECT_BY_TICKET))
{
Ls_4 = OrderComment();
if(StringSubstr(Ls_4, 0, StringFind(Ls_4, "-", 0)) == Gs_buy_224 && OrderMagicNumber() == Magic)
return ((Ask - OrderOpenPrice()) / MarketInfo(Symbol(), MODE_POINT));
if(StringSubstr(Ls_4, 0, StringFind(Ls_4, "-", 0)) == Gs_sell_232 && OrderMagicNumber() == Magic)
return ((OrderOpenPrice() - Bid) / MarketInfo(Symbol(), MODE_POINT));
}
return (0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int f0_4()
{
int Li_0 = 0;
string Ls_4 = "";
for(int Li_12 = 0; Li_12 < OrdersTotal(); Li_12++)
{
if(OrderSelect(Li_12, SELECT_BY_POS, MODE_TRADES))
{
Ls_4 = OrderComment();
if(Gs_buy_224 == StringSubstr(Ls_4, 0, StringFind(Ls_4, "-", 0)))
if(OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == Magic)
Li_0++;
}
}
return (Li_0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int f0_13()
{
int Li_0 = 0;
string Ls_4 = "";
for(int Li_12 = 0; Li_12 < OrdersTotal(); Li_12++)
{
if(OrderSelect(Li_12, SELECT_BY_POS, MODE_TRADES))
{
Ls_4 = OrderComment();
if(Gs_sell_232 == StringSubstr(Ls_4, 0, StringFind(Ls_4, "-", 0)))
if(OrderSymbol() == Symbol() && OrderType() == OP_SELL && OrderMagicNumber() == Magic)
Li_0++;
}
}
return (Li_0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double f0_25()
{
double Ld_0 = 0;
for(int Li_8 = 0; Li_8 < OrdersHistoryTotal(); Li_8++)
{
if(OrderSelect(Li_8, SELECT_BY_POS, MODE_HISTORY))
{
if(OrderSymbol() == Symbol() && OrderType() == OP_SELL && OrderMagicNumber() == Magic)
Ld_0 += OrderProfit();
else
if(OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == Magic)
Ld_0 += OrderProfit();
}
if(Li_8 > 5000)
return (Ld_0);
}
return (Ld_0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void f0_27(double Ad_0, string As_8, double Ad_16, int Ai_24)
{
int Li_28 = FileOpen("Logs.csv", FILE_CSV|FILE_WRITE|FILE_READ, ',');
if(Li_28 > 0)
{
FileSeek(Li_28, 0, SEEK_END);
FileWrite(Li_28, f0_22(), Ad_0, As_8, Ad_16, Ai_24);
}
FileClose(Li_28);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
string f0_22()
{
string Ls_0 = TimeYear(TimeCurrent()) + "-" + TimeMonth(TimeCurrent()) + "-" + TimeDay(TimeCurrent()) + " " + TimeHour(TimeCurrent()) + ":" + TimeMinute(TimeCurrent()) + ":" + TimeSeconds(TimeCurrent());
return (Ls_0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double f0_21(double Ad_0)
{
return (NormalizeDouble(Ad_0, Digits));
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
void f0_26(string As_0, string As_8, int Ai_16, int Ai_20, int Ai_24, string As_28, color Ai_36, int Ai_40)
{
ObjectCreate(As_0, OBJ_LABEL, 0, 0, 0);
ObjectSetText(As_0, As_8, Ai_24, As_28, Ai_36);
ObjectSet(As_0, OBJPROP_CORNER, Ai_40);
ObjectSet(As_0, OBJPROP_XDISTANCE, Ai_16);
ObjectSet(As_0, OBJPROP_YDISTANCE, Ai_20);
}
//+------------------------------------------------------------------+
//| 版权所有 禁止盗用 |
//+------------------------------------------------------------------+
int f0_0()
{
int Li_0 = (Ask - Bid) / MarketInfo(Symbol(), MODE_POINT);
return (Li_0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CreateButton(string Name,string GeneralText,string UnGeneralText,int XDistance,int YDistance,int XSize,int YSize,int FontSize,int Corner,int Anchor,color ColorA,color ColorB,color BorderColor)
{
if(ObjectFind(0,Name)==-1) //判断是否存在X按钮
{
ObjectCreate(0,Name,OBJ_BUTTON,0,0,0); //新建
ObjectSetInteger(0,Name,OBJPROP_XDISTANCE,XDistance);//X轴位置
ObjectSetInteger(0,Name,OBJPROP_YDISTANCE,YDistance);//Y轴位置
ObjectSetInteger(0,Name,OBJPROP_XSIZE,XSize);//X轴长度
ObjectSetInteger(0,Name,OBJPROP_YSIZE,YSize);//Y轴长度
ObjectSetString(0,Name,OBJPROP_FONT,"微软雅黑"); //字体
ObjectSetInteger(0,Name,OBJPROP_FONTSIZE,FontSize);//文字大小
ObjectSetInteger(0,Name,OBJPROP_CORNER,Corner);//放哪个角落 0123为左右上下
//ObjectSetInteger(0,Name,OBJPROP_BORDER_COLOR,BorderColor); //边框颜色
ObjectSetInteger(0,Name,OBJPROP_SELECTABLE,0); //0不可选取,1可被选取
//ObjectSetInteger(0,Name,OBJPROP_BACK,true);//是否设为背景 true为背景
ObjectSetInteger(0,Name,OBJPROP_ANCHOR,Anchor); //向左对齐、向右对齐 //ANCHOR_LEFT_UPPER (向左上角对齐) ANCHOR_RIGHT(向右对齐)
}
if(ObjectGetInteger(0,Name,OBJPROP_STATE)==false) //0false为常规状态,1true为按下状态
{
ObjectSetString(0,Name,OBJPROP_TEXT,GeneralText);//文字内容
ObjectSetInteger(0,Name,OBJPROP_COLOR,ColorA); //文字颜色
ObjectSetInteger(0,Name,OBJPROP_BGCOLOR,ColorB);//背景颜色
}
else
{
ObjectSetString(0,Name,OBJPROP_TEXT,UnGeneralText);//文字内容
ObjectSetInteger(0,Name,OBJPROP_COLOR,ColorB);//文字颜色
ObjectSetInteger(0,Name,OBJPROP_BGCOLOR,ColorA);//背景颜色
}
//if(ObjectGetInteger(0,"CloseAll",OBJPROP_STATE)==true){} //获取按钮状态
//ObjectSetInteger(0,"CloseAll",OBJPROP_STATE,false); //恢复未按下状态
//例如:CreateButton("CloseAllYCEA","全部平仓?","在全平中",10,40,90,25,13,2,ANCHOR_LEFT,clrWhite,clrBrown,clrGold);
}
DOMINO789
发表于 2024-11-14 21:54:55
定方向,是顺势的方向还是反方向
等风来2025
发表于 2024-11-21 23:41:06
定方向,是顺势的方向还是反方向
页:
1
2
3
4
5
6
7
8
[9]
10