//+------------------------------------------------------------------+
#property copyright "2009"
#property link " "
int MagicNumber = 0;
string EAname ="順勢";
int MAGICMA = 2000;
//定義資金管理--------------------------------------------------------+
extern string _資金管理_ ="任選一個";
extern bool zijiguanli1= true;//false true、、
extern bool zijiguanli2= false;//false true、、
extern bool zijiguanli3= false;//false true、、
// 定義各參數--------------------------------------------------------+
extern int FastEMA = 12;
extern int SlowEMA = 26;
extern int SignalSMA = 9;
//定義指標函數--------------------------------------------------------+
//定義止贏止損,滑點---------------------------------------------------+
//定義移動止損-------------------------------------------------------+
//+------------------------------------------------------------------+
//定義下單信息--------------------------------------------------------+
//關於保證金-----------------------------------------------------------+
double BaoZhenJing;
//+------------------------------------------------------------------+
int 判斷=0,buy1=1,buy2=1,buy3=1,buy4=1,sell1=1,sell2=1,sell3=1,sell4=1;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//以後可能有用到
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//以後可能有用到
return(0);
}
//+------------------------------------------------------------------+
//| expert start 主程式
//+------------------------------------------------------------------+
int start()
{
MoneyManagement();//資金管理
ma();//指標管理
zhangchang();//戰場管理
jiancha();//檢查
TrailingStop();//移動止損
xianshi();//顯示管理
return(0);
}
//資金管理-------------------------------------------------------------+
void MoneyManagement() {
lotstart=(AccountBalance()*lotab/10000);
lots=lotstart;
if(cheng==0){cheng=1;}
CurrentBasket=AccountEquity()-AccountBalance();
/////////////////////////////////////////////////////////////////
if(zijiguanli1){ LotMM = lots;}
/////////////////////////////////////////////////////////////////
if(zijiguanli2){
if(CurrentBasket<0 ) {LotMM=NormalizeDouble(lots*(OrdersTotal()*cheng)+lotstart,2); }
if(CurrentBasket==0 ) {LotMM=NormalizeDouble(LotMM*0,2); }
}
/////////////////////////////////////////////////////////////////
if(zijiguanli3){
if(s+b==0){aa=1;}
if(s+b==1){aa=3;}
if(s+b==2){aa=7;}
if(s+b==3){aa=11;}
if(s+b==4){aa=20;}
if(s+b==5){aa=31;}
if(s+b==6){aa=42;}
if(s+b==7){aa=54;}
if(s+b==8){aa=66;}
if(s+b==9){aa=76;}
if(s+b>=10){aa=66;}
if(CurrentBasket<0 ) {LotMM=NormalizeDouble(lotstart*aa,2); }
if(CurrentBasket==0 ) {LotMM=NormalizeDouble(LotMM*0,2); }
}
/////////////////////////////////////////////////////////////////
if(LotMM<LotsMin){LotMM=LotsMin;}
if(LotMM>LotsMax){LotMM=LotsMax;}
}//end 資金管理
//指標管理MA--------------------------------------------------------+
void ma() {
ema120 = iMA(NULL, PERIOD_M5, 120, 0, MODE_EMA, PRICE_CLOSE, 0);
sma20 = iMA(NULL, PERIOD_M5, 20, 0, MODE_SMA, PRICE_CLOSE, 0);
sma21 = iMA(NULL, PERIOD_M5, 20, 0, MODE_SMA, PRICE_CLOSE, 0+1);
ema15 = iMA(NULL, PERIOD_M5, 15, 0, MODE_EMA, PRICE_CLOSE, 0);
ema16 = iMA(NULL, PERIOD_M5, 15, 0, MODE_EMA, PRICE_CLOSE, 0+1);
}
//戰場管理---------------------------------------------------------+
void zhangchang() {
//--- 如果開倉保證金超過上限,則返還不交易。www.emoneybtc.com ------------------
if( AccountMargin() / (AccountMargin() + AccountFreeMargin()) >= 1 ) { return(0); }
BaoZhenJing = MarketInfo( Symbol(), MODE_MARGINREQUIRED); // 一個標准手需保證金金額。
BaoZhenJing = BaoZhenJing * LotMM ; // 下單需用的保證金
if( (AccountMargin()+BaoZhenJing) / (AccountMargin()+AccountFreeMargin()) >= 1 ) { return(0); }
//+-------------------------------------------------------------------+
if(s+b==111){buyme();sellme();CloseSell();CloseBuy();closeall();}
datetime Time0 = 0;
if (Time0 != Time[0]){
Time0 = Time[0];
if(
(b==0 && ema120<sma21 && sma20>ema15 && sma21<ema16){判斷=1;buyme();}
if(
(s==0 && ema120>sma21 && sma20<ema15 && sma21>ema16)){判斷=2;sellme();}
}
if(判斷==2 && b>0){CloseBuy();}
if(判斷==1 && s>0){CloseSell();}
//if(s+b>0 && AccountProfit()>30){closeall();}
if(sma20>ema15 b>0){CloseBuy();}
if(sma20<ema15 && s>0){CloseSell();}
}
//下單後沒成交 撤單--------------------------------------------------------------+
//if (OrderSend==OP_BUY)
//if((OrderOpenPrice-OrderClosePrice)/Point > 100)
//OrderDelete(OrderTicket)};
//if (OrderSend==OP_SELL)
//if((OrderClosePrice-OrderOpenPrice)/Point > 100)
//OrderDelete(OrderTicket)};
//買入開單--------------------------------------------------------------+
void buyme(){
if (TP==0) { TPP=0; } if(TP>0) { TPP=Ask+TP*Point; }
if (SL==0) { SLL=0; } if(SL>0) { SLL=Ask-SL*Point; }
OrderSend(Symbol(),OP_BUY,LotMM,Ask,slip,SLL,TPP,"M"+Period()+"",0,0,Violet);
return(0); }
//賣出開單--------------------------------------------------------------+
void sellme(){
if (TP==0) { TPP=0; } if(TP>0) { TPP=Bid-(TP*Point); }
if (SL==0) { SLL=0; } if(SL>0) { SLL=Bid+(SL*Point); }
OrderSend(Symbol(),OP_SELL,LotMM,Bid,2,SLL,TPP,"M"+Period()+"",0,0,GreenYellow);
return(0); }
//平倉持有的買單-------------------------------------------------------+
void CloseBuy()
{
if (OrdersTotal( ) > 0 )
{
for(i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)
if(OrderType()==OP_BUY)
{
} }}}
//平倉持有的賣單--------------------------------------------------------+
void CloseSell()
{
if (OrdersTotal( ) > 0 )
{
for(i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)
if(OrderType()==OP_SELL)
//平倉所有--------------------------------------------------------+
void closeall()
{
if (OrdersTotal( ) > 0 )
{
for(i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)
if(OrderType()==OP_SELL)
if(OrderType()==OP_BUY)
//移動止損-----------------------------------------------------------+
void TrailingStop()
{
for(cnt=OrdersTotal();cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() )//&& OrderMagicNumber()==MAGICMA)
{
if (OrderType()==OP_SELL)
{
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
if (OrderType()==OP_BUY)
{
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
return(0);
} } } } } }
}
//檢 查--------------------------------------------------------------+
void jiancha()
{
b=0;s=0;
for (int cnt=0; cnt<=OrdersTotal(); cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() )
{
mode=OrderType();LastOrderType=OrderType();
if (OrderType() == OP_SELL){ s++; LastPricesell=OrderOpenPrice();}
if (OrderType() == OP_BUY ){ b++; LastPricebuy=OrderOpenPrice();}
LastPrice=OrderOpenPrice();
if (OrderType()==OP_SELL) {OpenSells++;}
if (OrderType()==OP_SELLSTOP) {OpenSellStops++;}
if (OrderType()==OP_BUY) {OpenBuys++;}
if (OrderType()==OP_BUYSTOP) {OpenBuyStops++;}
}
}
}
//顯示數據-----------------------------------------------------------+
void xianshi()
{
string name_8 = "xianshi1";
ObjectDelete(name_8);
ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name_8, "伺服器時間::"+TimeToStr(CurTime( ))+"", 13, "Arial", White);
ObjectSet(name_8, OBJPROP_CORNER, 0);
ObjectSet(name_8, OBJPROP_XDISTANCE, 15);
ObjectSet(name_8, OBJPROP_YDISTANCE, 15);
name_8 = "Lableyeddrice1";
ObjectDelete(name_8);
ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name_8, "M"+Period()+" 貨幣 "+Symbol()+"", 10, "Arial", Silver);
ObjectSet(name_8, OBJPROP_CORNER, 1);
ObjectSet(name_8, OBJPROP_XDISTANCE, 130);
ObjectSet(name_8, OBJPROP_YDISTANCE, 32);
//////這個顯示上方
name_8 = "LableCurPrice2";
ObjectDelete(name_8);
ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name_8,""+DoubleToStr(Ask, Digits)+"::買上", 15, "Arial", Lime);
ObjectSet(name_8, OBJPROP_CORNER, 1);
ObjectSet(name_8, OBJPROP_XDISTANCE, 15);
ObjectSet(name_8, OBJPROP_YDISTANCE, 30);
//////這個顯示下方
name_8 = "Lab345rPrice3";
ObjectDelete(name_8);
ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name_8,""+DoubleToStr(Bid, Digits)+"::賣下", 15, "Arial", Lime);
ObjectSet(name_8, OBJPROP_CORNER, 1);
ObjectSet(name_8, OBJPROP_XDISTANCE, 15);
ObjectSet(name_8, OBJPROP_YDISTANCE, 50);
name_8 = "Acc87lance";
ObjectDelete(name_8);
ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name_8,""+DoubleToStr( AccountBalance(), 2)+"::賬面資金", 13, "Arial", Lime);
ObjectSet(name_8, OBJPROP_CORNER, 1);
ObjectSet(name_8, OBJPROP_XDISTANCE, 15);
ObjectSet(name_8, OBJPROP_YDISTANCE, 70);
name_8 = "LableC5rice6";
ObjectDelete(name_8);
ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name_8,""+DoubleToStr( AccountEquity(), 2)+"::淨值資金", 13, "Arial", Lime);
ObjectSet(name_8, OBJPROP_CORNER, 1);
ObjectSet(name_8, OBJPROP_XDISTANCE, 15);
ObjectSet(name_8, OBJPROP_YDISTANCE, 90);
name_8 = "Labl456rice6";
ObjectDelete(name_8);
ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name_8,""+DoubleToStr( AccountMargin(), 2)+"::保證資金", 13, "Arial", Lime);
ObjectSet(name_8, OBJPROP_CORNER, 1);
ObjectSet(name_8, OBJPROP_XDISTANCE, 15);
ObjectSet(name_8, OBJPROP_YDISTANCE, 110);
name_8 = "Labl4hcjce6";
ObjectDelete(name_8);
ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name_8,""+DoubleToStr( AccountFreeMargin(), 2)+"::可用資金", 13, "Arial", Lime);
ObjectSet(name_8, OBJPROP_CORNER, 1);
ObjectSet(name_8, OBJPROP_XDISTANCE, 15);
ObjectSet(name_8, OBJPROP_YDISTANCE, 130);
name_8 = "Accvf7lance";
ObjectDelete(name_8);
ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name_8,""+DoubleToStr( AccountProfit(), 2)+"::賬面盈虧", 13, "Arial", Lime);
ObjectSet(name_8, OBJPROP_CORNER, 1);
ObjectSet(name_8, OBJPROP_XDISTANCE, 15);
ObjectSet(name_8, OBJPROP_YDISTANCE, 150);
aa=s+b;
name_8 = "Accvfee7lance";
ObjectDelete(name_8);
ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name_8,""+DoubleToStr( aa, 0)+"::s+b", 13, "Arial", Lime);
ObjectSet(name_8, OBJPROP_CORNER, 1);
ObjectSet(name_8, OBJPROP_XDISTANCE, 15);
ObjectSet(name_8, OBJPROP_YDISTANCE, 170);
name_8 = "Acccvfee7lance";
ObjectDelete(name_8);
ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name_8,""+b+"::buy", 13, "Arial", Lime);
ObjectSet(name_8, OBJPROP_CORNER, 1);
ObjectSet(name_8, OBJPROP_XDISTANCE, 15);
ObjectSet(name_8, OBJPROP_YDISTANCE, 190);
name_8 = "Acccwvfee7lance";
ObjectDelete(name_8);
ObjectCreate(name_8, OBJ_LABEL, 0, 0, 0);
ObjectSetText(name_8,""+s+"::sell", 13, "Arial", Lime);
ObjectSet(name_8, OBJPROP_CORNER, 1);
ObjectSet(name_8, OBJPROP_XDISTANCE, 15);
ObjectSet(name_8, OBJPROP_YDISTANCE, 210);
return(0);
}
境內對數字貨幣日趨嚴格的監管政策使得許多境內公民將目光轉向境外的數字貨幣投資。然而,在《個人信息和重要數據出境安全評估辦法(征求意見稿)》
近日,EDU智能合約出現重大漏洞,任意賬戶中的EDU token可被轉走,這些漏洞造成了來自項目方地址中的30億萬枚EDU Token被偷
前有“互聯網+”,現有“區塊鏈+”,各個行業都在探索區塊鏈應用落地的場景,5月30日,在由e簽寶主辦的2018電子證據與電子簽名研討會上,
北京商報記者 宋媛媛/漫畫 繼幣圈、鏈圈後,一種新型盤圈騙局開始席卷數字貨幣市場。近日,北京商報記者注意到,一種新型“GEC環保幣”交易
日前,總部位於南京的中國雲簽獲得國家知識產權局授予的國內首個區塊鏈智能合同領域的核心發明專利授權。 區塊鏈技術的集成應用在新的技術革新
國家外匯管理局的簡介:國家外匯管理局(State Administration of Foreign Exchange--SAFE) 國家外
外_匯_邦 WaiHuiBang.com 什麼是美元指數:美元指數(US Dollar Index®,即USDX),是綜合反映美元在國際外匯
現在出門購物都很少有人會帶現金了,大家都是用手機支付或者直接刷卡消費。但是隨著人們消費能力越來越高,不少人根本就記不清自己的錢花在
最佳答案: 現在開通抖音小店非常的簡單了,就算個人不需要營業執照也可以輕松入住,開通小店需要經過 很
平安銀行信用卡在消費了兩萬元後,還款時打算分6期還的話,由於平安銀行有規定,人民幣已出賬單分期最高可分期