如何把Lab3Buffer[i]画出来一条直线

 
//+------------------------------------------------------------------+
//|                                                         第二指标.mq4 |
//|                        Copyright 2022, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   3
//--- plot Lab1
#property indicator_label1  "Lab1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrPaleGreen
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot Lab2
#property indicator_label2  "Lab2"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- plot Lab3
#property indicator_label3  "Lab3"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrRed
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
//--- indicator buffers
double         Lab1Buffer[];
double         Lab2Buffer[];
double         Lab3Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Lab1Buffer);
   SetIndexBuffer(1,Lab2Buffer);
   SetIndexBuffer(2,Lab3Buffer);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration 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 limit = rates_total - prev_calculated;
      if(limit == 0) limit++;
      for(int i = 0; i < limit; i++) {
         Lab1Buffer[i] = iMA(Symbol(), PERIOD_CURRENT, 10, 0, MODE_SMA, PRICE_CLOSE, i);
         Lab2Buffer[i] = iMA(Symbol(), PERIOD_CURRENT, 20, 0, MODE_SMA, PRICE_CLOSE, i);
      }
       for(int i = 0; i < limit; i++) {
         if(Lab1Buffer[i] > Lab2Buffer[i] && Lab1Buffer[i+1]<Lab2Buffer[i+1]) {
            Lab3Buffer[i] =Lab2Buffer[i];
            
         }
         
         else if(Lab1Buffer[i]<Lab2Buffer[i] && Lab1Buffer[i+1]>Lab2Buffer[i+1]) {
             Lab3Buffer[i] = Lab2Buffer[i];
      }
      }
   
   
   
   
   
   
   
   return(rates_total);
  }
Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2022.09.28
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions