[MT4指标]Turnal_0.5指标源码
mt4的源码 如果不行 再花钱买原版加密的mt4的吧/*
Generated by EX4-TO-MQ4 decompiler V4.0.224.1
Website: http://purebeam.biz
E-mail : [email protected]
*/
#property copyright "Koy"
#property link ""
extern double lots = 0.1;
extern double takeprofitpercent = 0.3;
extern double stoplosepercent = 0.5;
extern bool TradeEnable = TRUE;
double g_slippage_104 = 3.0;
double gd_112;
double gd_120;
double gd_128;
double gd_unused_136;
double gd_144;
double g_price_152;
double g_price_160;
double gd_168;
double gd_176;
double gd_184;
double gd_192;
double g_close_200 = 0.0;
int g_hour_212;
int gi_unused_216;
int g_ticket_220 = 0;
int g_ticket_224 = 0;
bool gi_228 = FALSE;
bool gi_232 = TRUE;
bool gi_236 = FALSE;
int g_time_240 = 0;
bool isNewBar() {
datetime l_time_0 = Time[0];
if (g_time_240 != l_time_0) {
g_time_240 = l_time_0;
return (TRUE);
}
return (FALSE);
}
double CalcFormerPivot() {
double ld_ret_0 = 0;
for (int li_8 = 1; li_8 <= 3; li_8++) ld_ret_0 += Close[li_8];
ld_ret_0 /= 3.0;
return (ld_ret_0);
}
void OppositeHandle() {
if (OrdersTotal() > 3 || gi_236 == TRUE) return;
if (Bid > gd_168 && Bid < g_price_152 && gd_120 <= 0.0) {
g_ticket_220 = OrderSend(Symbol(), OP_SELL, lots, Bid, g_slippage_104, NormalizeDouble(Bid + gd_112 * stoplosepercent, Digits), NormalizeDouble(Bid - gd_112 * takeprofitpercent, Digits), 0, 12345, 0, LawnGreen);
if (g_ticket_220 < 0) {
Comment("OrderSend failed: ", GetLastError());
Sleep(300000);
} else {
gi_unused_216 = -1;
gi_236 = TRUE;
}
}
if (Ask < gd_176 && Ask > g_price_160 && gd_120 >= 0.0) {
g_ticket_220 = OrderSend(Symbol(), OP_BUY, lots, Ask, g_slippage_104, NormalizeDouble(Ask - gd_112 * stoplosepercent, Digits), NormalizeDouble(Ask + gd_112 * takeprofitpercent, Digits), 0, 12345, 0, LawnGreen);
if (g_ticket_220 < 0) {
Comment("OrderSend failed: ", GetLastError());
Sleep(300000);
} else {
gi_unused_216 = -1;
gi_236 = TRUE;
}
}
}
void ThirdToFifth() {
double ld_0 = CalcFormerPivot();
OppositeHandle();
}
int GetLastCloseHour() {
int l_datetime_0;
if (OrderSelect(g_ticket_224, SELECT_BY_TICKET, MODE_HISTORY)) {
l_datetime_0 = OrderCloseTime();
if (l_datetime_0 > 0) g_hour_212 = TimeHour(l_datetime_0);
return (1);
}
return (0);
}
double CalcCurrScale(int ai_0, double ada_4, double ada_8) {
double ld_12 = 0;
double ld_20 = 0;
for (int li_28 = 1; li_28 <= 10; li_28++) ld_12 += (ada_4[li_28 + ai_0] - (ada_8[li_28 + ai_0])) * (ada_4[li_28 + ai_0] - (ada_8[li_28 + ai_0]));
ld_12 /= 10.0;
ld_20 = MathSqrt(ld_12);
return (1.0 * ld_20);
}
double Calc2BarTrend(int ai_0, double ada_4, double ada_8) {
double ld_12;
double ld_20;
double ld_ret_28;
if (ada_4[ai_0] > ada_4[ai_0 + 1] && ada_8[ai_0] >= ada_8[ai_0 + 1]) {
ld_12 = ada_4[ai_0] - (ada_4[ai_0 + 1]);
ld_20 = ada_8[ai_0] - (ada_8[ai_0 + 1]);
if (MathAbs(ld_12) > MathAbs(ld_20)) ld_ret_28 = ld_20;
else ld_ret_28 = ld_12;
if (ld_ret_28 * gd_144 < 0.0) ld_ret_28 = 0.0;
return (ld_ret_28);
}
if (ada_4[ai_0] > ada_4[ai_0 + 1] && ada_8[ai_0] < ada_8[ai_0 + 1]) {
ld_ret_28 = 0;
return (ld_ret_28);
}
if (ada_4[ai_0] <= ada_4[ai_0 + 1] && ada_8[ai_0] < ada_8[ai_0 + 1]) {
ld_12 = ada_4[ai_0] - (ada_4[ai_0 + 1]);
ld_20 = ada_8[ai_0] - (ada_8[ai_0 + 1]);
if (MathAbs(ld_12) > MathAbs(ld_20)) ld_ret_28 = ld_20;
else ld_ret_28 = ld_12;
if (ld_ret_28 * gd_144 < 0.0) ld_ret_28 = 0.0;
return (ld_ret_28);
}
if (ada_4[ai_0] < ada_4[ai_0 + 1] && ada_8[ai_0] >= ada_8[ai_0 + 1]) {
ld_ret_28 = 0;
return (ld_ret_28);
}
return (0.0);
}
double Calc2BarPivot(int ai_0, double ad_4, double ad_12, double ada_20, double ada_24, double ada_28) {
double ld_ret_32;
if (ad_12 != 0.0) {
ld_ret_32 = ad_12 + ad_4;
return (ld_ret_32);
}
if (ada_20[ai_0] - ada_24[ai_0] >= ada_20[ai_0 + 1] - (ada_24[ai_0 + 1])) ld_ret_32 = ada_28[ai_0];
else ld_ret_32 = ada_28[ai_0 + 1] + ad_4;
return (ld_ret_32);
}
int CheckSpike(int ai_unused_0, double ad_unused_4, double ad_unused_12, double ada_20[40], double ada_24[40]) {
bool li_ret_28 = FALSE;
gd_144 = 0;
for (int li_32 = 1; li_32 <= 6; li_32++) {
if (Close[li_32] < g_price_160 || g_price_160 - Low[li_32] > gd_112 / 4.0) {
li_ret_28 = TRUE;
gd_144 = -1;
break;
}
if (Close[li_32] > g_price_152 || High[li_32] - g_price_152 > gd_112 / 4.0) {
li_ret_28 = TRUE;
gd_144 = 1;
break;
}
}
int l_count_36 = 0;
for (li_32 = 1; li_32 <= 6; li_32++)
if (Close[li_32] > g_price_152 - gd_112 / 2.0) l_count_36++;
if (l_count_36 >= 5) {
li_ret_28 = TRUE;
gd_144 = 1;
}
l_count_36 = 0;
for (li_32 = 1; li_32 <= 6; li_32++)
if (Close[li_32] < g_price_160 + gd_112 / 2.0) l_count_36++;
if (l_count_36 >= 5) {
li_ret_28 = TRUE;
gd_144 = -1;
}
return (li_ret_28);
}
void CalcTrend() {
double lda_0[40];
double lda_4[40];
double lda_8[40];
double lda_12[40];
double lda_16[40];
double lda_20[6];
double lda_24[6];
double ld_36;
double ld_44;
double ld_60;
ArrayInitialize(lda_0, 0.0);
ArrayInitialize(lda_4, 0.0);
ArrayInitialize(lda_16, 0.0);
for (int li_28 = 39; li_28 >= 0; li_28--) {
for (int l_index_32 = 0; l_index_32 < 6; l_index_32++) {
lda_20[l_index_32] = High[6 * li_28 + 1 + l_index_32];
lda_24[l_index_32] = Low[6 * li_28 + 1 + l_index_32];
}
lda_0[li_28] = lda_20[ArrayMaximum(lda_20, 6, 0)];
lda_4[li_28] = lda_24[ArrayMinimum(lda_24, 6, 0)];
ld_36 = 0.5;
ld_44 = 0;
for (l_index_32 = 0; l_index_32 < 6; l_index_32++) {
ld_36 = 0.5;
if (l_index_32 < 3) ld_36 = 1.0;
if (l_index_32 < 1) ld_36 = 2;
lda_16[li_28] += Close[l_index_32] * ld_36;
ld_44 += ld_36;
}
lda_16[li_28] = lda_16[li_28] / ld_44;
lda_8[li_28] = Open[6 * li_28 + 6];
lda_12[li_28] = Close[6 * li_28 + 1];
}
int li_52 = 1;
if (gi_232) {
for (int li_56 = 15; li_56 >= 0; li_56--) {
gd_112 = CalcCurrScale(li_56, lda_0, lda_4);
if (g_close_200 != 0.0) li_52 = CheckSpike(li_56, g_close_200 + gd_112 / 2.0, g_close_200 - gd_112 / 2.0, lda_0, lda_4);
if (li_52 == 1) {
gd_120 = Calc2BarTrend(li_56, lda_0, lda_4);
if (NormalizeDouble(MathAbs(gd_120), Digits) >= NormalizeDouble(gd_112 / 3.0, Digits)) gd_120 = gd_112 / 3.0 * gd_120 / MathAbs(gd_120);
g_close_200 = 0;
}
g_close_200 = Calc2BarPivot(li_56, gd_120, g_close_200, lda_0, lda_4, lda_16);
g_price_152 = g_close_200 + gd_112 / 2.0;
g_price_160 = g_close_200 - gd_112 / 2.0;
}
gd_128 = gd_120 / 6.0;
gd_184 = g_price_152 - gd_120 / 2.0;
gd_192 = g_price_160 - gd_120 / 2.0;
gd_168 = gd_184 - 0.2 * gd_112;
gd_176 = gd_192 + 0.2 * gd_112;
} else {
li_52 = CheckSpike(1, g_close_200 + gd_112 / 2.0, g_close_200 - gd_112 / 2.0, lda_0, lda_4);
if (li_52 == 1) {
gd_112 = CalcCurrScale(0, lda_0, lda_4);
gd_120 = Calc2BarTrend(0, lda_0, lda_4);
ld_60 = 100.0 * iMACD(NULL, 0, 8, 16, 30, PRICE_MEDIAN, MODE_MAIN, 1) - 100.0 * iMACD(NULL, 0, 8, 16, 30, PRICE_MEDIAN, MODE_MAIN, 2);
g_close_200 = 0;
g_close_200 = Calc2BarPivot(0, gd_120, g_close_200, lda_0, lda_4, lda_16);
if (ld_60 * gd_120 <= 0.0) {
gd_120 = 0.0;
gd_112 = 1.0 * gd_112;
g_close_200 = Close[1];
}
g_price_152 = g_close_200 + gd_112 / 2.0;
g_price_160 = g_close_200 - gd_112 / 2.0;
gd_128 = gd_120 / 6.0;
gd_184 = g_price_152 - gd_120 / 2.0;
gd_192 = g_price_160 - gd_120 / 2.0;
gd_168 = gd_184 - gd_112 / 4.0;
gd_176 = gd_192 + gd_112 / 4.0;
} else {
gd_112 = CalcCurrScale(0, lda_0, lda_4);
g_close_200 = Calc2BarPivot(li_56, gd_120, g_close_200, lda_0, lda_4, lda_16);
g_price_152 = g_close_200 + gd_112 / 2.0;
g_price_160 = g_close_200 - gd_112 / 2.0;
gd_128 = gd_120 / 6.0;
gd_184 = g_price_152 - gd_120 / 2.0;
gd_192 = g_price_160 - gd_120 / 2.0;
gd_168 = gd_184 - gd_112 / 4.0;
gd_176 = gd_192 + gd_112 / 4.0;
}
}
gi_232 = FALSE;
}
int init() {
return (0);
}
int deinit() {
return (0);
}
int start() {
string l_name_4;
string l_name_12;
string ls_20;
string ls_28;
if (Bars < 20) return (0);
int li_unused_0 = 1;
if (Hour() == 8 && gi_228 == FALSE) {
gi_236 = FALSE;
gd_unused_136 = gd_120;
CalcTrend();
gi_228 = TRUE;
}
if (Hour() != 8 && gi_228 == TRUE) gi_228 = FALSE;
if (isNewBar()) {
l_name_4 = "P" + Time[0];
l_name_12 = "B" + Time[0];
ls_20 = "e" + Time[0];
ls_28 = "r" + Time[0];
ObjectCreate(l_name_4, OBJ_TREND, 0, Time[1] + 10, g_price_152, Time[0], g_price_152);
ObjectSet(l_name_4, OBJPROP_RAY, FALSE);
ObjectSet(l_name_4, OBJPROP_COLOR, Gold);
ObjectSet(l_name_4, OBJPROP_WIDTH, 5);
ObjectCreate(l_name_12, OBJ_TREND, 0, Time[1] + 10, g_price_160, Time[0], g_price_160);
ObjectSet(l_name_12, OBJPROP_RAY, FALSE);
ObjectSet(l_name_12, OBJPROP_COLOR, Gold);
ObjectSet(l_name_12, OBJPROP_WIDTH, 5);
}
GetLastCloseHour();
ThirdToFifth();
Comment("Please visit: http://turnal.blog.hexun.com/");
return (0);
}
Turnal_0.50~.mq4Turnal_0.50.ex4
2楼
这也是系统不能直接应用到实战的原因,只是定性的检验,也是为讨论可行性才画了黄线
以4小时图为交易判断窗口,则应该以1小时或更小周期选择入场时机
最近2~3天日线为根据,估计今日的活动范围。直观说就是画一对平行线刚好扣住最近2~3天的bar,平行线延长到今天,就是今天的活动范围。所以真实的系统支撑线和压力线通常是斜的,而不是平的
入场信号的第一层筛选,是上升过程接近下平行线,或者下降过程接近上平行线。也就是回调。这是第一种情况,顺势而为
第二种情况,就是平行线是水平的情况,这是震荡,每当接近压力或支撑则做反向
我想一定有很多人和我有相似思路的,所以希望有所借鉴启发,改进压力支撑的计算方法。
阅尽天下指标
搬砖开始,始于2014
发表于:2017-06-17 04:41只看该作者
3楼
6666
韬客社区www.talkfx.co
发表于:2017-08-07 04:53只看该作者
4楼
谢谢分享~~~~~~~~~~~
韬客社区www.talkfx.co