MT4的请帮忙改成w6的 (文华财经WH6赢顺V6.7)

投资者咨询:MT4的请帮忙改成w6的 (文华财经WH6赢顺V6.7)
来源:文华财经  日期:2019-7-29 15:26
 

/*------------------------------------------------------------------------------------
   Name: xSuperTrend Tape.mq4
   Copyright ?011, Xaphod, http://wwww.xaphod.com
  
   Description: SuperTrend Tape Chart
          
   Change log:
       2014-05-28, Xaphod, v1.600
          - Update for MT4 build 600+
       2011-11-25. Xaphod, v1.00
          - First Release
-------------------------------------------------------------------------------------*/
// Indicator properties
#property copyright "?010, xaphod.com"
#property link      "http://wwww.xaphod.com"

#property strict
#property version    "1.600"
#property description "xSuperTrend-Tape Indicator"
#property description ""
#property description "SuperTrend Formula:"
#property description "  UpperLevel=(High[i]+Low[i])/2+Multiplier*Atr(Period)"
#property description "  LowerLevel=(High[i]+Low[i])/2-Multiplier*Atr(Period)"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 LimeGreen
#property indicator_color2 Red
#property indicator_width1 4
#property indicator_width2 4
#property indicator_maximum 1
#property indicator_minimum 0
//#include <xDebug.mqh>

// Constant definitions
#define INDICATOR_NAME "xSuperTrend"

// Indicator parameters
extern int    SuperTrend_Period=10;      // SuperTrend ATR Period
extern double SuperTrend_Multiplier=1.7; // SuperTrend Multiplier

// Global module varables
double gdaUpBuf[];
double gdaDnBuf[];
double gdaSuperTrend[];


//-----------------------------------------------------------------------------
// function: init()
// Description: Custom indicator initialization function.
//-----------------------------------------------------------------------------
int init() {
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexBuffer(0, gdaUpBuf);
   SetIndexLabel(0, NULL);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(1, gdaDnBuf);
   SetIndexLabel(1, NULL);
   SetIndexStyle(2, DRAW_NONE);
   SetIndexBuffer(2, gdaSuperTrend);
   SetIndexLabel(2, NULL);
   IndicatorShortName(INDICATOR_NAME+"["+(string)SuperTrend_Period+";"+DoubleToStr(SuperTrend_Multiplier,1)+"]");
  return(0);
}


//-----------------------------------------------------------------------------
// function: deinit()
// Description: Custom indicator deinitialization function.
//-----------------------------------------------------------------------------
int deinit() {
   return (0);
}


///-----------------------------------------------------------------------------
// function: start()
// Description: Custom indicator iteration function.
//-----------------------------------------------------------------------------
int start() {
  int iNewBars, iCountedBars, i;
  double dAtr,dUpperLevel, dLowerLevel; 
 
  // Get unprocessed ticks
  iCountedBars=IndicatorCounted();
  if(iCountedBars < 0) return (-1);
  if(iCountedBars>0) iCountedBars--;
  iNewBars=Bars-iCountedBars;
 
  for(i=iNewBars; i>=0; i--) {
    // Bounds check
    if (i>=Bars-1)
      continue;
     
    // Calc SuperTrend
    dAtr = iATR(NULL, 0, SuperTrend_Period, i);
    dUpperLevel=(High[i]+Low[i])/2+SuperTrend_Multiplier*dAtr;
    dLowerLevel=(High[i]+Low[i])/2-SuperTrend_Multiplier*dAtr;
   
    // Set supertrend levels
    if (Close[i]>gdaSuperTrend[i+1] && Close[i+1]<=gdaSuperTrend[i+1]) {
      gdaSuperTrend[i]=dLowerLevel;
    }
    else if (Close[i]<gdaSuperTrend[i+1] && Close[i+1]>=gdaSuperTrend[i+1]) {
      gdaSuperTrend[i]=dUpperLevel;
    }
    else if (gdaSuperTrend[i+1]<dLowerLevel)
        gdaSuperTrend[i]=dLowerLevel;
    else if (gdaSuperTrend[i+1]>dUpperLevel)
        gdaSuperTrend[i]=dUpperLevel;
    else
      gdaSuperTrend[i]=gdaSuperTrend[i+1];
   
    // Draw Histo
    gdaUpBuf[i]=EMPTY_VALUE;
    gdaDnBuf[i]=EMPTY_VALUE;
    if (Close[i]>gdaSuperTrend[i] || (Close[i]==gdaSuperTrend[i] && Close[i+1]>gdaSuperTrend[i+1]))
      gdaUpBuf[i]=1;
    else if (Close[i]<gdaSuperTrend[i] || (Close[i]==gdaSuperTrend[i] && Close[i+1]<gdaSuperTrend[i+1]))
      gdaDnBuf[i]=1;
  }
 
  return(0);
}
//+------------------------------------------------------------------+

 

 

技术人员回复
日期:2019-7-29 15:39
 MT4指标编写用了FOR语句,和麦语言差异巨大,并不能直接改写的

如果您有指标编制思路,您告知我们,我们给您直接编制文华版本