请 [注册] 或 [登录]  | 返回主站

量化交易吧 /  量化策略 帖子:3364794 新帖:30

烛台方向统计再现的研究

TRADE12发表于:4 月 17 日 19:19回复(1)

简介

你好!

我想提请你注意以下思路。 是否能够基于烛台方向的再现趋势,在一天内的特定时间预测市场在即将到来的一小段时间内的市场行为? 即,是否可以在第一时间找出此类事件。

基本上,如果我们发现在过去几天的特定时间,烛台始终是同一方向,那么这本身就是非常有趣的现象。 毕竟,任何技术分析本质上都可归结为找出统计上的显著关系。



烛台方向上的重复变化表明趋势产生了变化。

首先我们要在某些条款上达成一致。 尽管这些条款是常用的,但我们还是要再过一遍,避免曲解。 如果烛台的开盘价小于收盘价 - 则被称为上升烛(在给出的图形中,它们均涂以白色),反之则为下降烛,均涂以黑色。 如果开盘价等于收盘价,这些烛台将被称为等价烛台(我自己的术语)。 如果报价下跌了一段时间,则这段时间是下跌趋势,反之则为上涨趋势。

我们看一看图片:

图 1 USDJPY 的 4 小时时间范围的烛台图,时间范围为 2009 年 11 月 20 日至 2009 年 12 月 8 日

如图 1 中所示,如果是下跌趋势,则形成此趋势的烛台大部分是下跌的,如果是上涨趋势,则烛台也是上涨的。 如果是横向的,则烛台也会不停变换其方向。

实际上,我们的问题 是确定烛台中是否有再现情况,以及它相对于趋势的变更会作出怎样的反应

当然,所有这些都可以手动完成,例如我们可以采用小时图或任何其他类型的图,在纸上写下烛台方向,并相互比较一段时间。 工作有很多,但都能完成。 不过我们还有 MQL4 编程语言这个神奇的工具,我们可以用它轻松创建 Expert Advisor,它将自己进行所有计算并告知我们计算结果的所有相关信息。

所以,我们要做的是:

  • 首先我们必须能够指定一个感兴趣的时间段。 15 分钟烛台是不太可能有的,因为在过去几年,每天在 7 点 15 分时百分百是下跌趋势。 然而,因为这种情况发生的概率虽小但仍存在,所以我们必须能够至少对过去六个月的时段测试这种情况。
  • 第二,最好是能够了解所研究期间有多少烛台是上升烛,有多少是下降烛。 你必须同意这一点:如果在过去 10 天内,在 18:00 打开的小时烛台上升了 6 次,下降了 4 次,则此信息不太可能会给我们提供重要的参考。 现在,如果 10 次中有 9 次下降,则此信息需被纳入考虑范围,用于确定今天 18:00 在哪个方向上建仓等。
  • 第三,最好还能了解烛台开盘价和收盘价之间的平均差距,以及它们在给定时段内的平均高度。
  • 第四,我们应能够在不同时间范围上执行我们的计算。

所有这些都可在给出的脚本的外部变量 script_Statistics_candles 中定义

现在看看下图。


图 2 脚本的输入参数

图 2 显示可在脚本中更改的输入参数。

Open_session - 研究时段的开始时间

Close_session - 研究时段的结束时间

Period_time - 脚本考虑烛台再现可能性时所处的时间范围。 可取以下值之一 - 5、15、30、60、240。 请记住这些值,其他值都不是允许值。 相应地,这些值对应于 5 分钟、15 分钟、30 分钟、1 小时和 4 小时的图形周期。

下面是脚本代码。 我在代码中添加了尽可能多的注释,因为我自己也在学习一本关于 MQL4 的教材,并且经常求助于此网站上的 Expert Advisor,尤其是带详细注释的 Expert Advisor。 应该承认,对于刚接触 MQL4 的新手来说,此网站上的任何文章(除了其他东西)都有教学价值。

//+------------------------------------------------------------------+
//|                                 script_Statistics_candles_V2.mq4 |
//|                              Copyright © 2009, Igor Aleksandrov  |
//|                                                sydiya@rambler.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Igor Aleksandrov"
#property link      "sydiya@rambler.ru"
#property show_inputs
//---- Input parameters

extern string  Open_session ="2009.11.20";   //Date of the opening of the studied session 
extern string  Close_session = "2009.11.26"; //Date of the closing of the studied session
extern int     Period_time = 60;             //Period of the graph on which the Expert Advisor will be working,
                                             //can take the value of 5;15;30;60;240
//-----------------------------------------------------------------
int 
    Day_bars_i;                      //Number for i bar in session
double
    Mas_vira_maina[24,60]={0,0 0,0}, //Declare an array for bars with an equal opening-closing price
    Mas_vira[24,60]={0,0 0,0},       //Declare an array for calculating bullish bars
    Mas_maina[24,60]={0,0 0,0},      //Declare an array for calculating bearish bars
    Mas_kol_vo[24,60]={0,0 0,0},     //Declare an array for calculating the number of the counted bars
    Mas_profit[24,60]={0,0 0.0},     //Declare an array of the calculation of profit by open-close
    Mas_H_L[24,60]={0,0 0.0};        //Declare an array of calculating the profit by high-low

string Symb;                         //Name of the financial. instrument on which the script is executed
bool New_day = false;                //Flag of the new day
//--------------------------------------------------------------------

//----------------------------Starting--------------------------------

int start()
  {                                  //-general opening bracket
  
  Print("----------------------------------------------------------------------");
  Print("  Results of the script's work- Statistics_candles- ",TimeToStr(TimeCurrent()) );
  Print("  Calculations completed from ",Open_session," to ",Close_session);

//------------------------Declare the variables ----------------------
  int  
       Hour_open_bars,                  //Number of the hour of opening the i bar in session
       Minute_open_bars,                //Number of the minute of opening  i bar in session
       Shift_open,                      //Number of bar with opening time Open_session               
       Shift_close,                     //Number of bar with opening time Close_session
       Shift_open_close,                //Number of bars in session
       Total_day=0;                     //Counter of counted days     
                    
  double Open_bars_price,               //Price of opening i bar of the session
         Close_bars_price,              //Price of closing the i bar of the session
         Low_bars_price,                //Minimum price of the i bar of the session
         High_bars_price,               //Maximum price of the i bar of the session
         Total_bars=0;                  //Number of studied bars at the start of the script
         
  datetime Time_open_session,           //Opening time of the first bar of the studied session 
                                        //in datatime format          
           Time_close_session,          //Opening time of the last bar of the studying 
                                        //session in datatime format 
           Time_open_bars;              //Opening time of bars in datatime format 
                       
  bool  Session_vira=false,             //Flag of the bullish session
        Session_maina=false;            //Flag of the bearish session 
//-----------------------End of the variables declaration ------------------
                   
  Symb=Symbol();                        //Name of the financial instrument
  
  //Request the starting time of the studied session in datatime format
  Time_open_session= StrToTime(Open_session); 

  //Request the closing time of the studied session in datatime format
  Time_close_session= StrToTime(Close_session); 

  //Request the number of the bar, opening the session
  Shift_open=iBarShift( Symb,Period_time, Time_open_session,false);

  //Request the number of the bar, which closes the session 
  Shift_close=iBarShift( Symb,Period_time, Time_close_session,false);

//---------------------------------------------------------------------  
for(int i = Shift_open; i>=Shift_close; i --)        //Cycle of bar searching in the session
{ //Opening bracket of the search cycle of bars
    Total_bars++;                                    //Counter of the number of studied bars
    static int New_day_shift=0;                      //Number of the day of starting the Expert Advisor

    //Request the opening of the i bar in session
    Time_open_bars=iTime( Symb,Period_time,Shift_open-Total_bars);

    //Request the opening hour of the i bar in session
    Hour_open_bars=TimeHour(Time_open_bars); 

    //Request the opening minute of the i bar in session 
    Minute_open_bars=TimeMinute(Time_open_bars);

    //Request the day number for the i bar in session
    Day_bars_i=TimeDayOfYear( Time_open_bars);
    
    //If the number for the first bar in session is not equal to the i-th bar of the day,then
    if(New_day_shift!=Day_bars_i)  
      {                                    
         New_day = true;               //flag for the new day is true
         New_day_shift=Day_bars_i;     //and assign the number for the number of the i bar
         Total_day++;                  //Increase the day counter by one
      }  
      else                             //otherwise,
      {
      New_day = false;                 //Flag for the new day is false
      }      
       //Request the opening price of the i-th bar
       Open_bars_price= iOpen( Symb, Period_time,i);

       //Request the closing price of the i-th bar
       Close_bars_price=iClose( Symb, Period_time,i);

       //Request the minimum price of the i-th bar
       Low_bars_price=iLow( Symb, Period_time,i);

       //Request the maximum price of the i-th bar
       High_bars_price=iHigh( Symb, Period_time,i);
        
       //If the opening price of the bar is lower than the closing price, then the session is bullish
       if(Open_bars_price<Close_bars_price) 
          {                                      
          //Increase by one the values of the corrsponding element
          Mas_vira[Hour_open_bars,Minute_open_bars]=Mas_vira[Hour_open_bars,Minute_open_bars]+1;

          //Increase by one the values of the corrsponding element
          Mas_kol_vo[Hour_open_bars,Minute_open_bars]=Mas_kol_vo[Hour_open_bars,Minute_open_bars]+1; 

          //Save the difference between the opening and closing price in points
          Mas_profit[Hour_open_bars,Minute_open_bars]=
          Mas_profit[Hour_open_bars,Minute_open_bars]+(Close_bars_price-Open_bars_price)/Point;

          //Save the difference between the maximum and minimum price in points
          Mas_H_L[Hour_open_bars,Minute_open_bars]=
          Mas_H_L[Hour_open_bars,Minute_open_bars]+(High_bars_price-Low_bars_price)/Point;
          }          

       //If the opening price of the bar is higher than the closing price, then the session is bearish
       if(Open_bars_price>Close_bars_price)
          {
           //Increase by one the values of the corrsponding element
           Mas_maina[Hour_open_bars,Minute_open_bars]=Mas_maina[Hour_open_bars,Minute_open_bars]+1;

           //Increase by one the values of the corrsponding element
           Mas_kol_vo[Hour_open_bars,Minute_open_bars]=Mas_kol_vo[Hour_open_bars,Minute_open_bars]+1; 

          //Save the difference between the opening and closing price in points
           Mas_profit[Hour_open_bars,Minute_open_bars]=
           Mas_profit[Hour_open_bars,Minute_open_bars]+(Open_bars_price-Close_bars_price)/Point;

          //Save the difference between the maximum and minimum price in points
           Mas_H_L[Hour_open_bars,Minute_open_bars]=
           Mas_H_L[Hour_open_bars,Minute_open_bars]+(High_bars_price-Low_bars_price)/Point;
          }

        //If the opening price is equal to the closing price, then session is undefined
        if(Open_bars_price==Close_bars_price)
          {
           ///Increase by one the corresponding array elements
           Mas_vira_maina[Hour_open_bars,Minute_open_bars]=Mas_vira_maina[Hour_open_bars,Minute_open_bars]+1;

           //Increase by one the corresponding array elements
           Mas_kol_vo[Hour_open_bars,Minute_open_bars]=Mas_kol_vo[Hour_open_bars,Minute_open_bars]+1; 
           
           //Leave the value of the array as is
           Mas_profit[Hour_open_bars,Minute_open_bars]=
           Mas_profit[Hour_open_bars,Minute_open_bars]+0;

           //Save the difference between maximum and minimum bar prices in points
           Mas_H_L[Hour_open_bars,Minute_open_bars]=
           Mas_H_L[Hour_open_bars,Minute_open_bars]+(High_bars_price-Low_bars_price)/Point;
          }                                                                          
      
} //Closing bracket of the bar search cycle
//--------------------------Print the information to the Expert Advisor Journal-------------------

Print("Processed - ",Total_day," days; ",Total_bars," bars, period ",Period_time," minutes");

for (int h=0; h<=23; h++) //Hours cycle
{
  for (int m=0; m<=60; m++) //Minutes cycle
   {
    if (Mas_kol_vo[h,m]!=0) //If the value of array is not equal to zero, then we continue counting
    {     
  Print("For the period there are ",Mas_kol_vo[h,m],
       " bars with the time of the opening ",h,":",m,
       " .Bullish- ",Mas_vira[h,m],
       ".Bearish- ",Mas_maina[h,m],
       ".Equal - ",Mas_vira_maina[h,m]);
  Print("For the bars with the opening time ",h,":",m,
       " ,average distance between the Open-Close prices - ",Mas_profit[h,m]/Mas_kol_vo[h,m],
       " points. Between the High-Low prices - ",Mas_H_L[h,m]/Mas_kol_vo[h,m]," points.");   
     }
           Mas_vira_maina[h,m]=0;  //set to zero
           Mas_vira[h,m]=0;        //set to zero
           Mas_maina[h,m]=0;       //set to zero
           Mas_kol_vo[h,m]=0;      //set to zero
           Mas_profit[h,m]=0;      //set to zero
           Mas_H_L[h,m]=0;         //set to zero
   } //End of the minute cycle
} //End of the hour cycle
             
Print("-------------- Script completed the work --------------------");

   return(0);    
  }                                        //-general closing bracket

如你所见,我宣布了六个正在计算的全局级数组。

double    
Mas_vira_maina[24,60]={0,0 0,0}, //Declare the bar array with an equal price of opening-closing
Mas_vira[24,60]={0,0 0,0},       //Declare the array for calculating the bullish bars
Mas_maina[24,60]={0,0 0,0},      //Declare the array for calculating the bearish bars
Mas_kol_vo[24,60]={0,0 0,0},     //Declare the array for calculating the number of counted bars
Mas_profit[24,60]={0,0 0.0},     //Declare the array for calculating the profit for open-close
Mas_H_L[24,60]={0,0 0.0};        //Declare the array for calculating the profit for high-low

我们将把条柱计数记录到 Mas_kol_vo 缓冲区中。 这么做的理由。 看起来,建仓-平仓和最高价-最低价的单元格数组的值能被计数天数除,尤其是代码中有计数器时 - Total_day 。 但我在处理脚本的过程中碰到了一个问题,即历史记录中缺少某些条柱,因此结果看上去非常有趣。 例如,所获得的某些条柱的高度完全是不现实的。

注释中可以很明显地看出剩余数组的用途。

实际上现在要检查不同趋势方向时的条柱的可重复性。 为此,让我们以 USDJPY 的小时图为例,如图 1 中所示。 我们可以看到,在 2009 年 11 月 20 日至 2009 年 11 月 26 日这段时间内,图中呈下跌趋势;从 2009 年 11 月 26 日至 2009 年 12 月 2 日,呈横盘趋势;从 2009 年 12 月 2 日至 2009 年 12 月 8 日,图中表现出上涨趋势。

让我们检查这段时间内是否有重复烛台,如果有,则算出其变更方向。

将脚本设置为小时图。 对于不明白怎么做的读者,我会提供更详细的说明。 将脚本 script_Statistics_candles_V2.mq4 下载到文件夹 \Program Files\TerminalName\expert\scripts 中。 复制。 脚本显示在“浏览器”窗口的左下角。 看起来就像这样:


图 3 浏览器窗口

如果你用鼠标将脚本从此窗口拖动到终端窗口,你将看到一个属性窗口 - 图 2. 指定计算的开始和结束日期。

为了理解这些操作的逻辑,请考虑以下情况。 设想你早上起床做的第一件事是运行此脚本。 下一步,你将运行结果放到表格中,编号 1 下方给出了一个相关示例。 你的任务是基于脚本运行结果试着了解市场在接下来的一天或两天内将发生什么情况。

好吧,让我们假定今天是 2009 年 11 月 26 日。 你运行了脚本,你对过去 6 个日历日内的烛台统计数据很感兴趣。 你将脚本的属性设置为: Open_session - 2009.11.20(6 天前) Close_session - 2009.11.26(就是今天),可使用任何时间范围进行计算,我用的是小时图,即 Period_time = 60。 我们将每日执行一次此任务,每次将脚本的开始和结束日期增加一天。

我们将基于历史数据执行此任务。

单击属性中的“确定”按钮,在“Expert Advisor”文件夹的“日志”文件中,可看到以下条目:

15:33:52 script_Statistics_candles_V2 EURUSD,H1: loaded successfully
15:33:53 script_Statistics_candles_V2 EURUSD,H1 inputs: Open_session="2009.11.20"; Close_session="2009.11.26"; Period_time=60;
15:33:53 script_Statistics_candles_V2 EURUSD,H1: ----------------------------------------------------------------------
15:33:53 script_Statistics_candles_V2 EURUSD,H1: Results of the script's work- Statistics_candles- 14:32
15:33:53 script_Statistics_candles_V2 EURUSD,H1: Calculations completed from 2009.11.20 to 2009.11.26
15:33:53 script_Statistics_candles_V2 EURUSD,H1: Processed - 5 days; 95 bars, period 60 minutes
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 3 bars with the time of the opening 0:0 .Bullish- 1.Bearish- 2.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 0:0,average distance between the Open-Close prices - 5.6667 points. Between the High-Low prices - 12 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 5 bars with the time of the opening 1:0 .Bullish- 2.Bearish- 2.Equal - 1
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 1:0,average distance between the Open-Close prices - 4.2 points. Between the High-Low prices - 11.8 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 2:0 .Bullish- 2.Bearish- 2.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 2:0,average distance between the Open-Close prices - 7 points. Between the High-Low prices - 16.25 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 3:0 .Bullish- 2.Bearish- 2.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 3:0,average distance between the Open-Close prices - 11.5 points. Between the High-Low prices - 25.25 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 4:0 .Bullish- 2.Bearish- 2.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 4:0,average distance between the Open-Close prices - 12.25 points. Between the High-Low prices - 21 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 5:0 .Bullish- 3.Bearish- 1.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 5:0,average distance between the Open-Close prices - 9.25 points. Between the High-Low prices - 17.75 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 6:0 .Bullish- 3.Bearish- 1.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 6:0,average distance between the Open-Close prices - 13.5 points. Between the High-Low prices - 22 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 7:0 .Bullish- 4.Bearish- 0.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 7:0,average distance between the Open-Close prices - 5.75 points. Between the High-Low prices - 15.25 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 8:0 .Bullish- 1.Bearish- 3.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 8:0,average distance between the Open-Close prices - 8.25 points. Between the High-Low prices - 22.75 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 9:0 .Bullish- 1.Bearish- 3.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 9:0,average distance between the Open-Close prices - 10.75 points. Between the High-Low prices - 22 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 10:0 .Bullish- 2.Bearish- 2.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 10:0,average distance between the Open-Close prices - 12.75 points. Between the High-Low prices - 34 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 11:0 .Bullish- 3.Bearish- 1.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 11:0,average distance between the Open-Close prices - 11.5 points. Between the High-Low prices - 26.75 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 12:0 .Bullish- 3.Bearish- 1.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 12:0,average distance between the Open-Close prices - 20.75 points. Between the High-Low prices - 24.5 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 13:0 .Bullish- 3.Bearish- 1.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 13:0,average distance between the Open-Close prices - 7 points. Between the High-Low prices - 18.5 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 14:0 .Bullish- 2.Bearish- 2.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 14:0,average distance between the Open-Close prices - 18.25 points. Between the High-Low prices - 31.75 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 15:0 .Bullish- 3.Bearish- 1.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 15:0,average distance between the Open-Close prices - 21.25 points. Between the High-Low prices - 34.25 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 16:0 .Bullish- 2.Bearish- 2.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 16:0,average distance between the Open-Close prices - 7 points. Between the High-Low prices - 23.75 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 17:0 .Bullish- 2.Bearish- 2.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 17:0,average distance between the Open-Close prices - 12.25 points. Between the High-Low prices - 31.75 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 18:0 .Bullish- 0.Bearish- 4.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 18:0,average distance between the Open-Close prices - 6.75 points. Between the High-Low prices - 31.75 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 19:0 .Bullish- 2.Bearish- 2.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 19:0,average distance between the Open-Close prices - 19.25 points. Between the High-Low prices - 28.25 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 20:0 .Bullish- 2.Bearish- 2.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 20:0,average distance between the Open-Close prices - 11.75 points. Between the High-Low prices - 21.75 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 21:0 .Bullish- 3.Bearish- 1.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 21:0,average distance between the Open-Close prices - 14 points. Between the High-Low prices - 20.75 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 4 bars with the time of the opening 22:0 .Bullish- 3.Bearish- 1.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 22:0,average distance between the Open-Close prices - 13.25 points. Between the High-Low prices - 26 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the period there are 3 bars with the time of the opening 23:0 .Bullish- 1.Bearish- 2.Equal - 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: For the bars with the opening time 23:0,average distance between the Open-Close prices - 7.6667 points. Between the High-Low prices - 15.6667 points.
15:33:53 script_Statistics_candles_V2 EURUSD,H1: -------------- Script completed the work --------------------
15:33:53 script_Statistics_candles_V2 EURUSD,H1: uninit reason 0
15:33:53 script_Statistics_candles_V2 EURUSD,H1: removed

将工作结果输入表格中。 让我们将上涨条柱的数量输入到“B”列中,将下跌条柱的数量输入到“M”列中,但“无”条柱的数量不输入表格中。

开盘时间 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
条柱类型
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
M
B
11.20-11.26
3 1 2 1 2 2 2 2 4 0 2 2 2 1 3 1 2 2 3 0 2 2 1 3 3 1 2 2 2 1 2 2 3 0 1 3 2 2 2 2 2 2 3 1 3 1 2 1
11.21-11.27
4 1 2 1 1 3 2 2 3 1 2 2 3 0 3 1 2 2 2 1 3 1 1 3 4 0 2 2 2 1 3 1 4 0 2 2 2 2 2 2 2 2 4 0 3 1 2 1
11.22-11.28
5 1 2 1 2 3 2 3 4 1 3 2 3 1 3 2 3 2 3 1 3 2 1 4 4 1 3 2 2 2 4 1 4 1 2 3 3 2 2
3 2 5 0 3 2 3 1
11.23-11.29
4 1 2 1 2 3 2 3 4 1 3 2 3 1 3 2 3 2 3 1 3 2 1 4 4 1 3 2 2 2 4 1 4 1 2 3 3 2 2 3 3 2 5 0 3 2 3 1
11.24-11.30
3 1 2 1 2 2 2 2 3 1 2 2 2 1 2 2 2 2 3 1 2 2 1 3 3 1 2 2 2 2 4 0 3 1 2 2 3 1 2 2 2 2 4 0 2 2 2 1
11.25-12.01
3 1 2 0 1 3 1 3 3 1 3 1 3 1 2 2 2 2 3 1 2 2 2 2 2 2 3 1 1 3 3 1 2 2 2 2 3 1 3 1 1 3 4 0 2 2 2 2
11.26-12.02
3 0 2 1 2 2 0 4 2 2 3 1 2 2 2 2 3 1 3 1 2 2 2 2 2 2 4 0 0 4 2 2 2 2 2 2 4 0 3 1 2 2 3 0 3 1 3 1
11.27-12.03
3 0 2 2 3 1 0 4 2 2 2 2 1 3 2 2 4 0 3 1 2 2 2 2 1 3 3 1 1 3 1 3 2 2 1 3 3 1 3 1 2 2 2 0 0 4 2 2
11.28-12.04
3 1 1 3 2 2 0 4 1 3 1 3 2 2 3 1 3 1 3 1 2 2 2 2 1 1 3 1 2 2 0 4 2 2 1 3 3 1 3 1 1 2 1 1 1 3 2 2
11.29-12.05
3 2 1 3 3 2 1 4 1 4 1 4 3 2 4 1 3 2 4 1 3 2 2 3 1 4 3 2 2 3 1 4 2 3 1 4 3 2 4 1 1 3 1 2 1 4 3 2
11.30-12.06
2 2 1 3 3 2 1 4 1 4 1 4 3 2 4 1 3 2 4 1 3 2 2 3 4 1 3 2 2 3 1 4 2 3 1 4 3 2 4 1 1 3 1 2 1 4 3 2
12.01-12.07
2 1 4 0 1 3 3 1 4 0 4 0 2 2 3 1 2 2 3 1 2 2 1 3 1 3 2 2 2 2 1 3 2 2 1 3 2 2 3 1 1 2 0 2 1 3 3 1
12.02-12.08
2 2 1 4 3 1 1 3 1 3 1 3 3 1 3 1 1 3 3 1 3 1 0 4 0 4 2 2 2 2 1 3 2 2 1 3 2 2 3 1 1 2 1 2 1 3 3 1

表 1 Expert Advisor 的工作结果

好吧,现在让我们来看一看结果。 首先,结果表明,某些条柱在同一时间段内的方向是相同的,这一点非常有趣。. 注意,单元格涂上了不同的颜色。 我用黄色标注过去 6 天内只含下跌条柱的单元格,并用粉色标注过去 6 天内只含上涨条柱的单元格。

在 11 月 26 日,可以看到过去 6 天中的第 4、9 和 16 个小时内,所有条柱都是下跌条柱。 我们可以假设今天熊市力量较强,甚至明天的市场也许也是熊市。

11 月 27 日。 事实证明我们的预测是正确的。 脚本结果显示,过去 6 天中的第 6、12、16 和 21 个小时,烛台完全呈下跌态势,因此我们可以假设市场将持续熊市格局。

11 月 28 日。 事实证明我们的预测是正确的。 在过去 6 天内,下跌烛台数量减少了,仅在第 21 个小时才完全呈下跌态势。 我们可以假设熊市趋势渐止,并将开始反弹。

11 月 29 日和 30 日,1 月 1 日和 2 日,情况是相同的。 我们正处于横盘趋势。 然而有趣的是,在 1 月 2 日,图中出现的全都是上涨烛台,我们假设趋势将发生变化,随着时间的推移,我们的假设得到了证明。

我们将在 12 月 5 日和 6 日见证一个有趣的情景。 烛台未在任一时间间隔内始终倾向于同一个方向。 这里面一定有隐情。 但当我们查看终端时,我们恍然大悟,原来这些表现异常的日子都是在周末。

12 月 7 日,我们再次看到了多向烛台,并再次等待趋势的变化。

12 月 8 日,第 11 和 12 个小时的烛台完全呈上涨态势。 图 1 中的趋势看起来像是下跌趋势? 但如果我们查看终端,我们会惊奇地发现,在 12 点左右,趋势将变为横盘,从 12 月 9 日开始,又变为上涨趋势。

好吧。 如我们所看到的那样,这个方法给不了你百分百的保证,但其他工具也同样如此。 然而这个工具可以是很有价值的,当它与其他技术分析方法相结合时,会对你预测未来一两天内的市场行为大有裨益。



总结

在写这篇文章时,我给自己设定了三个目标:

  • 第一,阐明学习 MQL4 语言的必要性,学习此语言后,你分析交易的能力会大幅增长,所有感兴趣的用户也能将其作为一个独立分析工具,用于针对不同时间间隔和货币对分析烛台的再现情况。
  • 第二,检查历史上不同时间间隔内是否有再现烛台,我在数天的流程中发现,一些具有相同开盘时间的烛台,其方向也是相同的。
  • 第三,看烛台方向的变化是否能作为预测趋势方向变化的一项依据。

显然,篇幅所限,仅仅一篇文章是不足以深入分析烛台在不同时间图上的行为的,我开始时本来还想这么做的。 所有人都可以探讨和分析他们特别感兴趣的货币对和时间范围。 此脚本就在所附文件中。

谢谢!

全部回复

0/140

量化课程

    移动端课程