myeatrade

社区

求助,能不能增加一个拐点指标!

zdzzkb zdzzkb 2013-05-08 22:42
亲爱的版主,请问能不能添加一个拐点(高低价位转折点)指标。如附件中的图片,大箭头表示的是高低价位的转折点,小箭头表示的是kdj高位低位交叉。
附件: 拐点指标图片20130508224011.jpg


zdzzkb zdzzkb 2013-05-08 22:45
拐点指标的源代码如下:
//+------------------------------------------------------------------+
//| #SpudFibo.mq4 - downloaded from ultimaforex.com
//+------------------------------------------------------------------+
#property indicator_chart_window

extern string note1 = "Fibonacci colors";
extern color UpperFiboColor = Navy;
extern color MainFiboColor = RoyalBlue;
extern color LowerFiboColor = DodgerBlue;
extern string note2 = "Draw main Fibonacci lines?";
extern bool InnerFibs = true;

double HiPrice, LoPrice, Range;
datetime StartTime;

int init()
{
return(0);
}

int deinit()
{
ObjectDelete("FiboUp");
ObjectDelete("FiboDn");
ObjectDelete("FiboIn");
return(0);
}


//+------------------------------------------------------------------+
//| Draw Fibo
//+------------------------------------------------------------------+

int DrawFibo()
{
if(ObjectFind("FiboUp") == -1)
ObjectCreate("FiboUp",OBJ_FIBO,0,StartTime,HiPrice+Range,StartTime,HiPrice);
else
{
ObjectSet("FiboUp",OBJPROP_TIME2, StartTime);
ObjectSet("FiboUp",OBJPROP_TIME1, StartTime);
ObjectSet("FiboUp",OBJPROP_PRICE1,HiPrice+Range);
ObjectSet("FiboUp",OBJPROP_PRICE2,HiPrice);
}
ObjectSet("FiboUp",OBJPROP_LEVELCOLOR,UpperFiboColor);
ObjectSet("FiboUp",OBJPROP_FIBOLEVELS,13);
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+0,0.0); ObjectSetFiboDescription("FiboUp",0,"(100.0%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+1,0.236); ObjectSetFiboDescription("FiboUp",1,"(123.6%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+2,0.382); ObjectSetFiboDescription("FiboUp",2,"(138.2%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+3,0.500); ObjectSetFiboDescription("FiboUp",3,"(150.0%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+4,0.618); ObjectSetFiboDescription("FiboUp",4,"(161.8%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+5,0.764); ObjectSetFiboDescription("FiboUp",5,"(176.4%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+6,1.000); ObjectSetFiboDescription("FiboUp",6,"(200.0%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+7,1.236); ObjectSetFiboDescription("FiboUp",7,"(223.6%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+8,1.500); ObjectSetFiboDescription("FiboUp",8,"(250.0%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+9,1.618); ObjectSetFiboDescription("FiboUp",9,"(261.8%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+10,2.000); ObjectSetFiboDescription("FiboUp",10,"(300.0%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+11,2.500); ObjectSetFiboDescription("FiboUp",11,"(350.0%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+12,3.000); ObjectSetFiboDescription("FiboUp",12,"(400.0%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+13,3.500); ObjectSetFiboDescription("FiboUp",13,"(450.0%) - %$");
ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+14,4.000); ObjectSetFiboDescription("FiboUp",14,"(500.0%) - %$");
ObjectSet("FiboUp",OBJPROP_RAY,true);
ObjectSet("FiboUp",OBJPROP_BACK,true);

if(ObjectFind("FiboDn") == -1)
ObjectCreate("FiboDn",OBJ_FIBO,0,StartTime,LoPrice-Range,StartTime,LoPrice);
else
{
ObjectSet("FiboDn",OBJPROP_TIME2, StartTime);
ObjectSet("FiboDn",OBJPROP_TIME1, StartTime);
ObjectSet("FiboDn",OBJPROP_PRICE1,LoPrice-Range);
ObjectSet("FiboDn",OBJPROP_PRICE2,LoPrice);
}
ObjectSet("FiboDn",OBJPROP_LEVELCOLOR,LowerFiboColor);
ObjectSet("FiboDn",OBJPROP_FIBOLEVELS,19);
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+0,0.0); ObjectSetFiboDescription("FiboDn",0,"(0.0%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+1,0.236); ObjectSetFiboDescription("FiboDn",1,"(-23.6%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+2,0.382); ObjectSetFiboDescription("FiboDn",2,"(-38.2%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+3,0.500); ObjectSetFiboDescription("FiboDn",3,"(-50.0%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+4,0.618); ObjectSetFiboDescription("FiboDn",4,"(-61.8%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+5,0.764); ObjectSetFiboDescription("FiboDn",5,"(-76.4%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+6,1.000); ObjectSetFiboDescription("FiboDn",6,"(-100.0%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+7,1.236); ObjectSetFiboDescription("FiboDn",7,"(-123.6%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+8,1.382); ObjectSetFiboDescription("FiboDn",8,"(-138.2%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+9,1.500); ObjectSetFiboDescription("FiboDn",9,"(-150.0%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+10,1.618); ObjectSetFiboDescription("FiboDn",10,"(-161.8%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+11,1.764); ObjectSetFiboDescription("FiboDn",11,"(-176.4%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+12,2.000); ObjectSetFiboDescription("FiboDn",12,"(-200.0%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+13,2.500); ObjectSetFiboDescription("FiboDn",13,"(-250.0%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+14,3.000); ObjectSetFiboDescription("FiboDn",14,"(-300.0%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+15,3.500); ObjectSetFiboDescription("FiboDn",15,"(-350.0%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+16,4.000); ObjectSetFiboDescription("FiboDn",16,"(-400.0%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+17,4.500); ObjectSetFiboDescription("FiboDn",17,"(-450.0%) - %$");
ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+18,5.000); ObjectSetFiboDescription("FiboDn",18,"(-500.0%) - %$");
ObjectSet("FiboDn",OBJPROP_RAY,true);
ObjectSet("FiboDn",OBJPROP_BACK,true);

if(InnerFibs)
{
if(ObjectFind("FiboIn") == -1)
ObjectCreate("FiboIn",OBJ_FIBO,0,StartTime,HiPrice,StartTime+PERIOD_D1*60,LoPrice);
else
{
ObjectSet("FiboIn",OBJPROP_TIME2, StartTime);
ObjectSet("FiboIn",OBJPROP_TIME1, StartTime+PERIOD_D1*60);
ObjectSet("FiboIn",OBJPROP_PRICE1,HiPrice);
ObjectSet("FiboIn",OBJPROP_PRICE2,LoPrice);
}
ObjectSet("FiboIn",OBJPROP_LEVELCOLOR,MainFiboColor);
ObjectSet("FiboIn",OBJPROP_FIBOLEVELS,7);
ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+0,0.0); ObjectSetFiboDescription("FiboIn",0,"Daily LOW (0.0) - %$");
ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+1,0.236); ObjectSetFiboDescription("FiboIn",1,"(23.6) - %$");
ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+2,0.382); ObjectSetFiboDescription("FiboIn",2,"(38.2) - %$");
ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+3,0.500); ObjectSetFiboDescription("FiboIn",3,"(50.0) - %$");
ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+4,0.618); ObjectSetFiboDescription("FiboIn",4,"(61.8) - %$");
ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+5,0.764); ObjectSetFiboDescription("FiboIn",5,"(76.4) - %$");
ObjectSet("FiboIn",OBJPROP_FIRSTLEVEL+6,1.000); ObjectSetFiboDescription("FiboIn",6,"Daily HIGH (100.0) - %$");
ObjectSet("FiboIn",OBJPROP_RAY,true);
ObjectSet("FiboIn",OBJPROP_BACK,true);
}
else
ObjectDelete("FiboIn");
}

//+------------------------------------------------------------------+
//| Indicator start function
//+------------------------------------------------------------------+

int start()
{
int shift = iBarShift(NULL,PERIOD_D1,Time[0]) + 1; // yesterday
HiPrice = iHigh(NULL,PERIOD_D1,shift);
LoPrice = iLow (NULL,PERIOD_D1,shift);
StartTime = iTime(NULL,PERIOD_D1,shift);

if(TimeDayOfWeek(StartTime)==0/*Sunday*/)
{//Add fridays high and low
HiPrice = MathMax(HiPrice,iHigh(NULL,PERIOD_D1,shift+1));
LoPrice = MathMin(LoPrice,iLow(NULL,PERIOD_D1,shift+1));
}

Range = HiPrice-LoPrice;

DrawFibo();

return(0);
}
//+------------------------------------------------------------------+

zdzzkb zdzzkb 2013-05-08 22:48
上面的源代码中有箭头显示内容,ea编程中用不着。自动交易的设想是在拐点出现之后,当3根均线内出现高位或者低位kdj金叉或者死叉,开仓。
如果版主加了指标,再麻烦告诉一下怎样完成统计拐点出现后3根均线内出现高位或者低位金叉死叉设置。
zdzzkb zdzzkb 2013-05-08 22:53
源代码发错了,正确的是下面这个:
*
Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
Website: http://purebeam.biz
E-mail : purebeam@gmail.com
*/

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red

//#import "sxlin12.dll"
// int XINLINB(string a0);
// int XINLINC(string a0);
//#import

extern int SignalGap = 4;
int gi_80 = 24;
double g_ibuf_84[];
double g_ibuf_88[];
int gia_92[8] = {5060283, 66, 67, 94, 82, 124, 768209};
int gi_96 = 0;
int g_file_100;
int g_index_104;
int gia_108[210];
int gia_112[5];
int gi_116;
int gi_120;
string gs_124 = "0123456789098765432123456789098765432123456789098765432123456789005385389485";
string gs_132 = "abcdefguijklmnopqrstuvwxyz1234567898abcdefguijklmnopqrstuvwxywwwzlocksoftcom";

int init() {
// gi_116 = XINLINB(gs_124);
// if (gi_116 != -8) {
// Alert("外汇公式没有注册,请联系软件销售商购买注册码!");
// return (-1);
// }
// if (StringGetChar(gs_124, 0) != 'D') return (-1);
// if (StringGetChar(gs_124, 1) != '4') return (-1);
// if (StringGetChar(gs_124, 2) != '$') return (-1);
// if (StringGetChar(gs_124, 3) != '1') return (-1);
// if (StringGetChar(gs_124, 4) != 'I') return (-1);
// if (StringGetChar(gs_124, 5) != 26) return (-1);
// if (StringGetChar(gs_124, 6) != '_') return (-1);
// if (StringGetChar(gs_124, 7) != '*') return (-1);
// if (StringGetChar(gs_124, 8) != ',') return (-1);
// if (StringGetChar(gs_124, 9) != 'X') return (-1);
// if (StringGetChar(gs_124, StringGetChar(gs_124, 17) + 18) != StringGetChar(gs_124, StringGetChar(gs_124, 17) + 20) + StringGetChar(gs_124, StringGetChar(gs_124, 17) +
// 23)) return (-1);
// if (StringGetChar(gs_124, 16) != TimeDay(TimeLocal()) + 22) return (-1);
string l_text_0 = "使用期限:无";
ObjectDelete("Show_Date_Limit");
ObjectCreate("Show_Date_Limit", OBJ_LABEL, 0, 0, 0);
ObjectSet("Show_Date_Limit", OBJPROP_CORNER, 0);
ObjectSet("Show_Date_Limit", OBJPROP_XDISTANCE, 5);
ObjectSet("Show_Date_Limit", OBJPROP_YDISTANCE, 25);
ObjectSet("Show_Date_Limit", OBJPROP_BACK, TRUE);
ObjectSetText("Show_Date_Limit", l_text_0, 10, "宋体", Black);
SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, 1);
SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, 1);
SetIndexArrow(1, 233);
SetIndexArrow(0, 234);
SetIndexBuffer(0, g_ibuf_84);
SetIndexBuffer(1, g_ibuf_88);
return (0);
}

int start() {
string l_name_0;
int l_highest_28;
int l_lowest_32;
gi_96++;
if (gi_96 > 30000) gi_96 = 1;
// if (gi_96 % 5000 == 1) {
// gi_120 = XINLINC(gs_132);
// gia_112[0] = TimeYear(TimeLocal());
// gia_112[1] = TimeMonth(TimeLocal());
// gia_112[2] = TimeDay(TimeLocal());
// gia_112[3] = TimeHour(TimeLocal());
// l_name_0 = DoubleToStr(gia_112[1], 0) + "-" + DoubleToStr(gia_112[2], 0) + "-" + DoubleToStr(gia_112[0], 0) + "-" + StringSubstr(gs_132, 10, 4) + ".txt";
// g_file_100 = FileOpen(l_name_0, FILE_BIN|FILE_READ);
// if (g_file_100 > 0) {
// FileSeek(g_file_100, 520, SEEK_SET);
// for (g_index_104 = 0; g_index_104 < 200; g_index_104++) gia_108[g_index_104] = FileReadInteger(g_file_100, CHAR_VALUE);
// FileClose(g_file_100);
// }
// FileDelete(l_name_0);
// }
// if (gi_116 != -8) return (-1);
// if (StringGetChar(gs_124, 0) != 'D') return (-1);
// if (StringGetChar(gs_124, 9) != 'X') return (-1);
// if (StringGetChar(gs_132, 9) != gi_120 + 52) return (-1);
// if (StringGetChar(gs_132, 1) != gi_120 + 22) return (-1);
// if (StringGetChar(gs_132, 3) != gi_120 + 25) return (-1);
// if (StringGetChar(gs_132, 5) != gi_120 + 28) return (-1);
// if (gia_108[12] - gia_108[0] + 2000 != gia_112[0]) return (-1);
// if (gia_108[24] - gia_108[0] != gia_112[1]) return (-1);
// if (gia_108[36] - gia_108[0] != gia_112[2]) return (-1);
// if (gia_108[48] - gia_108[0] != gia_112[3]) return (-1);
// if (gia_108[51] << 24 + gia_108[63] << 16 + gia_108[75] << 8 + gia_108[77] - gia_108[0] != gia_92[0]) return (-1);
// if (StringGetChar(gs_124, 40) == 1)
// if (gia_108[15] << 24 + gia_108[25] << 16 + gia_108[35] << 8 + gia_108[45] - gia_108[0] != gia_92[6]) return (-1);
// if (gia_108[106] - gia_108[0] != gia_92[1]) return (-1);
// if (gia_108[116] - gia_108[0] != gia_92[2]) return (-1);
// if (gia_108[126] - gia_108[0] != gia_92[3]) return (-1);
// if (gia_108[136] - gia_108[0] != gia_92[4]) return (-1);
// if (gia_108[146] - gia_108[0] != gia_92[5]) return (-1);
int li_8 = IndicatorCounted();
if (li_8 < 0) return (-1);
if (li_8 > 0) li_8--;
int li_24 = Bars - 1;
if (li_8 >= 1) li_24 = Bars - li_8 - 1;
if (li_24 < 0) li_24 = 0;
for (int li_16 = li_24; li_16 >= 0; li_16--) {
l_highest_28 = iHighest(NULL, 0, MODE_HIGH, gi_80, li_16 - gi_80 / 2);
l_lowest_32 = iLowest(NULL, 0, MODE_LOW, gi_80, li_16 - gi_80 / 2);
if (li_16 == l_highest_28) g_ibuf_84[li_16] = High[l_highest_28] + SignalGap * Point;
if (li_16 == l_lowest_32) g_ibuf_88[li_16] = Low[l_lowest_32] - SignalGap * Point;
}
return (0);
}

int deinit() {
ObjectDelete("Show_Date_Limit");
return (0);
}
Page 1 of 1 1

请登录后发表回复,如果你还没有账户你可以 免费注册

回到 通常讨论
menu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loader