股票量化軟件:驗證流言--- 全日交易取決于亞洲時段的交易行情
“全日交易取決于亞洲時段的交易行情”。
愛因斯坦認(rèn)為,一切都是相對的,一旦我們推敲任何陳述細(xì)節(jié)的話,我們會?馬上?相信他說的是對的。?例如,有個問題是關(guān)于亞洲市場的交易時間的。 讓我們來看一看以下圖表,交易時間如下所示。赫茲量化軟件
地區(qū)
城市
冬季時間
開市
冬季時間
收市
夏季時間
開市
夏季時間
收市
亞洲
東京
香港
新加坡
03:00
04:00
04:00
11:00
12:00
12:00
04:00
05:00
04:00
12:00
13:00
12:00
歐洲
法蘭克福
蘇黎世
巴黎
倫敦
9:00
9:00
9:00
10:00
17:00
17:00
17:00
18:00
09:00
09:00
09:00
10:00
17:00
17:00
17:00
18:00
美洲
紐約
芝加哥
16:00
17:00
24:00
01:00
16:00
17:00
24:00
01:00
大洋洲
威靈頓
悉尼
00:00
01:00
08:00
09:00
00:00
01:00
08:00
09:00
表 1 外匯交易時段
我們可以發(fā)現(xiàn),亞洲交易時段在冬令時開始于 3:00,結(jié)束于 12:00,在夏令時開始于 4:00,結(jié)束于 13:00。 但歐洲的交易時間開始于 9.00。 那么問題來了 - 亞洲市場的開放時間到底是 3.00 到 9.00 還是 3.00 到 13.00?赫茲量化軟件 另一個問題是關(guān)于服務(wù)器時間,由于不同經(jīng)紀(jì)人的服務(wù)器時間不同,故沒有必要與莫斯科時間保持一致,還有一個問題是關(guān)于冬令時/夏令時的時間調(diào)整 - 部分經(jīng)紀(jì)人并不做此調(diào)整。 因此,我們需要將此納入我們的研究范圍內(nèi)。 “..全日交易取決于此”是什么意思? 如果亞洲時段行情上漲,價格是否會持續(xù)漲至下一個時段?赫茲量化軟件
首先,讓我們來看看圖 1。 該時段已用 Igor Kim 開發(fā)的指標(biāo) “i-Sessions” 涂上了不同顏色。 從 3.00 到 13.00 的時段填充為黑色(“亞洲”)。 歐洲時段(9.00 至 18.00)涂上了較淺顏色,美洲時段(16.00 至 24.00)則為最淺顏色。赫茲量化軟件
圖 1 NZDUSD 交易時段圖
我將進(jìn)一步詳細(xì)描述,以幫助新手了解透徹。
因此,我的 Expert Advisor “1-Session” 設(shè)計用于解決以下問題:
必須計算時段開盤和收盤的價位,而時段由我們指定。 讓我們假設(shè)如果時段的開盤價位高于收盤價位,則該時段為下跌行情,反之則為上漲行情。赫茲量化軟件
如果開盤價位等于收盤價位,則行情中性。赫茲量化軟件
我試著對所有的 Expert Advisor 代碼進(jìn)行注釋,以令新手(包括我在內(nèi))易于理解。
//+------------------------------------------------------------------+ //|????????????????????????????????????????????????????1-Session.mq4 | //|????????????????????????????????Copyright ? 2009, Igor Alexandrov | //|????????????????????????????????????????????????sydiya@rambler.ru | //+------------------------------------------------------------------+ #property copyright "Copyright ? 2009, Igor Alexandrov" #property link??????"sydiya@rambler.ru" //---- Input parameters extern string??Open_session =??"01:00"; //Opening time of the session to study extern string??Close_session = "10:00"; //Closing time of the session to study extern int Day_kol_vo = 50;???????????? //Number of days to study extern int Hour_kol_vo = 15;????????????//Number of hours to study after the session extern int Profit = 20;???????????????? //Take Profit value to verify //---------------------------------------------------------------------------- string Symb;????????????????????????????//Trade symbol of the expert attached //----------------------------Starting---------------------------------------- int start() ??{ //the main bracket begins ?? int??Shift_open_H1,?????? //Number of hourly bar with the same opening time as daily bar ?? Shift_open_bars_session,??//Number of hourly bar, that opens the session???? ?? Shift_close_bars_session, //Number of hourly bar, that closes the session ?? STOP_LEVER=0;???????????? //Minimal distance for TP and SL ?? double Open_bars_session, //Opening price of the first bar of the session ?? Close_bars_session,?????? //Closing price of the last bar of the session ?? Vira_session,???????????? //Maximal price of the session ?? Total_TP=0,?????????????? //Counter of Take Profit executions ?? Total_SL=0,?????????????? //Counter of Stop Loss executions ?? Total_day=0,??????????????//Number of days to study ?? Total_SL_TP=0,????????????//Counter of neutral sessions ?? Maina_session;????????????//Minimal price of the session ?? datetime Time_open_day,?? //Opening time of the i-th daily bar ?? Time_open_session,????????//Opening time of the session (datetime format) ?? Time_close_session;?????? //Closing time of the session (datetime format) ?? string String_open_H1;????//Opening time of the first hourly bar of the day to study ???????????????????????????? //as string format "yyyy.mm.dd" ?? bool?? Session_buy=false, //Bullish session flag ?? Session_sell=false;?????? //Bearish session flag ?? Symb=Symbol();????????????//Symbol name ?? //Minimal distance for TP and SL ?? STOP_LEVER=MarketInfo(Symb,MODE_STOPLEVEL); ?? // daily bars cycle ?? for(int i=Day_kol_vo;i>0;i --) ???? { //bracket for daily bars cycle ??????//Counter for days studied ??????Total_day++; ??????//opening time of the i-th daily bar ??????Time_open_day=iTime(Symb,PERIOD_D1,i); ??????//number of hourly bar with the same opening time as daily bar ??????Shift_open_H1=iBarShift(Symb,PERIOD_H1,Time_open_day,false); ??????//convert opening time of the first hourly bar to the string like "yyyy.mm.dd" ??????String_open_H1=TimeToStr(Time_open_day,TIME_DATE); ??????//opening time for the session to study (in the datetime format) ??????Time_open_session=StrToTime(String_open_H1+" "+Open_session); ??????//number of hourly bar from which session begins ??????Shift_open_bars_session=iBarShift(Symb,PERIOD_H1,Time_open_session,false); ??????//closing time of the session to study (in datetime format) ??????Time_close_session=StrToTime(String_open_H1+" "+Close_session); ??????//number of last hourly bar of the session ??????Shift_close_bars_session=iBarShift(Symb,PERIOD_H1,Time_close_session,false); ??????//opening price of the first bar of the session ??????Open_bars_session=iOpen(Symb,PERIOD_H1,Shift_open_bars_session); ??????//closing price of the last bar of the session ??????Close_bars_session=iClose(Symb,PERIOD_H1,Shift_close_bars_session); ??????//finding the maximal price of the session ??????Vira_session=iHigh(Symb,PERIOD_H1,iHighest(Symb,PERIOD_H1,MODE_HIGH, ??????(Shift_open_bars_session-Shift_close_bars_session),Shift_close_bars_session)); ??????//finding the minimal price of the session ??????Maina_session=iLow(Symb,PERIOD_H1,iLowest(Symb,PERIOD_H1,MODE_LOW, ??????(Shift_open_bars_session-Shift_close_bars_session),Shift_close_bars_session)); ??????// the opening price is greater than closing price, session is Bearish ??????if(Open_bars_session>Close_bars_session) ????????{ ???????? Session_buy=false; ???????? Session_sell=true; ????????} ??????//The opening price is lower than closing price, session is bullish?????? ??????if(Open_bars_session<Close_bars_session) ????????{ ???????? Session_buy=true; ???????? Session_sell=false; ????????} ??????//The opening price is equal to closing price, session is Neutral ??????if(Open_bars_session==Close_bars_session) ????????{ ???????? Session_buy=false; ???????? Session_sell=false; ????????} ??????// hours counter for checking ??????int PEREBOR=0; ??????//Cycle for hourly bars in the i-th day ??????for(int j=Shift_close_bars_session;j>Shift_close_bars_session-Hour_kol_vo;j --) ????????{//Opening bracket for the hourly bars cycle ???????? //hours counter (for checking) ???????? PEREBOR++; ???????? //if session is bullish ???????? if(Session_buy==true && Session_sell==false) ?????????? { ????????????//if maximal price of the hourly bar ????????????//is greater than (closing price of the session+Profit+Minimal distance) ????????????if(iHigh(Symb,PERIOD_H1,j-PEREBOR)>(Close_bars_session+(Profit+STOP_LEVER)*Point)) ??????????????{ ?????????????? Total_TP++;???? //Take Profit executed ?????????????? break;??????????//break the cycle(hourly bars) ??????????????} ????????????//if minimal price of the hourly bar ????????????//is lower than minimal price of the session ????????????if(iLow(Symb,PERIOD_H1,j-PEREBOR)<Maina_session) ??????????????{ ?????????????? Total_SL++;???? //Stop Loss executed ?????????????? break;??????????//break the cycle(hourly bars) ??????????????} ?????????? } ???????? //if session is bearish ???????? if(Session_buy==false && Session_sell==true) ?????????? { ????????????//if maximal price of the hourly bar ????????????//is greater than maximal price of the session ????????????if(iHigh(Symb,PERIOD_H1,j-PEREBOR)>Vira_session) ??????????????{ ?????????????? Total_SL++;??????//Stop Loss executed ?????????????? break;?????????? //break the cycle(hourly bars) ??????????????} ????????????//if minimal price of the hourly bar ????????????//is lower than (closing price of the session-(Profit + Minimal distance)) ????????????if(iLow(Symb,PERIOD_H1,j-PEREBOR)<(Close_bars_session-(Profit+STOP_LEVER)*Point)) ??????????????{ ?????????????? Total_TP++;??????//Take Profit executed?????????????? ?????????????? break;?????????? //break the cycle(hourly bars) ??????????????} ?????????? } ???????? //if session is neutral ???????? if(Session_buy==false && Session_sell==false) ?????????? { ????????????Total_SL_TP++;??????//Increase the counter ????????????break;??????????????//break the cycle(hourly bars) ?????????? } ????????} // closing bracket for the hourly bars cycle ??????double Pro_Total_TP=(Total_TP/Total_day)*100, //Probabiility of TP execution ??????Pro_Total_SL=(Total_SL/Total_day)*100,????????//Probability of SL execution ??????Pro_Total_SL_TP=(Total_SL_TP/Total_day)*100;??//Probability of neutral sessions ??????int Total_no=Total_day-Total_SL-Total_TP-Total_SL_TP; //TP and SL hasn't executed ??????double Pro_Total_no =(Total_no/Total_day)*100;????????//Probability that TP and SL will not executed ??????Comment("Checked ",Total_day," days","\n", ??????????????"Session Opening time??",Open_session," Session Closing time ", ??????????????Close_session," Number of hours to check after the session ",Hour_kol_vo," Profit ",Profit,"\n", ??????????????"Take profit has executed ",Total_TP," times","\n", ??????????????"Stop Loss has executed ",Total_SL," times","\n", ??????????????"The neutral sessions was ",Total_SL_TP," times","\n", ??????????????"Neither SL/TP executed ",Total_no," times","\n", ??????????????"Probability for Take Profit execution ",Pro_Total_TP," %","\n", ??????????????"Probability for Stop Loss execution ",Pro_Total_SL," %","\n", ??????????????"Probability for neutral sessions ",Pro_Total_SL_TP," %","\n", ??????????????"Probability that SL and TP will not executed ",Pro_Total_no," %"); ???? } //Closing bracket for the daily bars ?? return(0); ??} //-the main bracket ends
?