编码帮助 - 页 629

 
traderduke:

mladen & mrtools

我有一个EA,它的交易是自爆的。我需要帮助建立一个可以添加到现有EA中的Void或功能。这个函数需要解决。

输入 bool doBasketExit = true; // 检查篮子退出条件
Input double BasketTP = 250.0; // Basket Take Profit (Account Currency) The chart Pair
输入 double BasketSL = -100.0; // Basket Stop Loss (Account Currency) 图表对

我在H1上用激进的EA运行9个货币对/图表,我想在9个图表中的每一个上进行特定货币对的篮子交易。
以下是我刚刚发生的情况。9个图表正在运行,3个图表正在交易,当然是3个独立的货币对,每个都有15笔交易,是的,有45笔交易,2个在盈利,1个严重亏损。我在寻找一种方法,将15个交易的每组/对分别加起来,并将每组交易与一个篮子的SL和TP边界进行对比。我找到了一个篮子的设置,但当然需要完善。诀窍是让同一对交易从订单盈利交易栏中加起来。通过在一个有特定货币对的图表上,我想我找到了一个无效的方法,但它有点复杂。该函数必须以某种方式按交易对读取OrderProfit?

请看我的代码作为一个可怜的例子。

void closeTrades( CURRENCY* &currencies[] ) {
// 检查一揽子退出
if ( doBasketExit ) {
double basketProfit = getBasketProfit();
如果( ( ( BasketTP > 0.0 ) && ( basketProfit > BasketTP ) )||
( ( BasketSL < 0.0 ) && ( basketProfit < BasketSL ) ) ){
closeAll();
}
}
double getBasketProfit() {
double basketProfit = 0.0;
for (int iOrder=OrdersTotal()-1; iOrder >= 0; iOrder--){
如果(OrderSelect(iOrder,SELECT_BY_POS,M ODE_TRADES)) {
如果 ( OrderMagicNumber() == MagicNumber ) {
如果 ( (OrderType() == OP_BUY)|| (OrderType() == OP_SELL) ){
basketProfit += OrderProfit() + OrderSwap() + OrderCommission()。
}
}
}
}
return(basketProfit);
}

void closeAll() {
double closePrice;
字符串 symbolName;
int result;
for (int iOrder=OrdersTotal()-1; iOrder >= 0; iOrder--){
如果(OrderSelect(iOrder,SELECT_BY_POS,M ODE_TRADES)) {
如果 ( OrderMagicNumber() == MagicNumber ) {
如果 ( (OrderType() == OP_BUY)|| (OrderType() == OP_SELL) ){
symbolName = OrderSymbol();
closePrice = ( OrderType() == OP_BUY ) ?MarketInfo( symbolName, MODE_BID ) : MarketInfo( symbolName, MODE_ASK ) 。
结果 = OrderCloseReliable(OrderTicket(), OrderLots(), closePrice, 50)。
}
}



真的很感谢你对这个问题的关注

谢谢


你需要某种 "母EA"--它知道其他EA处理的所有神奇数字,然后做你需要做的 "分组 "操作。

 
MLADEN先生,请检查 您的收件箱,先生。
 
mladen:

试着做以下事情。

而不是

谢谢Mladen,我对代码做了一些调整,现在可以工作了。
 
mladen:


你需要某种 "母EA"--它知道所有由其他EA处理的神奇数字,然后进行你需要的 "分组 "操作。

mladen

谢谢你对这件事的看法。所以,不。

再次感谢



 

我试着让箭头在信号蜡烛收盘后出现,以避免重绘,但都无济于事,请帮助我。TOOLS和MLADEN,以下是代码。

//+------------------------------------------------------------------+
//|                                              signalindicator.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property  indicator_color1 Blue
#property  indicator_color2 Yellow
#property  indicator_color3 Aqua
#property  indicator_color4 Red

extern int FastEMA = 5;
extern int SlowEMA = 6;
extern int RSIPeriod = 7;
extern bool Alerts = TRUE;
double buffer_1[];
double buffer_2[];
double arrow_1[];
double arrow_2[];
int a = 0;
int b = 0;
double x = 0.0;
double y = 0.0;

int init() {
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, buffer_1);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, buffer_2);
   SetIndexStyle(2, DRAW_ARROW, 0,4);
   SetIndexArrow(2, 217);
   SetIndexBuffer(2, arrow_1);
   SetIndexEmptyValue(2, 0.0);
   SetIndexStyle(3, DRAW_ARROW, 0,4);
   SetIndexArrow(3, 218);
   SetIndexBuffer(3, arrow_2);
   SetIndexEmptyValue(3, 0.0);
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   int counted_bars = IndicatorCounted();
   double irsi_1 = 0;
   bool c = FALSE;
   double price_10 = 0;
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars--;
   int li_0 = Bars - counted_bars;
   for (int i = 0; i < li_0; i++) {
      buffer_1[i] = iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      buffer_2[i] = iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      irsi_1 = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i);
      x = buffer_1[i] - buffer_2[i];
      if (x > 0.0 && irsi_1 > 50.0) a = 1;
      else
         if (x < 0.0 && irsi_1 < 50.0) a = 2;
      if (a == 1 && b == 2) {
         arrow_2[i - 1] = High[i - 1] - 5.0 * Point;
         c= TRUE;
         price_10 = Ask;
      } else {
         if (a == 2 && b == 1) {
            arrow_1[i - 1] = Low[i - 1] - 5.0 * Point;
            c = TRUE;
            price_10 = Bid;
         }
      }
      b = a;
      y = x;
   }
   if (Alerts && c) {
      PlaySound("alert.wav");
      if (b == 2) Alert(Symbol(),"  M",Period(),"Buy at " + price_10 + "!!", "Entry Point", 0);
      else
         if (b == 1) Alert(Symbol(),"  M",Period(),"Sell at " + price_10 + "!!", "Entry Point", 0);
      c= FALSE;
   }
   return (0);
}
 

嗨,mladen

我需要ITM X-Gen Daily Scalper Indicator.mq4。

请帮助我

谢谢

附加的文件:
 
alozard:

嗨,mladen

我需要ITM X-Gen Daily Scalper Indicator.mq4。

请帮助我

谢谢

尊敬的各位领导

该指标是一个重新命名的我的中心TMA波段指标。你可以在这里找到它:https://www.mql5.com/en/forum/181241

 
mladen先生,请帮助我提供上述代码的版本。
 

Mladen先生,请看下面的代码,在我切换时间框架之前,箭头不会出现在实时状态。


//+------------------------------------------------------------------+
//|                                              signalindicator.mq4 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property  indicator_color1 Blue
#property  indicator_color2 Yellow
#property  indicator_color3 Aqua
#property  indicator_color4 Red

#property  indicator_color4 Red

extern int FastEMA = 5;
extern int SlowEMA = 6;
extern int RSIPeriod = 7;
extern bool Alerts = TRUE;
double buffer_1[];
double buffer_2[];
double arrow_1[];
double arrow_2[];
int a = 0;
int b = 0;
double x = 0.0;
double y = 0.0;
 double alertshow;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0, DRAW_NONE);
   SetIndexBuffer(0, buffer_1);
   SetIndexStyle(1, DRAW_NONE);
   SetIndexBuffer(1, buffer_2);
   SetIndexStyle(2, DRAW_ARROW, 0,4);
   SetIndexArrow(2, 241);
   SetIndexBuffer(2, arrow_1);
   SetIndexEmptyValue(2, 0.0);
   SetIndexStyle(3, DRAW_ARROW, 0,4);
   SetIndexArrow(3, 242);
   SetIndexBuffer(3, arrow_2);
   SetIndexEmptyValue(3, 0.0);

   return (0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return (0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   int counted_bars = IndicatorCounted();
   double irsi_1 = 0;
   int li_0;
   bool c = FALSE;
   double price_10 = 0;
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars--;
   if(counted_bars==0)
      li_0=MathMin(Bars-10-1,Bars-MathMax(FastEMA,SlowEMA)-1);
   else
      li_0=Bars-counted_bars;
   for (int i = 0; i < li_0; i++) {
      buffer_1[i] = iMA(NULL, 0, FastEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      buffer_2[i] = iMA(NULL, 0, SlowEMA, 0, MODE_EMA, PRICE_CLOSE, i);
      irsi_1 = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i);
      x = buffer_1[i] - buffer_2[i];
      if (x > 0.0 && irsi_1 > 50.0) a = 1;
      else
         if (x < 0.0 && irsi_1 < 50.0) a = 2;
      if (a == 1 && b == 2) {
         arrow_2[i - 1] = High[i - 1] - 5.0 * Point;
         c= TRUE;
         price_10 = Ask;
      } else {
         if (a == 2 && b == 1) {
            arrow_1[i - 1] = Low[i - 1] - 5.0 * Point;
            c = TRUE;
            price_10 = Bid;
         }
      }
      b = a;
      y = x;
   }
   if (Alerts && c) {
      PlaySound("alert.wav");
      if (b == 2)  
      
         if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol()," buy signal");
            alertshow=Time[1];
           }
      else
         if (b == 1) if(alertshow<Time[1] && counted_bars!=0)
           {
            PlaySound("news.wav");// buy wav
            Alert(Symbol(),"  sell signal");
            alertshow=Time[1];
           }
   }
//----
   return(prev_calculated);
  }
//+------------------------------------------------------------------+
 
kapoo:

Mladen先生,请看下面的代码,在我切换时间框架之前,箭头不会出现在实时画面上。


卡普

我已经告诉过你很多次了:该指标是一个坏的修复器,这就是为什么它做的事情。我最好的建议是,你忘掉它吧