bigwin 发表于 2024-4-15 14:52:38

订单块-供需策略

订单块策略,不同等级,缓解情况等

#property copyright "tradingvue"
#property link      "http://www.tradingvue.com"
#property description "edited by bigwin"


#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 DodgerBlue
#property indicator_color4 DodgerBlue

static datetime 失效期 = D'2024.08.01 00:00';   //失效日期
extern int 监测距离(K线数)= 46;
extern int 小数点 = 2;

extern string 显示设置:="-----------------1---------------------";
extern bool 显示“已测试”供给和需求?=true;
extern bool 显示“待测试”供给和需求? = true;
extern bool 显示“破坏的”供给和需求? = false;
extern double zone_fuzzfactor=1;

extern string 因子设置:="-----------------2---------------------";
extern bool 是否显示因子=false;
extern double 快因子大小 = 3.0;
extern double 慢因子大小 = 6.0;
extern bool SetGlobals=true;

extern string 图形设置:="-----------------3---------------------";
extern bool zone_solid=true;
extern int zone_linewidth=1;
extern int zone_style=0;
extern bool zone_show_info=true;
extern int zone_label_shift=4;
extern bool zone_merge=true;
extern bool zone_extend=false;

extern string 警报设置:="-----------------4---------------------";
extern bool zone_show_alerts= false;
extern bool zone_alert_popups = true;
extern bool zone_alert_sounds = true;
extern int zone_alert_waitseconds=300;

extern string 字体设置:="-----------------5---------------------";
extern int Text_size=8;
extern string Text_font = "Courier New";
extern color Text_color = White;
extern color Text_color2 = Red;
extern color Text_color3 = Yellow;
extern string sup_name = "需求区";
extern string res_name = "供给区";
extern string test_name= "缓解次数";
extern color color_support_weak   = DarkSlateGray;
extern color color_support_untested = SeaGreen;
extern color color_support_verified = Green;
extern color color_support_proven   = LimeGreen;
extern color color_support_turncoat = OliveDrab;
extern color color_resist_weak      = Indigo;
extern color color_resist_untested= Orchid;
extern color color_resist_verified= Crimson;
extern color color_resist_proven    = Red;
extern color color_resist_turncoat= DarkOrange;

double FastDnPts[],FastUpPts[];
double SlowDnPts[],SlowUpPts[];

double zone_hi,zone_lo;
int    zone_start,zone_hits,zone_type,zone_strength,zone_count=0;
bool   zone_turn;

#define ZONE_SUPPORT 1
#define ZONE_RESIST2

#define ZONE_WEAK      0
#define ZONE_TURNCOAT1
#define ZONE_UNTESTED2
#define ZONE_VERIFIED3
#define ZONE_PROVEN    4

#define UP_POINT 1
#define DN_POINT -1

int time_offset=0;

double ner_lo_zone_P1[];
double ner_lo_zone_P2[];
double ner_hi_zone_P1[];
double ner_hi_zone_P2[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
{
   IndicatorBuffers(4);

   SetIndexBuffer(0,SlowDnPts);
   SetIndexBuffer(1,SlowUpPts);
   SetIndexBuffer(2,FastDnPts);
   SetIndexBuffer(3,FastUpPts);

   if(是否显示因子==true)
   {
      SetIndexStyle(0,DRAW_ARROW,0,3);
      SetIndexStyle(1,DRAW_ARROW,0,3);
      SetIndexStyle(2,DRAW_ARROW,0,1);
      SetIndexStyle(3,DRAW_ARROW,0,1);
      SetIndexArrow(0,218);
      SetIndexArrow(1,217);
      SetIndexArrow(2,218);
      SetIndexArrow(3,217);
   }
   else
   {
      SetIndexStyle(0,DRAW_NONE);
      SetIndexStyle(1,DRAW_NONE);
      SetIndexStyle(2,DRAW_NONE);
      SetIndexStyle(3,DRAW_NONE);
   }

   SetIndexBuffer(4,ner_hi_zone_P1);
   SetIndexBuffer(5,ner_hi_zone_P2);
   SetIndexBuffer(6,ner_lo_zone_P1);
   SetIndexBuffer(7,ner_lo_zone_P2);

   SetIndexStyle(4,DRAW_LINE);
   SetIndexStyle(5,DRAW_LINE);
   SetIndexStyle(6,DRAW_LINE);
   SetIndexStyle(7,DRAW_NONE);

   SetIndexLabel(4,"ner up zone P1");
   SetIndexLabel(5,"ner up zone P2");
   SetIndexLabel(6,"ner dn zone P1");
   SetIndexLabel(7,"ner dn zone P2");

   IndicatorDigits(Digits);

   return(0);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
{
   DeleteZones();
   DeleteGlobalVars();
   return(0);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
{
   if(NewBar()==true && TimeCurrent()<失效期)
   {
      int old_zone_count=zone_count;

      FastFractals();
      SlowFractals();
      DeleteZones();
      FindZones();
      DrawZones();
      if(zone_count<old_zone_count)
         DeleteOldGlobalVars(old_zone_count);
   }

   if(zone_show_info==true)
   {
      for(int i=0; i<zone_count; i++)
      {
         string lbl, lblhi, lbllo;
         if(zone_strength==ZONE_PROVEN)
            lbl="基础";
         else if(zone_strength==ZONE_VERIFIED)
            lbl="已测试";
         else if(zone_strength==ZONE_UNTESTED)
            lbl="未测试";
         else if(zone_strength==ZONE_TURNCOAT)
            lbl="破坏的";
         else
            lbl="未缓解";

         if(zone_type==ZONE_SUPPORT)
         {
            lbl=lbl+" "+sup_name;
            lblhi="多单入场: "+NormalizeDouble( zone_hi,小数点);
            lbllo="多单止损: "+NormalizeDouble( zone_lo,小数点);
         }
         else
         {
            lbl=lbl+" "+res_name;
            lblhi="空单止损:"+NormalizeDouble( zone_hi,小数点);
            lbllo="空单入场:"+NormalizeDouble( zone_lo,小数点);
         }
         if(zone_hits>0 && zone_strength>ZONE_UNTESTED)
         {
            if(zone_hits==1)
               lbl=lbl+": "+test_name+zone_hits;
            else
               lbl=lbl+": "+test_name+zone_hits;
         }

         int adjust_hpos;
         int wbpc=WindowBarsPerChart();
         int k=Period()*60+(20+StringLen(lbl));

         if(wbpc<80)
            adjust_hpos=Time+k*4;
         else if(wbpc<125)
            adjust_hpos=Time+k*8;
         else if(wbpc<250)
            adjust_hpos=Time+k*15;
         else if(wbpc<480)
            adjust_hpos=Time+k*29;
         else if(wbpc<950)
            adjust_hpos=Time+k*58;
         else
            adjust_hpos=Time+k*115;

         //

         int shift=k*zone_label_shift;
         double vpos=zone_hi-(zone_hi-zone_lo)/2;


         if(zone_strength==ZONE_WEAK && 显示“已测试”供给和需求?==false)
            continue;
         if(zone_strength==ZONE_UNTESTED && 显示“待测试”供给和需求?==false)
            continue;
         if(zone_strength==ZONE_TURNCOAT && 显示“破坏的”供给和需求?==false)
            continue;

         string s="SSSR#"+i+"LBL";
         ObjectCreate(s,OBJ_TEXT,0,0,0);
         ObjectSet(s,OBJPROP_TIME1,adjust_hpos+shift);
         ObjectSet(s,OBJPROP_PRICE1,vpos);
         ObjectSetText(s,StringRightPad(lbl,36," "),Text_size,Text_font,Text_color);
         
         string shi="SSSR#"+i+"Hi";
         ObjectCreate(shi,OBJ_TEXT,0,0,0);
         ObjectSet(shi,OBJPROP_TIME1,adjust_hpos+shift);
         ObjectSet(shi,OBJPROP_PRICE1,zone_hi);
         ObjectSetText(shi,StringRightPad(lblhi,36," "),Text_size,Text_font,Text_color2);
         
         string slo="SSSR#"+i+"Lo";
         ObjectCreate(slo,OBJ_TEXT,0,0,0);
         ObjectSet(slo,OBJPROP_TIME1,adjust_hpos+shift);
         ObjectSet(slo,OBJPROP_PRICE1,zone_lo);
         ObjectSetText(slo,StringRightPad(lbllo,36," "),Text_size,Text_font,Text_color3);
      }
   }

   CheckAlerts();

   return(0);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CheckAlerts()
{
   static int lastalert=0;

   if(zone_show_alerts==false)
      return;

   if(Time-lastalert>zone_alert_waitseconds)
      if(CheckEntryAlerts()==true)
         lastalert=Time;
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CheckEntryAlerts()
{
// check for entries
   for(int i=0; i<zone_count; i++)
   {
      if(Close>=zone_lo && Close<zone_hi)
      {
         if(zone_show_alerts==true)
         {
            if(zone_alert_popups==true)
            {
               if(zone_type==ZONE_SUPPORT)
                  Alert(Symbol()+TimeFrameToString(Period())+": 进入需求区");
               else
                  Alert(Symbol()+TimeFrameToString(Period())+": 进入供给区");
            }

            if(zone_alert_sounds==true)
               PlaySound("alert_wav");
         }

         return(true);
      }
   }

   return(false);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DeleteGlobalVars()
{
   if(SetGlobals==false)
      return;

   GlobalVariableDel("SSSR_Count_"+Symbol()+Period());
   GlobalVariableDel("SSSR_Updated_"+Symbol()+Period());

   int old_count=zone_count;
   zone_count=0;
   DeleteOldGlobalVars(old_count);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DeleteOldGlobalVars(int old_count)
{
   if(SetGlobals==false)
      return;

   for(int i=zone_count; i<old_count; i++)
   {
      GlobalVariableDel("SSSR_HI_"+Symbol()+Period()+i);
      GlobalVariableDel("SSSR_LO_"+Symbol()+Period()+i);
      GlobalVariableDel("SSSR_HITS_"+Symbol()+Period()+i);
      GlobalVariableDel("SSSR_STRENGTH_"+Symbol()+Period()+i);
      GlobalVariableDel("SSSR_AGE_"+Symbol()+Period()+i);
   }
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void FindZones()
{
   int i,j,shift,bustcount=0,testcount=0;
   double hival,loval;
   bool turned=false,hasturned=false;

   double temp_hi,temp_lo;
   int    temp_start,temp_hits,temp_strength,temp_count=0;
   bool   temp_turn,temp_merge;
   int merge1,merge2,merge_count=0;

// iterate through zones from oldest to youngest (ignore recent 5 bars),
// finding those that have survived through to the present___
   for(shift=MathMin(Bars-1,监测距离(K线数)); shift>5; shift--)
   {
      double atr= iATR(NULL,0,7,shift);
      double fu = atr/2 * zone_fuzzfactor;
      bool isWeak;
      bool touchOk= false;
      bool isBust = false;

      if(FastUpPts>0.001)
      {
         // a zigzag high point
         isWeak=true;
         if(SlowUpPts>0.001)
            isWeak=false;

         hival=High;
         if(zone_extend==true)
            hival+=fu;

         loval=MathMax(MathMin(Close,High-fu),High-fu*2);
         turned=false;
         hasturned=false;
         isBust=false;

         bustcount = 0;
         testcount = 0;

         for(i=shift-1; i>=0; i--)
         {
            if((turned==false && FastUpPts>=loval && FastUpPts<=hival) ||
               (turned==true && FastDnPts<=hival && FastDnPts>=loval))
            {
               // Potential touch, just make sure its been 10+candles since the prev one
               touchOk=true;
               for(j=i+1; j<i+11; j++)
               {
                  if((turned==false && FastUpPts>=loval && FastUpPts<=hival) ||
                     (turned==true && FastDnPts<=hival && FastDnPts>=loval))
                  {
                     touchOk=false;
                     break;
                  }
               }

               if(touchOk==true)
               {
                  // we have a touch_If its been busted once, remove bustcount
                  // as we know this level is still valid & has just switched sides
                  bustcount=0;
                  testcount++;
               }
            }

            if((turned==false && High>hival) ||
               (turned==true && Low<loval))
            {
               // this level has been busted at least once
               bustcount++;

               if(bustcount>1 || isWeak==true)
               {
                  // busted twice or more
                  isBust=true;
                  break;
               }

               if(turned == true)
                  turned = false;
               else if(turned==false)
                  turned=true;

               hasturned=true;

               // forget previous hits
               testcount=0;
            }
         }

         if(isBust==false)
         {
            // level is still valid, add to our list
            temp_hi = hival;
            temp_lo = loval;
            temp_turn = hasturned;
            temp_hits = testcount;
            temp_start = shift;
            temp_merge = false;

            if(testcount>3)
               temp_strength=ZONE_PROVEN;
            else if(testcount>0)
               temp_strength=ZONE_VERIFIED;
            else if(hasturned==true)
               temp_strength=ZONE_TURNCOAT;
            else if(isWeak==false)
               temp_strength=ZONE_UNTESTED;
            else
               temp_strength=ZONE_WEAK;

            temp_count++;
         }
      }
      else if(FastDnPts>0.001)
      {
         // a zigzag low point
         isWeak=true;
         if(SlowDnPts>0.001)
            isWeak=false;

         loval=Low;
         if(zone_extend==true)
            loval-=fu;

         hival=MathMin(MathMax(Close,Low+fu),Low+fu*2);
         turned=false;
         hasturned=false;

         bustcount = 0;
         testcount = 0;
         isBust=false;

         for(i=shift-1; i>=0; i--)
         {
            if((turned==true && FastUpPts>=loval && FastUpPts<=hival) ||
               (turned==false && FastDnPts<=hival && FastDnPts>=loval))
            {
               // Potential touch, just make sure its been 10+candles since the prev one
               touchOk=true;
               for(j=i+1; j<i+11; j++)
               {
                  if((turned==true && FastUpPts>=loval && FastUpPts<=hival) ||
                     (turned==false && FastDnPts<=hival && FastDnPts>=loval))
                  {
                     touchOk=false;
                     break;
                  }
               }

               if(touchOk==true)
               {
                  // we have a touch_If its been busted once, remove bustcount
                  // as we know this level is still valid & has just switched sides
                  bustcount=0;
                  testcount++;
               }
            }

            if((turned==true && High>hival) ||
               (turned==false && Low<loval))
            {
               // this level has been busted at least once
               bustcount++;

               if(bustcount>1 || isWeak==true)
               {
                  // busted twice or more
                  isBust=true;
                  break;
               }

               if(turned == true)
                  turned = false;
               else if(turned==false)
                  turned=true;

               hasturned=true;

               // forget previous hits
               testcount=0;
            }
         }

         if(isBust==false)
         {
            // level is still valid, add to our list
            temp_hi = hival;
            temp_lo = loval;
            temp_turn = hasturned;
            temp_hits = testcount;
            temp_start = shift;
            temp_merge = false;

            if(testcount>3)
               temp_strength=ZONE_PROVEN;
            else if(testcount>0)
               temp_strength=ZONE_VERIFIED;
            else if(hasturned==true)
               temp_strength=ZONE_TURNCOAT;
            else if(isWeak==false)
               temp_strength=ZONE_UNTESTED;
            else
               temp_strength=ZONE_WEAK;

            temp_count++;
         }
      }
   }

// look for overlapping zones___
   if(zone_merge==true)
   {
      merge_count=1;
      int iterations=0;
      while(merge_count>0 && iterations<3)
      {
         merge_count=0;
         iterations++;

         for(i=0; i<temp_count; i++)
            temp_merge=false;

         for(i=0; i<temp_count-1; i++)
         {
            if(temp_hits==-1 || temp_merge==true)
               continue;

            for(j=i+1; j<temp_count; j++)
            {
               if(temp_hits==-1 || temp_merge==true)
                  continue;

               if((temp_hi>=temp_lo && temp_hi<=temp_hi) ||
                  (temp_lo <= temp_hi && temp_lo >= temp_lo) ||
                  (temp_hi >= temp_lo && temp_hi <= temp_hi) ||
                  (temp_lo <= temp_hi && temp_lo >= temp_lo))
               {
                  merge1 = i;
                  merge2 = j;
                  temp_merge = true;
                  temp_merge = true;
                  merge_count++;
               }
            }
         }

         // ___ and merge them ___
         for(i=0; i<merge_count; i++)
         {
            int target = merge1;
            int source = merge2;

            temp_hi = MathMax(temp_hi, temp_hi);
            temp_lo = MathMin(temp_lo, temp_lo);
            temp_hits += temp_hits;
            temp_start = MathMax(temp_start, temp_start);
            temp_strength=MathMax(temp_strength,temp_strength);
            if(temp_hits>3)
               temp_strength=ZONE_PROVEN;

            if(temp_hits==0 && temp_turn==false)
            {
               temp_hits=1;
               if(temp_strength<ZONE_VERIFIED)
                  temp_strength=ZONE_VERIFIED;
            }

            if(temp_turn == false || temp_turn == false)
               temp_turn = false;
            if(temp_turn == true)
               temp_hits = 0;

            temp_hits=-1;
         }
      }
   }

// copy the remaining list into our official zones arrays
   zone_count=0;
   for(i=0; i<temp_count; i++)
   {
      if(temp_hits>=0 && zone_count<1000)
      {
         zone_hi       = temp_hi;
         zone_lo       = temp_lo;
         zone_hits   = temp_hits;
         zone_turn   = temp_turn;
         zone_start    = temp_start;
         zone_strength = temp_strength;

         if(zone_hi<Close)
            zone_type=ZONE_SUPPORT;
         else if(zone_lo>Close)
            zone_type=ZONE_RESIST;
         else
         {
            for(j=5; j<1000; j++)
            {
               if(Close<zone_lo)
               {
                  zone_type=ZONE_RESIST;
                  break;
               }
               else if(Close>zone_hi)
               {
                  zone_type=ZONE_SUPPORT;
                  break;
               }
            }

            if(j==1000)
               zone_type=ZONE_SUPPORT;
         }

         zone_count++;
      }
   }
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DrawZones()
{
   double lower_nerest_zone_P1=0;
   double lower_nerest_zone_P2=0;
   double higher_nerest_zone_P1=EMPTY_VALUE;
   double higher_nerest_zone_P2=EMPTY_VALUE;

   if(SetGlobals==true)
   {
      GlobalVariableSet("SSSR_Count_"+Symbol()+Period(),zone_count);
      GlobalVariableSet("SSSR_Updated_"+Symbol()+Period(),TimeCurrent());
   }

   for(int i=0; i<zone_count; i++)
   {
      if(zone_strength==ZONE_WEAK && 显示“已测试”供给和需求?==false)
         continue;

      if(zone_strength==ZONE_UNTESTED && 显示“待测试”供给和需求?==false)
         continue;

      if(zone_strength==ZONE_TURNCOAT && 显示“破坏的”供给和需求?==false)
         continue;

      //name sup
      if(zone_type==ZONE_SUPPORT)
         string s="SSSR#S"+i+" Strength=";
      else
      //name res
         s="SSSR#R"+i+" Strength=";

      if(zone_strength==ZONE_PROVEN)
         s=s+"Proven, Test Count="+zone_hits;
      else if(zone_strength==ZONE_VERIFIED)
         s=s+"Verified, Test Count="+zone_hits;
      else if(zone_strength==ZONE_UNTESTED)
         s=s+"Untested";
      else if(zone_strength==ZONE_TURNCOAT)
         s=s+"Turncoat";
      else
         s=s+"Weak";

      ObjectCreate(s,OBJ_RECTANGLE,0,0,0,0,0);
      ObjectSet(s,OBJPROP_TIME1,Time]);
      ObjectSet(s,OBJPROP_TIME2,Time);
      ObjectSet(s,OBJPROP_PRICE1,zone_hi);
      ObjectSet(s,OBJPROP_PRICE2,zone_lo);
      ObjectSet(s,OBJPROP_BACK,zone_solid);
      ObjectSet(s,OBJPROP_WIDTH,zone_linewidth);
      ObjectSet(s,OBJPROP_STYLE,zone_style);

      if(zone_type==ZONE_SUPPORT)
      {
         // support zone
         if(zone_strength==ZONE_TURNCOAT)
            ObjectSet(s,OBJPROP_COLOR,color_support_turncoat);
         else if(zone_strength==ZONE_PROVEN)
            ObjectSet(s,OBJPROP_COLOR,color_support_proven);
         else if(zone_strength==ZONE_VERIFIED)
            ObjectSet(s,OBJPROP_COLOR,color_support_verified);
         else if(zone_strength==ZONE_UNTESTED)
            ObjectSet(s,OBJPROP_COLOR,color_support_untested);
         else
            ObjectSet(s,OBJPROP_COLOR,color_support_weak);
      }
      else
      {
         // resistance zone
         if(zone_strength==ZONE_TURNCOAT)
            ObjectSet(s,OBJPROP_COLOR,color_resist_turncoat);
         else if(zone_strength==ZONE_PROVEN)
            ObjectSet(s,OBJPROP_COLOR,color_resist_proven);
         else if(zone_strength==ZONE_VERIFIED)
            ObjectSet(s,OBJPROP_COLOR,color_resist_verified);
         else if(zone_strength==ZONE_UNTESTED)
            ObjectSet(s,OBJPROP_COLOR,color_resist_untested);
         else
            ObjectSet(s,OBJPROP_COLOR,color_resist_weak);
      }


      if(SetGlobals==true)
      {
         GlobalVariableSet("SSSR_HI_"+Symbol()+Period()+i,zone_hi);
         GlobalVariableSet("SSSR_LO_"+Symbol()+Period()+i,zone_lo);
         GlobalVariableSet("SSSR_HITS_"+Symbol()+Period()+i,zone_hits);
         GlobalVariableSet("SSSR_STRENGTH_"+Symbol()+Period()+i,zone_strength);
         GlobalVariableSet("SSSR_AGE_"+Symbol()+Period()+i,zone_start);
      }

      //nearest zones
      if(zone_lo>lower_nerest_zone_P2 && Bid>zone_lo) {lower_nerest_zone_P1=zone_hi;lower_nerest_zone_P2=zone_lo;}
      if(zone_hi<higher_nerest_zone_P1 && Bid<zone_hi) {higher_nerest_zone_P1=zone_hi;higher_nerest_zone_P2=zone_lo;}
   }

   ner_hi_zone_P1=higher_nerest_zone_P1;
   ner_hi_zone_P2=higher_nerest_zone_P2;
   ner_lo_zone_P1=lower_nerest_zone_P1;
   ner_lo_zone_P2=lower_nerest_zone_P2;
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool Fractal(int M,int P,int shift)
{
   if(Period()>P)
      P=Period();

   P=P/Period()*2+MathCeil(P/Period()/2);

   if(shift<P)
      return(false);

   if(shift>Bars-P)
      return(false);

   for(int i=1; i<=P; i++)
   {
      if(M==UP_POINT)
      {
         if(High>High)
            return(false);
         if(High>=High)
            return(false);
      }
      if(M==DN_POINT)
      {
         if(Low<Low)
            return(false);
         if(Low<=Low)
            return(false);
      }
   }
   return(true);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void FastFractals()
{
   int shift;
   int limit=MathMin(Bars-1,监测距离(K线数));
   int P=Period()*快因子大小;

   FastUpPts = 0.0; FastUpPts = 0.0;
   FastDnPts = 0.0; FastDnPts = 0.0;

   for(shift=limit; shift>1; shift--)
   {
      if(Fractal(UP_POINT,P,shift)==true)
         FastUpPts=High;
      else
         FastUpPts=0.0;

      if(Fractal(DN_POINT,P,shift)==true)
         FastDnPts=Low;
      else
         FastDnPts=0.0;
   }
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SlowFractals()
{
   int shift;
   int limit=MathMin(Bars-1,监测距离(K线数));
   int P=Period()*慢因子大小;

   SlowUpPts = 0.0; SlowUpPts = 0.0;
   SlowDnPts = 0.0; SlowDnPts = 0.0;

   for(shift=limit; shift>1; shift--)
   {
      if(Fractal(UP_POINT,P,shift)==true)
         SlowUpPts=High;
      else
         SlowUpPts=0.0;

      if(Fractal(DN_POINT,P,shift)==true)
         SlowDnPts=Low;
      else
         SlowDnPts=0.0;
   }
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool NewBar()
{
   static datetime LastTime=0;
   if(iTime(Symbol(),Period(),0)+time_offset!=LastTime)
   {
      LastTime=iTime(Symbol(),Period(),0)+time_offset;
      return (true);
   }
   else
      return (false);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DeleteZones()
{
   int len=5;
   int i;

   while(i<ObjectsTotal())
   {
      string objName=ObjectName(i);
      if(StringSubstr(objName,0,len)!="SSSR#")
      {
         i++;
         continue;
      }
      ObjectDelete(objName);
   }
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string TimeFrameToString(int tf) //code by TRO
{
   string tfs;

   switch(tf)
   {
      case PERIOD_M1:
         tfs="M1";
         break;
      case PERIOD_M5:
         tfs="M5";
         break;
      case PERIOD_M15:
         tfs="M15";
         break;
      case PERIOD_M30:
         tfs="M30";
         break;
      case PERIOD_H1:
         tfs="H1";
         break;
      case PERIOD_H4:
         tfs="H4";
         break;
      case PERIOD_D1:
         tfs="D1";
         break;
      case PERIOD_W1:
         tfs="W1";
         break;
      case PERIOD_MN1:
         tfs="MN";
   }

   return(tfs);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string StringRepeat(string str,int n=1)
{
   string outstr="";
   for(int i=0; i<n; i++) outstr=outstr+str;
   return(outstr);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string StringRightPad(string str,int n=1,string str2=" ")
{
   return(str + StringRepeat(str2,n-StringLen(str)));
}
//+------------------------------------------------------------------+

bigwin 发表于 2024-4-15 15:38:08

欢迎大家交流,批评指正。

ken138888 发表于 2024-4-16 06:40:36

看差不错呢

t5530407 发表于 2024-4-18 22:53:10

楼主好人好心

xinhua123 发表于 2024-4-20 00:04:21

好好学习天天向上

shllwk 发表于 2024-5-6 19:58:40

订单块策略,不同等级,缓解情况等

秒秒007 发表于 2024-5-9 07:36:31

供需策略

minggege 发表于 2024-5-28 08:39:45

供需指标

liguangxing2007 发表于 2024-6-24 10:26:35

看不懂什么东西啊

stjingyuan 发表于 2024-6-27 20:50:01

这是技术指标?还是ea

hanbin618 发表于 2024-8-17 17:54:54

看起来不错

leo321 发表于 2024-12-4 11:43:03

效果还不错

yzh03106 发表于 2024-12-11 14:08:00

看着不错啊!

dyt20 发表于 2024-12-13 16:24:19

币刚好不够了

天使的恶魔君 发表于 2025-2-9 11:33:44

浏览还需要币?

196013755 发表于 2025-3-6 07:48:20

早上是来学习的

dyt20 发表于 2025-4-20 12:44:54

有没有MT5的

alibhr 发表于 2025-4-25 17:31:10

study hard and improve every day
页: [1]
查看完整版本: 订单块-供需策略