MT4
如何计算SAR指标的k线数量
回复:0  浏览:84
  • 楼主admin 圈主
  • 2019-05-05 10:59
C:documents and SettingsHPMy documentsMy Pictures1.jpg<div class="blockcode"><div id="code_GQS"><ol>//+------------------------------------------------------------------+
//|                                                    Parabolic.mq4 |
//|                      Copyright ?2004, metaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, metaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Lime
//---- input parameters
extern double    Step=0.02;
extern double    Maximum=0.2;
//---- buffers
double SarBuffer[];
//----
int    save_lastreverse;
bool   save_dirlong;
double save_start;
double save_last_high;
double save_last_low;
double save_ep;
double save_sar;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
   {
//---- indicators
    SetIndexStyle(0,DRAW_ARROW);
    SetIndexArrow(0,159);
    SetIndexBuffer(0,SarBuffer);
//----
    return(0);
   }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SaveLastReverse(int last,int dir,double start,double low,double high,double ep,double sar)
   {
    save_lastreverse=last;
    save_dirlong=dir;
    save_start=start;
    save_last_low=low;
    save_last_high=high;
    save_ep=ep;
    save_sar=sar;
   }
//+------------------------------------------------------------------+
//| Parabolic Sell And Reverse system                                |
//+------------------------------------------------------------------+
int start()
   {
    static bool first=true;
    bool   dirlong;
    double start,last_high,last_low;
    double ep,sar,price_low,price_high,price;
    int    i,counted_bars=IndicatorCounted();
//----
    if(Bars0)
         {
          save_lastreverse=i;
          price_low=Low[i];
          if(last_low>price_low)   last_low=price_low;
          price_high=High[i];
          if(last_highHigh[i+1] && price_low>Low[i+1]) break;
          if(price_high