请秃鹫老师、各位高手帮下忙
我想把下面指标的开始时间和运用周期修改一下就是这样:
A 可以修改指标的开始、结束时间,例如开始早上9点,结束是第二天的凌晨3点;
B 将适用周期扩展到4小时、日、周、月图
//+------------------------------------------------------------------+
//| MarketProfile.mq4 |
//| Copyright ?2006, Viatcheslav Suvorov|
//+------------------------------------------------------------------+
#property copyright "Viatcheslav Suvorov"
#property indicator_chart_window
extern datetime StartDate = D'';
extern bool lastdayStart = true;
extern int CountProfile = 2;
int fontsize=10;
int i,j;
double LastHigh,LastLow,CurPos;
bool signal;
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectsDeleteAll(0,OBJ_RECTANGLE);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- name for DataWindow and indicator subwindow label
short_name="MarketProfile";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
deinit();
double onetick;
double Mediana=0;
int MaxSize=0;
int MySize=0;
int MySizeEuropa=0;
int MySizeAzia=0;
int MySizeAmerica=0;
int BACK=0;
if (lastdayStart) StartDate=Time[0];
int x=Period();
if (x>60) return(-1);
if (x<15) return(-1);
BACK=0;
while (TimeDayOfYear(Time[BACK])>TimeDayOfYear(StartDate) || TimeYear(Time[BACK])!=TimeYear(StartDate) && (BACK=Bars) return(0);
}//while
onetick = 1/(MathPow(10,Digits));
i=BACK;
////
int cycles;
for (cycles=CountProfile;cycles>0;cycles--) {
signal=false;
LastHigh=High;
LastLow=Low;
while (!signal)
{
//if (i+1==Bars) signal=true;
if (High[i+1]>LastHigh) LastHigh=High[i+1];
if (Low[i+1]=BACK;j--) {
if ((High[j]>=CurPos) && (Low[j]<=CurPos)) {
MySize++;
if (TimeHour(Time[j])>=13) MySizeAmerica++; else
if ((TimeHour(Time[j])>=8) && (TimeHour(Time[j])<13)) MySizeEuropa++; else
MySizeAzia++;
}//if
}//for
if (MySizeAzia+MySizeEuropa+MySizeAmerica>MaxSize){
MaxSize=MySizeAzia+MySizeEuropa+MySizeAmerica;
Mediana=CurPos;
}
if (i-MySizeAzia>=0)
if(ObjectFind("rec"+"Azia"+TimeToStr(Time,TIME_DATE)+CurPos) == -1 && MySizeAzia!=0) {
ObjectCreate("rec"+"Azia"+TimeToStr(Time,TIME_DATE)+CurPos, OBJ_RECTANGLE, 0, Time, CurPos,Time[i-MySizeAzia],CurPos+onetick);
ObjectSet("rec"+"Azia"+TimeToStr(Time,TIME_DATE)+CurPos, OBJPROP_COLOR, Olive);
}//if
if(ObjectFind("rec"+"Europa"+TimeToStr(Time,TIME_DATE)+CurPos) == -1 && MySizeEuropa!=0) {
ObjectCreate("rec"+"Europa"+TimeToStr(Time,TIME_DATE)+CurPos, OBJ_RECTANGLE, 0, Time[i-MySizeAzia], CurPos,Time[i-MySizeAzia-MySizeEuropa],CurPos+onetick);
ObjectSet("rec"+"Europa"+TimeToStr(Time,TIME_DATE)+CurPos, OBJPROP_COLOR, Navy);
}//if
if(ObjectFind("rec"+"America"+TimeToStr(Time,TIME_DATE)+CurPos) == -1 && MySizeAmerica!=0) {
ObjectCreate("rec"+"America"+TimeToStr(Time,TIME_DATE)+CurPos, OBJ_RECTANGLE, 0, Time[i-MySizeAzia-MySizeEuropa], CurPos,Time[i-MySizeAzia-MySizeEuropa-MySizeAmerica],CurPos+onetick);
ObjectSet("rec"+"America"+TimeToStr(Time,TIME_DATE)+CurPos, OBJPROP_COLOR, Maroon);
}//if
CurPos=CurPos+onetick;
}//while
ObjectCreate("mediana"+TimeToStr(Time,TIME_DATE), OBJ_RECTANGLE, 0, Time, Mediana,Time[i+10],Mediana+onetick);
ObjectSet("mediana"+TimeToStr(Time,TIME_DATE), OBJPROP_STYLE, STYLE_SOLID);
ObjectSet("mediana"+TimeToStr(Time,TIME_DATE), OBJPROP_COLOR,White);
BACK=i+1;
}//if
i++;
if (i>=Bars) return(0);
}//while
}//for
//----
return(0);
}
//+------------------------------------------------------------------+
发表于:2007-11-23 13:19只看该作者
2楼
不好意思,俺只是三脚猫的水平,只会搞一些简单的事情,你的问题俺解决不了,惭愧:L。只有等高手来帮你解决了
3楼
韬客社区www.talkfx.co