BollTrade

楼主  收藏   举报   帖子创建时间:  2019-05-05 05:15 回复:0 关注量:113
XAUUSDM30.png

  1. //+-----------+
  2. //| TwoPerBar |
  3. //+-----------+
  4. #property copyright "Ron Thompson"
  5. #property link      "http://www.lightpatch.com/forex/"

  6. #property indicator_chart_window
  7. #property indicator_buffers 2
  8. #property indicator_color1 DodgerBlue
  9. #property indicator_color2 Magenta

  10. extern double BDistance    =      14;    // plus how much
  11. extern int    BPeriod      =      15;    // Bollinger period
  12. extern int    Deviation    =       2;    // Bollinger deviation

  13. //---- buffers
  14. double val1[];
  15. double val2[];

  16. //+----------------+
  17. //| Custom DE-init |
  18. //+----------------+
  19. // Called onCE when EA is removed from chart

  20. int deinit()
  21.   {
  22.    int    i;
  23.    string o;

  24.    //remove the old objects
  25.    for(i=0; i<Bars; i++)
  26.      {
  27.       o=DoubleToStr(i,0);
  28.       ObjectDelete("myx"+o);
  29.      }
  30.    Print("DE-Init happened ",CurTime());
  31.    Comment(" ");
  32.   }



  33. //+------------------------------------------------------------------+
  34. //| Custom indicator initialization function                         |
  35. //+------------------------------------------------------------------+
  36. int init()
  37.   {
  38.    IndicatorBuffers(2);
  39.    
  40.    SetIndexStyle(0,DRAW_ARROW);
  41.    SetIndexArrow(0,233);
  42.    SetIndexBuffer(0,val1);
  43.    
  44.    SetIndexStyle(1,DRAW_ARROW);
  45.    SetIndexArrow(1,234);
  46.    SetIndexBuffer(1,val2);
  47.   }
  48.   
  49.   
  50. //+-----+
  51. //| TPB |
  52. //+-----+
  53. int start()
  54.   {   
  55.    
  56.    int i;
  57.    int mybars=2000;

  58.    double bup=iBands(Symbol(),0,BPeriod,Deviation,0,PRICE_OPEN,MODE_UPPER,0);
  59.    double bdn=iBands(Symbol(),0,BPeriod,Deviation,0,PRICE_OPEN,MODE_LOWER,0);

  60.       
  61.    for (i=mybars; i>=0; i--)
  62.      {
  63.       bup=iBands(Symbol(),0,BPeriod,Deviation,0,PRICE_OPEN,MODE_UPPER,i);
  64.       bdn=iBands(Symbol(),0,BPeriod,Deviation,0,PRICE_OPEN,MODE_LOWER,i);

  65.       if( High[i]>=bup+(14*Point) )
  66.         {
  67.          val2[i]=bup+(15*Point);         
  68.          //ObjectDelete ("myx"+DoubleToStr(objtick,0));
  69.          //ObjectCreate ("myx"+DoubleToStr(objtick,0), OBJ_TEXT, 0, Time[i], High[i]+(7*Point));
  70.          //ObjectSetText("myx"+DoubleToStr(objtick,0),"X",15,"Arial",Red);
  71.          //objtick++;
  72.         }
  73.       if( Low[i]<=bdn-(14*Point) )
  74.         {
  75.          val1[i]=bdn-(15*Point);         
  76.          //ObjectDelete ("myx"+DoubleToStr(objtick,0));
  77.          //ObjectCreate ("myx"+DoubleToStr(objtick,0), OBJ_TEXT, 0, Time[i], High[i]+(7*Point));
  78.          //ObjectSetText("myx"+DoubleToStr(objtick,0),"X",15,"Arial",Red);
  79.          //objtick++;
  80.         }

  81.      }//for
  82.    
  83.    //Comment(DoubleToStr(mybars,0)+" bars with usable ="+DoubleToStr(objtick,0)+" and unusable="+DoubleToStr(noobj,0)+" maxTR="+DoubleToStr(maxTR,4));
  84.   
  85.   }//start
  86.   
打赏