差别
这里会显示出您选择的修订版和当前版本之间的差别。
后一修订版 | 前一修订版 | ||
mt4:mtf_fractals_indicator [2022/10/09 07:53] – 创建 wyrover | mt4:mtf_fractals_indicator [2022/10/09 08:04] (当前版本) – wyrover | ||
---|---|---|---|
行 1: | 行 1: | ||
# MTF Fractals indicator | # MTF Fractals indicator | ||
+ | ![](https:// | ||
+ | MTF_Fractal.mq4 | ||
+ | |||
+ | <code cpp> | ||
+ | // | ||
+ | //| MTF Fractal.mq4 | | ||
+ | //| | ||
+ | //| http:// | ||
+ | // | ||
+ | #property copyright " | ||
+ | #property link " | ||
+ | #property version " | ||
+ | #property indicator_chart_window | ||
+ | #property indicator_buffers 2 | ||
+ | |||
+ | extern string | ||
+ | extern int | ||
+ | extern int | ||
+ | extern color | ||
+ | extern int | ||
+ | extern color | ||
+ | extern int | ||
+ | extern bool Extend_Line | ||
+ | extern bool Extend_Line_to_Background | ||
+ | extern bool Show_Validation_Candle | ||
+ | extern color | ||
+ | extern int | ||
+ | extern int | ||
+ | extern color | ||
+ | extern int | ||
+ | extern int | ||
+ | |||
+ | double UpBuffer[], DoBuffer[], refchk, tempref, level; | ||
+ | int barc; | ||
+ | |||
+ | // | ||
+ | //| INIT | | ||
+ | // | ||
+ | |||
+ | int init() { | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | } | ||
+ | |||
+ | // | ||
+ | //| | ||
+ | // | ||
+ | |||
+ | int deinit() { | ||
+ | for (int i = ObjectsTotal(); | ||
+ | if (StringSubstr(ObjectName(i), | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | |||
+ | | ||
+ | } | ||
+ | |||
+ | // | ||
+ | //| START | | ||
+ | // | ||
+ | |||
+ | int start() { | ||
+ | int i, c, dif; | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | if (barc != Bars || IndicatorCounted() < 0 || tempref != refchk) { | ||
+ | barc = Bars; | ||
+ | refchk = tempref; | ||
+ | } else | ||
+ | return(0); | ||
+ | |||
+ | | ||
+ | |||
+ | if (Fractal_Timeframe <= Period()) Fractal_Timeframe = Period(); | ||
+ | |||
+ | dif = Fractal_Timeframe/ | ||
+ | |||
+ | if (Maxbar > Bars) Maxbar = Bars-10; | ||
+ | |||
+ | for(i = 0; i < Maxbar; i++) { | ||
+ | if (iBarShift(NULL, | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | UpBuffer[i] = iFractals(NULL, | ||
+ | DoBuffer[i] = iFractals(NULL, | ||
+ | } | ||
+ | |||
+ | if (Extend_Line) { | ||
+ | for(i = 0; i < Maxbar; i++) { | ||
+ | if (UpBuffer[i] > 0) { | ||
+ | level = UpBuffer[i]; | ||
+ | for (c = i; c > 0; c--) { | ||
+ | if ((Open[c] < level && Close[c] > level) || (Open[c] > level && Close[c] < level)) | ||
+ | break; | ||
+ | if (Open[c] <= level && Close[c] <= level && Open[c-1] >= level && Close[c-1] >= level) | ||
+ | break; | ||
+ | if (Open[c] >= level && Close[c] >= level && Open[c-1] <= level && Close[c-1] <= level) | ||
+ | break; | ||
+ | } | ||
+ | DrawLine (" | ||
+ | if (Show_Validation_Candle) UpBuffer[i-2*dif] = level; | ||
+ | i += dif; | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | for(i = 0; i < Maxbar; i++) { | ||
+ | if (DoBuffer[i] > 0) { | ||
+ | level = DoBuffer[i]; | ||
+ | for (c = i; c > 0; c--) { | ||
+ | if ((Open[c] < level && Close[c] > level) || (Open[c] > level && Close[c] < level)) | ||
+ | break; | ||
+ | if (Open[c] <= level && Close[c] <= level && Open[c-1] >= level && Close[c-1] >= level) | ||
+ | break; | ||
+ | if (Open[c] >= level && Close[c] >= level && Open[c-1] <= level && Close[c-1] <= level) | ||
+ | break; | ||
+ | } | ||
+ | DrawLine (" | ||
+ | if (Show_Validation_Candle) DoBuffer[i-2*dif] = level; | ||
+ | i += dif; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | | ||
+ | } | ||
+ | // | ||
+ | //| DRAW LINE | | ||
+ | // | ||
+ | |||
+ | void DrawLine (string dir, int i, int c, double lev, bool back, color col, int width, int style) { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | </ |