[MT4指标]趋势阻力区间指标
主图指标
趋势阻力区间指标
mt4指标类型:趋势指标
是否能用在mt4手机版上:否
是否含有未来函数:无
可以用在韬客外汇返佣网的平台上
#property copyright "[email protected]"
#property indicator_chart_window
extern int HistoryDay=5;
extern int timeshift=0;
//+------------------------------------------------------------------+
int deinit() {
ObjectsDeleteAll(0,EMPTY);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
}
return(0);
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double x;
int h,m,s,k;
m=Time[0]+Period()*60-CurTime();
x=m/60.0;
s=m%60;
m=(m-m%60)/60;
h=x/60;
k=m-(h*60);
for (int i=HistoryDay;i>=0;i--)
{
datetime TokyoStart=StrToTime(TimeToStr(iTime(Symbol(),PERIOD_D1,i),TIME_DATE)+" 01:00");
TokyoStart=StrToTime(TimeToStr(TokyoStart,TIME_DATE)+" "+(TimeHour(TokyoStart)+timeshift));
datetime TokyoEnd=StrToTime(TimeToStr(iTime(Symbol(),PERIOD_D1,i),TIME_DATE)+" 09:00");
TokyoEnd=StrToTime(TimeToStr(TokyoEnd,TIME_DATE)+" "+(TimeHour(TokyoEnd)+timeshift));
int tokyo_bs=iBarShift(Symbol(),15,TokyoStart);
int tokyo_be=iBarShift(Symbol(),15,TokyoEnd);
int ibl_tokyo = iLowest(Symbol(),15,MODE_LOW,tokyo_bs-tokyo_be,tokyo_be);
int ibh_tokyo = iHighest(Symbol(),15,MODE_HIGH,tokyo_bs-tokyo_be,tokyo_be);
double vHigh_tokyo =High[ibh_tokyo];
double vLow_tokyo =Low[ibl_tokyo];
double vMid_tokyo =(vHigh_tokyo+vLow_tokyo)/2;
double sum_tokyo=(vHigh_tokyo-vLow_tokyo)/Point;
ObjectCreate ("TokyoStart"+i,OBJ_VLINE,0,TokyoStart,0);ObjectSet("TokyoStart"+i,OBJPROP_COLOR,SteelBlue);
ObjectCreate ("TokyoEnd"+i,OBJ_VLINE,0,TokyoEnd,0);ObjectSet("TokyoEnd"+i,OBJPROP_COLOR,SteelBlue);
if (ibl_tokyo>ibh_tokyo)
{double fibo_0= vHigh_tokyo;double fibo_100=vLow_tokyo;
string strfibo382="S H O R T";string strfibo618="L O N G";
}
else
{fibo_100= vHigh_tokyo;fibo_0=vLow_tokyo;
strfibo382="L O N G";strfibo618="S H O R T";}
string objname = "FIBO Tokyo"+i;
ObjectCreate(objname,OBJ_FIBO,0,TokyoEnd,fibo_100,TokyoEnd+2000,fibo_0);
ObjectSet(objname,OBJPROP_COLOR,Gray);
ObjectSet(objname,OBJPROP_RAY,false);
ObjectSet(objname,OBJPROP_TIMEFRAMES,OBJ_PERIOD_M15);
ObjectSet(objname,OBJPROP_LEVELCOLOR,SteelBlue);
ObjectSet(objname,OBJPROP_FIBOLEVELS,21);
ObjectSet(objname,OBJPROP_LEVELSTYLE,STYLE_DOT);
ObjectSet(objname,OBJPROP_FIRSTLEVEL,0);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+1,0.382);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+2,0.618);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+3,1);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+4,1.309);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+5,1.618);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+6,2);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+7,2.618);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+8,-0.382);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+9,-0.618);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+10,-1);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+11,-1.309);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+12,-1.618);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+13,-2);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+14,-2.618);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+15,0.236);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+16,-0.236);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+17,0.764);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+18,-0.764);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+19,4.237);
ObjectSet(objname,OBJPROP_FIRSTLEVEL+20,-4.237);
ObjectSetFiboDescription(objname,0,"0%% . %$%");
ObjectSetFiboDescription(objname,1,strfibo618+" . "+"%$%");
ObjectSetFiboDescription(objname,2,strfibo382+" . "+"%$%");
ObjectSetFiboDescription(objname,3,"100%% . %$%");
ObjectSetFiboDescription(objname,4,"130.9%% . %$%");
ObjectSetFiboDescription(objname,5,"Liber Abaci"+" . "+"%$%");
ObjectSetFiboDescription(objname,6,"200%% . %$%");
ObjectSetFiboDescription(objname,7,"261.8%% . %$%");
ObjectSetFiboDescription(objname,8,strfibo382+" . "+"%$%");
ObjectSetFiboDescription(objname,9,strfibo618+" . "+"%$%");
ObjectSetFiboDescription(objname,10,"E 100%% . %$%");
ObjectSetFiboDescription(objname,11,"E 130.9%% . %$%");
ObjectSetFiboDescription(objname,12,"Liber Abaci"+" . "+"%$%");
ObjectSetFiboDescription(objname,13,"E 200%% . %$%");
ObjectSetFiboDescription(objname,14,"E 261.8%% . %$%");
ObjectSetFiboDescription(objname,15,"23.6%% . %$%");
ObjectSetFiboDescription(objname,16,"E 23.6%% . %$%");
ObjectSetFiboDescription(objname,17,"76.4%% . %$%");
ObjectSetFiboDescription(objname,18,"E 76.4%% . %$%");
ObjectSetFiboDescription(objname,19,"423.7%% . %$%");
ObjectSetFiboDescription(objname,20,"E 423.7%% . %$%");
datetime LondonStart=StrToTime(TimeToStr(iTime(Symbol(),PERIOD_D1,i),TIME_DATE)+" 09:00");
LondonStart=StrToTime(TimeToStr(LondonStart,TIME_DATE)+" "+(TimeHour(LondonStart)+timeshift));
datetime LondonEnd=StrToTime(TimeToStr(iTime(Symbol(),PERIOD_D1,i),TIME_DATE)+" 14:00");
LondonEnd=StrToTime(TimeToStr(LondonEnd,TIME_DATE)+" "+(TimeHour(LondonEnd)+timeshift));
int London_bs=iBarShift(Symbol(),0,LondonStart);
int London_be=iBarShift(Symbol(),0,LondonEnd);
int ibl_London = iLowest(Symbol(),0,MODE_LOW,London_bs-London_be,London_be);
int ibh_London = iHighest(Symbol(),0,MODE_HIGH,London_bs-London_be,London_be);
double vHigh_London =High[ibh_London];
double vLow_London =Low[ibl_London];
double sum_london=(vHigh_London-vLow_London)/Point;
ObjectCreate ("LondonStart"+i,OBJ_VLINE,0,LondonStart,0);ObjectSet("LondonStart"+i,OBJPROP_COLOR,LimeGreen);
ObjectCreate ("LondonEnd"+i,OBJ_VLINE,0,LondonEnd,0);ObjectSet("LondonEnd"+i,OBJPROP_COLOR,LimeGreen);
if (ibl_London>ibh_London)
{double fibo_1= vHigh_London;double fibo_200=vLow_London;
string strfiboL382="S H O R T";string strfiboL618="L O N G";
}
else
{fibo_200= vHigh_London;fibo_1=vLow_London;
strfiboL618="S H O R T";strfiboL382="L O N G";}
string objnameL = "FIBO London"+i;
ObjectCreate(objnameL,OBJ_FIBO,0,LondonEnd,fibo_200,LondonEnd+3000,fibo_1);
ObjectSet(objnameL,OBJPROP_COLOR,Gray);
ObjectSet(objnameL,OBJPROP_RAY,false);
ObjectSet(objnameL,OBJPROP_TIMEFRAMES,OBJ_PERIOD_M15);
ObjectSet(objnameL,OBJPROP_LEVELCOLOR,LimeGreen);
ObjectSet(objnameL,OBJPROP_FIBOLEVELS,21);
ObjectSet(objnameL,OBJPROP_LEVELSTYLE,STYLE_DOT);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL,0);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+1,0.382);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+2,0.618);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+3,1);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+4,1.309);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+5,1.618);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+6,2);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+7,2.618);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+8,-0.382);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+9,-0.618);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+10,-1);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+11,-1.309);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+12,-1.618);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+13,-2);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+14,-2.618);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+15,0.236);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+16,-0.236);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+17,0.764);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+18,-0.764);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+19,4.237);
ObjectSet(objnameL,OBJPROP_FIRSTLEVEL+20,-4.237);
ObjectSetFiboDescription(objnameL,0,"0%% . %$%");
ObjectSetFiboDescription(objnameL,1,strfiboL618+" . "+"%$%");
ObjectSetFiboDescription(objnameL,2,strfiboL382+" . "+"%$%");
ObjectSetFiboDescription(objnameL,3,"100%% . %$%");
ObjectSetFiboDescription(objnameL,4,"130.9%% . %$%");
ObjectSetFiboDescription(objnameL,5,"Liber Abaci"+" . "+"%$%");
ObjectSetFiboDescription(objnameL,6,"200%% . %$%");
ObjectSetFiboDescription(objnameL,7,"261.8%% . %$%");
ObjectSetFiboDescription(objnameL,8,strfiboL382+" . "+"%$%");
ObjectSetFiboDescription(objnameL,9,strfiboL618+" . "+"%$%");
ObjectSetFiboDescription(objnameL,10,"E 100%% . %$%");
ObjectSetFiboDescription(objnameL,11,"E 130.9%% . %$%");
ObjectSetFiboDescription(objnameL,12,"Liber Abaci"+" . "+"%$%");
ObjectSetFiboDescription(objnameL,13,"E 200%% . %$%");
ObjectSetFiboDescription(objnameL,14,"E 261.8%% . %$%");
ObjectSetFiboDescription(objnameL,15,"23.6%%% . %$%");
ObjectSetFiboDescription(objnameL,16,"E 23.6%% . %$%");
ObjectSetFiboDescription(objnameL,17,"76.4%% . %$%");
ObjectSetFiboDescription(objnameL,18,"E 76.4%% . %$%");
ObjectSetFiboDescription(objnameL,19,"423.7%% . %$%");
ObjectSetFiboDescription(objnameL,20,"E 423.7%% . %$%");
datetime NewyorkStart=StrToTime(TimeToStr(iTime(Symbol(),PERIOD_D1,i),TIME_DATE)+" 14:00");
NewyorkStart=StrToTime(TimeToStr(NewyorkStart,TIME_DATE)+" "+(TimeHour(NewyorkStart)+timeshift));
datetime NewyorkEnd=StrToTime(TimeToStr(iTime(Symbol(),PERIOD_D1,i),TIME_DATE)+" 22:00");
NewyorkEnd=StrToTime(TimeToStr(NewyorkEnd,TIME_DATE)+" "+(TimeHour(NewyorkEnd)+timeshift));
int Newyork_bs=iBarShift(Symbol(),0,NewyorkStart);
int Newyork_be=iBarShift(Symbol(),0,NewyorkEnd);
int ibl_Newyork = iLowest(Symbol(),0,MODE_LOW,Newyork_bs-Newyork_be,Newyork_be);
int ibh_Newyork = iHighest(Symbol(),0,MODE_HIGH,Newyork_bs-Newyork_be,Newyork_be);
double vHigh_Newyork =High[ibh_Newyork];
double vLow_Newyork =Low[ibl_Newyork];
double sum_NY=(vHigh_Newyork-vLow_Newyork)/Point;
ObjectCreate ("NewYorkStart"+i,OBJ_VLINE,0,NewyorkStart,0);ObjectSet("NewYorkStart"+i,OBJPROP_COLOR,DarkOrange);
ObjectCreate ("NewYorkEnd"+i,OBJ_VLINE,0,NewyorkEnd,0);ObjectSet("NewYorkEnd"+i,OBJPROP_COLOR,DarkOrange);
if (ibl_Newyork>ibh_Newyork)
{double fibo_3= vHigh_Newyork;double fibo_300=vLow_Newyork;
string strfiboN382="S H O R T";string strfiboN618="L O N G";}
else
{fibo_300= vHigh_Newyork;fibo_3=vLow_Newyork;
strfiboN382="L O N G";strfiboN618="S H O R T";
}
string objnameN = "FIBO New York"+i;
ObjectCreate(objnameN,OBJ_FIBO,0,NewyorkEnd,fibo_300,NewyorkEnd+4000,fibo_3);
ObjectSet(objnameN,OBJPROP_COLOR,Gray);
ObjectSet(objnameN,OBJPROP_RAY,false);
ObjectSet(objnameN,OBJPROP_TIMEFRAMES,OBJ_PERIOD_M15);
ObjectSet(objnameN,OBJPROP_LEVELCOLOR,DarkOrange);
ObjectSet(objnameN,OBJPROP_FIBOLEVELS,21);
ObjectSet(objnameN,OBJPROP_LEVELSTYLE,STYLE_DOT);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL,0);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+1,0.382);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+2,0.618);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+3,1);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+4,1.382);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+5,1.618);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+6,2);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+7,2.618);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+8,-0.382);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+9,-0.618);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+10,-1);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+11,-1.382);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+12,-1.618);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+13,-2);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+14,-2.618);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+15,0.236);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+16,-0.236);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+17,0.764);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+18,-0.764);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+19,4.237);
ObjectSet(objnameN,OBJPROP_FIRSTLEVEL+20,-4.237);
ObjectSetFiboDescription(objnameN,0,"0%% . %$%");
ObjectSetFiboDescription(objnameN,1,strfiboN618+" . "+"%$%");
ObjectSetFiboDescription(objnameN,2,strfiboN382+" . "+"%$%");
ObjectSetFiboDescription(objnameN,3,"100%% . %$%");
ObjectSetFiboDescription(objnameN,4,"130.9%% . %$%");
ObjectSetFiboDescription(objnameN,5,"Liber Abaci"+" . "+"%$%");
ObjectSetFiboDescription(objnameN,6,"200%% . %$%");
ObjectSetFiboDescription(objnameN,7,"261.8%% . %$%");
ObjectSetFiboDescription(objnameN,8,strfiboN382+" . "+"%$%");
ObjectSetFiboDescription(objnameN,9,strfiboN618+" . "+"%$%");
ObjectSetFiboDescription(objnameN,10,"E 100%% . %$%");
ObjectSetFiboDescription(objnameN,11,"E 130.9%% . %$%");
ObjectSetFiboDescription(objnameN,12,"Liber Abaci"+" . "+"%$%");
ObjectSetFiboDescription(objnameN,13,"E 200%% . %$%");
ObjectSetFiboDescription(objnameN,14,"E 261.8%% . %$%");
ObjectSetFiboDescription(objnameN,15,"23.6%%% . %$%");
ObjectSetFiboDescription(objnameN,16,"E 23.6%% . %$%");
ObjectSetFiboDescription(objnameN,17,"76.4%% . %$%");
ObjectSetFiboDescription(objnameN,18,"E 76.4%% . %$%");
ObjectSetFiboDescription(objnameN,19,"423.7%% . %$%");
ObjectSetFiboDescription(objnameN,20,"E 423.7%% . %$%");
}
if (TimeHour(TimeCurrent())>13)
{
ObjectCreate("SD_Newyork",OBJ_STDDEVCHANNEL,0,LondonStart,0,LondonEnd,0);
ObjectSet("SD_Newyork",OBJPROP_RAY,true);ObjectSet("SD_Newyork",OBJPROP_DEVIATION,2);
ObjectSet("SD_Newyork",OBJPROP_BACK,true);ObjectSet("SD_Newyork",OBJPROP_COLOR,Brown);
ObjectSet("SD_Newyork",OBJPROP_TIMEFRAMES,OBJ_PERIOD_M30);
ObjectSet("SD_Newyork",OBJPROP_STYLE,STYLE_SOLID);
ObjectSet("SD_Newyork",OBJPROP_SCALE,1.618);
}
if (TimeHour(TimeCurrent())>8)
{
ObjectCreate("SD_London",OBJ_STDDEVCHANNEL,0,TokyoStart,0,TokyoEnd,0);
ObjectSet("SD_London",OBJPROP_RAY,true);ObjectSet("SD_London",OBJPROP_DEVIATION,2);
ObjectSet("SD_London",OBJPROP_BACK,true);ObjectSet("SD_London",OBJPROP_COLOR,Green);
ObjectSet("SD_London",OBJPROP_TIMEFRAMES,OBJ_PERIOD_M30);
ObjectSet("SD_London",OBJPROP_STYLE,STYLE_SOLID);
ObjectSet("SD_London",OBJPROP_SCALE,1.618);
}
if (TimeHour(TimeCurrent())>22)
{
ObjectCreate("SD_Tokyo",OBJ_STDDEVCHANNEL,0,NewyorkStart,0,NewyorkEnd,0);
ObjectSet("SD_Tokyo",OBJPROP_RAY,true);ObjectSet("SD_Tokyo",OBJPROP_DEVIATION,2);
ObjectSet("SD_Tokyo",OBJPROP_BACK,true);ObjectSet("SD_Tokyo",OBJPROP_COLOR,Navy);
ObjectSet("SD_Tokyo",OBJPROP_TIMEFRAMES,OBJ_PERIOD_M30);
ObjectSet("SD_Tokyo",OBJPROP_STYLE,STYLE_SOLID);
ObjectSet("SD_Tokyo",OBJPROP_SCALE,1.618);
}
double sumAll= (sum_NY+sum_london+sum_tokyo )/3;
Comment( k + " minutes " + s + " second ",
"\n", "Tokyo : "+ DoubleToStr(sum_tokyo,0)+" pips",
"\n", "London : "+DoubleToStr(sum_london,0)+" pips",
"\n", "Newyork : "+ DoubleToStr(sum_NY,0)+" pips",
"\n", "Average : "+ DoubleToStr(sumAll,0)+" pips");
return(0);
}
//+------------------------------------------------------------------+Liber_Abaci.jpg
发表于:2015-04-16 06:38只看该作者
2楼
谢谢
韬客社区www.talkfx.co