[警告关闭!]任何新手问题,为了不给论坛添乱。专业人士,不要走过。没有你,哪里都不能去。 - 页 999

 
你好,你能告诉我在EA的代码中插入什么来优化EMA周期吗?
 
gawrik:
你好,你能告诉我在EA的代码中插入什么来优化EMA周期吗?
什么是EMA期?
 
移动平均线 exp.期间。我可以把它扔在这里,有人可以调整它吗?
 



#财产版权"hasgkhlhjgg"
#属性链接 "http://www.efefrWRF.com"

#define MIN_STOPLOSS_POINT 10
#define MIN_TAKEPROFIT_POINT 10
#define MAGIC 316995

外部字符串sNameExpert = "DGJJFYGJD"。
外部int nAccount =0;
外部双倍的dBuyStopLossPoint = 0;
外来的双倍dSellStopLossPoint = 0;
外来的双数dBuyTakeProfitPoint = 0;
外来的双倍dSellTakeProfitPoint = 0;
外来的双数dBuyTrailingStopPoint = 0;
外来的双倍dSellTrailingStopPoint = 0;
外部双倍dLots = 0.03。
外部int nSlippage = 4;
外部 bool lFlagUseHourTrade = False;
外部inttern nFromHourTrade = 0;
外置 intNToHourTrade = 23;
外部 bool lFlagUseSound = True;
外部字符串sSoundFileName = "alert.wav"。
外部颜色 colorOpenBuy = Blue;
外部的colorCloseBuy = Aqua;
外部颜色OpenSell = 红色。
extern colorCloseSell = Aqua;


void deinit() {
评论(")。
}

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start(){
如果(lFlagUseHourTrade){
如果(!(Hour()>=nFromHourTrade && Hour()<=nToHourTrade)){
评论("贸易的时间还没有到来!")。
return(0);
}
}

如果(Bars < 100){
Print("小于100的条形图")。
return(0);
}

如果(nAccount > 0 && nAccount != AccountNumber()){
评论("账户交易:"+账户号码()+"禁止!")。
return(0);
}

如果((dBuyStopLossPoint > 0 && dBuyStopLossPoint < MIN_STOPLOSS_POINT) ||
(dSellStopLossPoint > 0 && dSellStopLossPoint < MIN_STOPLOSS_POINT)){
Print("StopLoss 小于" + MIN_STOPLOSS_POINT)。
return(0);
}
如果((dBuyTakeProfitPoint > 0 && dBuyTakeProfitPoint < MIN_TAKEPROFIT_POINT) ||
(dSellTakeProfitPoint > 0 && dSellTakeProfitPoint < MIN_TAKEPROFIT_POINT)){
Print("TakeProfit小于" + MIN_TAKEPROFIT_POINT)。
return(0);
}

double diMA0=iMA(NULL,1,15,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA1=iMA(NULL,1,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA2=iMA(NULL,1,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA3=iMA(NULL,1,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA4=iMA(NULL,1,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA5=iMA(NULL,1,100,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA6=iMA(NULL,5,15,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA7=iMA(NULL,5,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA8=iMA(NULL,5,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA9=iMA(NULL,5,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA10=iMA(NULL,5,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA11=iMA(NULL,5,100,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA12=iMA(NULL,15,15,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA13=iMA(NULL,15,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA14=iMA(NULL,15,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA15=iMA(NULL,15,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA16=iMA(NULL,15,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA17=iMA(NULL,15,100,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA18=iMA(NULL,30,15,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA19=iMA(NULL,30,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA20=iMA(NULL,30,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA21=iMA(NULL,30,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA22=iMA(NULL,30,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA23=iMA(NULL,30,100,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA24=iMA(NULL,60,15,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA25=iMA(NULL,60,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA26=iMA(NULL,60,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA27=iMA(NULL,60,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA28=iMA(NULL,60,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA29=iMA(NULL,60,100,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA30=iMA(NULL,60,15,0,MODE_EMA,PRICE_CLOSE,0);
double diMA31=iMA(NULL,60,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA32=iMA(NULL,1,15,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA33=iMA(NULL,1,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA34=iMA(NULL,1,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA35=iMA(NULL,1,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA36=iMA(NULL,1,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA37=iMA(NULL,1,100,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA38=iMA(NULL,5,15,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA39=iMA(NULL,5,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA40=iMA(NULL,5,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA41=iMA(NULL,5,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA42=iMA(NULL,5,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA43=iMA(NULL,5,100,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA44=iMA(NULL,15,15,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA45=iMA(NULL,15,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA46=iMA(NULL,15,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA47=iMA(NULL,15,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA48=iMA(NULL,15,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA49=iMA(NULL,15,100,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA50=iMA(NULL,30,15,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA51=iMA(NULL,30,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA52=iMA(NULL,30,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA53=iMA(NULL,30,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA54=iMA(NULL,30,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA55=iMA(NULL,30,100,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA56=iMA(NULL,60,15,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA57=iMA(NULL,60,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA58=iMA(NULL,60,29,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA59=iMA(NULL,60,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA60=iMA(NULL,60,50,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA61=iMA(NULL,60,100,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA62=iMA(NULL,60,15,0,MODE_EMA,PRICE_CLOSE,0)。
double diMA63=iMA(NULL,60,29,0,MODE_EMA,PRICE_CLOSE,0)。


如果(AccountFreeMargin() < (1000*dLots)){
Print("我们没有钱。Free Margin = " + AccountFreeMargin())。
return(0);
}

bool lFlagBuyOpen = false, lFlagSellOpen = false, lFlagBuyClose = false, lFlagSellClose = false;

lFlagBuyOpen = (diMA0>diMA1 && diMA2>diMA3 && diMA4>diMA5 && diMA6>diMA7 && diMA8>diMA9 && diMA10>diMA11 && diMA12>diMA13 && diMA14>)diMA15 && diMA16>diMA17 && diMA18>diMA19 && diMA20>diMA21 && diMA22>diMA23 && diMA24>diMA25 && diMA26>diMA27 && diMA28>diMA29)。
lFlagSellOpen = (diMA32<diMA33 && diMA34<diMA35 && diMA36<diMA37 && diMA38<diMA39 && diMA40<diMA41 && diMA42<diMA43 && diMA44<diMA45 && diMA46<diMA47 && diMA46<diMA47; anddiMA46<diMA47 && diMA48<diMA49 && diMA50<diMA51 && diMA52<diMA53 && diMA54<diMA55 && diMA56<diMA57 && diMA58<diMA59 && diMA60<diMA61)。
lFlagBuyClose = (diMA30<diMA31)。
lFlagSellClose = (diMA62>diMA63)。

如果(!ExistPositions()){

如果(lFlagBuyOpen){
OpenBuy()。
{ return(0);
}

如果(lFlagSellOpen){
OpenSell()。
return(0);
}
}
如果(ExistPositions()){
如果(OrderType()==OP_BUY){
如果(lFlagBuyClose){
bool flagCloseBuy = OrderClose(OrderTicket(, OrderLots(), Bid, nSlippage, colorCloseBuy)。
如果(flagCloseBuy && lFlagUseSound)
PlaySound(sSoundFileName)。
return(0);
}
}
如果(OrderType()==OP_SELL){
如果(lFlagSellClose){
bool flagCloseSell = OrderClose(OrderTicket(, OrderLots(), Ask, nSlippage, colorCloseSell)。
如果(flagCloseSell && lFlagUseSound)
PlaySound(sSoundFileName)。
return(0);
}
}
}

如果(dBuyTrailingStopPoint > 0 || dSellTrailingStopPoint > 0){

for (int i=0; i<OrdersTotal(); i++){
如果(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){
bool lMagic = true。
如果(MAGIC > 0 && OrderMagicNumber() != MAGIC)
lMagic = false。

如果(OrderSymbol()==Symbol() && lMagic) {
如果(OrderType()==OP_BUY && dBuyTrailingStopPoint > 0) {
如果(Bid-OrderOpenPrice()>dBuyTrailingStopPoint*Point){
如果(OrderStopLoss()<Bid-dBuyTrailingStopPoint*Point)
修改StopLoss(Bid-dBuyTrailingStopPoint*Point)。
}
}
如果(OrderType()==OP_SELL) {
如果(OrderOpenPrice()-Ask>dSellTrailingStopPoint*Point) {
如果(OrderStopLoss()>Ask+dSellTrailingStopPoint*Point || OrderStopLoss()==0)
ModifyStopLoss(Ask+dSellTrailingStopPoint*Point)。
}
}
}
}
}
}
返回(0)。
}

bool ExistPositions() {
for (int i=0; i<OrdersTotal(); i++){
如果(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){
bool lMagic = true。

如果(MAGIC > 0 && OrderMagicNumber() != MAGIC)
lMagic = false。

如果(OrderSymbol()==Symbol() && lMagic) {
return(True)。
}
}
}
return(false)。
}

无效的修改止损(double ldStopLoss) {
bool lFlagModify = OrderModify(OrderTicket(, OrderOpenPrice(), ldStopLoss, OrderTakeProfit(), 0, CLR_NONE)。
如果(lFlagModify && lFlagUseSound)
PlaySound(sSoundFileName)。
}

空白的OpenBuy() {
双重dStopLoss = 0, dTakeProfit = 0。

如果(dBuyStopLossPoint > 0)
dStopLoss = Bid-dBuyStopLossPoint*Point。

如果(dBuyTakeProfitPoint > 0)
dTakeProfit = Bid + dBuyTakeProfitPoint * Point;

int numorder = OrderSend(Symbol(, OP_BUY, dLots, Ask, nSlippage, dStopLoss, dTakeProfit, sNameExpert, MAGIC, 0, colorOpenBuy);

如果(numorder > -1 && lFlagUseSound)
PlaySound(sSoundFileName)。
}

空白的OpenSell() {
双重dStopLoss = 0, dTakeProfit = 0。

如果(dSellStopLossPoint > 0)
dStopLoss = Ask+ dSellStopLossPoint*Point;

如果(dSellTakeProfitPoint > 0)
dTakeProfit = Ask-dSellTakeProfitPoint*Point。

int numorder = OrderSend(Symbol(,OP_SELL, dLots, Bid, nSlippage, dStopLoss, dTakeProfit, sNameExpert, MAGIC, 0, colorOpenSell);

如果(numorder > -1 && lFlagUseSound)
PlaySound(sSoundFileName)。
}

我只是想在不同的货币对上使用它,但它是为欧元兑美元设计的,所以我不能手动调整它,无论是道德上还是身体上。

 
滑动时的开与关
 
谁能帮帮我?
 

早晨好!

你能告诉我如何从一个函数计算中输出两个计算参数吗?如果我理解正确的话--return()函数只返回其括号中指定的一个参数。

double РасчётТЛвверх(int a, double Цена1 Син)
        {
          double МА23 = iMA(NULL,0,23,0,MODE_EMA,PRICE_CLOSE,a),
                 
                 MМА23[17];
                 
                 MМА23[0]=МА23-603*Point;
                 MМА23[1]=МА23-377*Point;
                 MМА23[2]=МА23-233*Point;
                 MМА23[3]=МА23-144*Point;
                 MМА23[4]=МА23-89*Point;
                 MМА23[5]=МА23-55*Point;
                 MМА23[6]=МА23-34*Point;
                 MМА23[7]=МА23-21*Point;
                 MМА23[8]=МА23;
                 MМА23[9]=МА23+21*Point;
                 MМА23[10]=МА23+34*Point;
                 MМА23[11]=МА23+55*Point;
                 MМА23[12]=МА23+89*Point;
                 MМА23[13]=МА23+144*Point;
                 MМА23[14]=МА23+233*Point;
                 MМА23[15]=МА23+377*Point;
                 MМА23[16]=МА23+603*Point;
  
          for(int i=0;i<=16;i++)
            {
              if(NormalizeDouble(Цена1 Син+8*Point,Digits)<=NormalizeDouble(MМА23[i],Digits))
                {
                  double ТЛвверх=MМА23[i+5];
                  double БезУбMМА23 вверх = MМА23[i+4];
                  break;
                    
                      
                }
            }
         
          
                
         return(ТЛвверх);
        }
//--------------------------------------------------------------------

我只能输出TLvup。而且我还想用BezubMMA23up。但如果我这样写--return(TLup, BezUbMMA23up)或return(TLup; BezUbMMA23up),我就会得到一个错误。该函数被调用为双TL-up=CalculateTL-up(a,Price1Cin)。

如何同时调用TLup和BezUbMMA23up?还是为了计算参数WithoutMMA23up,我应该单独再写一遍给定的代码,并输出return( WithoutMMA23up)?

 
例如,建立一个全局变量 并在那里插入函数的结果。
 
所以你仍然需要从计算中输出两个结果。附件中的代码只输出一个。我怎样才能输出两个?
 
谢谢大家,在这里找到了答案 -https://www.mql5.com/ru/articles/1496
原因: