mql4:编码空缓冲区(mql4 : coding empty buffer in line)

编程入门 行业动态 更新时间:2024-10-27 17:17:06
mql4:编码空缓冲区(mql4 : coding empty buffer in line)

所以我做了一些编码,现在有空缓冲区我想问一下如何感受EMPTY_BUFFER所以如果使用IF line == EMPTY BUFFER那么FILL IT..i已经尝试了一些编码但仍然没有填充空缓冲区

#property strict #property indicator_level1 75.0 #property indicator_level2 25.0 #property indicator_levelcolor LimeGreen #property indicator_levelwidth 1 #property indicator_levelstyle 0 #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 Green #property indicator_color2 Red #property indicator_color3 Blue #property indicator_color4 Green #property indicator_color5 Red extern string howtouse= "scalping in m5"; extern string contact = "reiz_gamer@yahoo.co.id"; extern string created = "created by reza rahmad"; extern int barsToProcess=100; double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double buy[]; double sell[]; int values; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer3); SetIndexStyle(3,DRAW_NONE); SetIndexBuffer(3,buy); SetIndexEmptyValue(3,0.0); SetIndexStyle(4,DRAW_ARROW,EMPTY,3,Magenta); SetIndexArrow(4,234); SetIndexBuffer(4,sell); SetIndexEmptyValue(4,0.0); // initialization of the generator of random numbers ObjectCreate("sig",OBJ_TEXT,0,0,0,0,0); ObjectSetText("sig","TAHAN",10,"Times New Roman",Magenta); ObjectCreate("sig1",OBJ_LABEL,0,0,0,0,0); ObjectSet("sig1",OBJPROP_XDISTANCE,750); ObjectSet("sig1",OBJPROP_YDISTANCE,20); ObjectSetText("sig1","created by reza rahmad scalping use in tf 5m",10,"Times New Roman",Magenta); //--- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int deinit() { ObjectDelete("tare"); ObjectDelete("tarmid"); ObjectDelete("tare1"); ObjectDelete("sig"); ObjectDelete("sig1"); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(), limit; if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; if(limit>barsToProcess) limit=barsToProcess; for(int i=0;i<limit;i++) { double main5 = iStochastic( NULL, PERIOD_M5, 14, 3, 3, MODE_SMMA, 0, MODE_MAIN, i ); double signal5 = iStochastic( NULL, PERIOD_M5, 14, 3, 3, MODE_SMMA, 0, MODE_SIGNAL, i ); double ma20 = iMA( NULL, PERIOD_M5, 20, 0, MODE_SMA, PRICE_CLOSE, 0 ); double ma5 = iMA( NULL, PERIOD_M5, 5, 0, MODE_SMA, PRICE_CLOSE, 0 ); ExtMapBuffer1[i] = EMPTY_VALUE; ExtMapBuffer2[i] = EMPTY_VALUE; if ( main5 > signal5 && High[0] > ma5 ){ ExtMapBuffer1[i] = ( ( Close[i+1] + Close[i] ) / 2 ); values = 1; } if ( main5 < signal5 && Low[0] < ma5 ){ ExtMapBuffer2[i] = ( ( Close[i+1] + Close[i] ) / 2 ); values = 2; }

图片示例

so I make some coding and now have empty buffer I want to ask how to feel EMPTY_BUFFER so if use IF line == EMPTY BUFFER then FILL IT..i already try some coding but still not fill the empty buffer

#property strict #property indicator_level1 75.0 #property indicator_level2 25.0 #property indicator_levelcolor LimeGreen #property indicator_levelwidth 1 #property indicator_levelstyle 0 #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 Green #property indicator_color2 Red #property indicator_color3 Blue #property indicator_color4 Green #property indicator_color5 Red extern string howtouse= "scalping in m5"; extern string contact = "reiz_gamer@yahoo.co.id"; extern string created = "created by reza rahmad"; extern int barsToProcess=100; double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double buy[]; double sell[]; int values; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer3); SetIndexStyle(3,DRAW_NONE); SetIndexBuffer(3,buy); SetIndexEmptyValue(3,0.0); SetIndexStyle(4,DRAW_ARROW,EMPTY,3,Magenta); SetIndexArrow(4,234); SetIndexBuffer(4,sell); SetIndexEmptyValue(4,0.0); // initialization of the generator of random numbers ObjectCreate("sig",OBJ_TEXT,0,0,0,0,0); ObjectSetText("sig","TAHAN",10,"Times New Roman",Magenta); ObjectCreate("sig1",OBJ_LABEL,0,0,0,0,0); ObjectSet("sig1",OBJPROP_XDISTANCE,750); ObjectSet("sig1",OBJPROP_YDISTANCE,20); ObjectSetText("sig1","created by reza rahmad scalping use in tf 5m",10,"Times New Roman",Magenta); //--- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int deinit() { ObjectDelete("tare"); ObjectDelete("tarmid"); ObjectDelete("tare1"); ObjectDelete("sig"); ObjectDelete("sig1"); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(), limit; if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; if(limit>barsToProcess) limit=barsToProcess; for(int i=0;i<limit;i++) { double main5 = iStochastic( NULL, PERIOD_M5, 14, 3, 3, MODE_SMMA, 0, MODE_MAIN, i ); double signal5 = iStochastic( NULL, PERIOD_M5, 14, 3, 3, MODE_SMMA, 0, MODE_SIGNAL, i ); double ma20 = iMA( NULL, PERIOD_M5, 20, 0, MODE_SMA, PRICE_CLOSE, 0 ); double ma5 = iMA( NULL, PERIOD_M5, 5, 0, MODE_SMA, PRICE_CLOSE, 0 ); ExtMapBuffer1[i] = EMPTY_VALUE; ExtMapBuffer2[i] = EMPTY_VALUE; if ( main5 > signal5 && High[0] > ma5 ){ ExtMapBuffer1[i] = ( ( Close[i+1] + Close[i] ) / 2 ); values = 1; } if ( main5 < signal5 && Low[0] < ma5 ){ ExtMapBuffer2[i] = ( ( Close[i+1] + Close[i] ) / 2 ); values = 2; }

picture example

最满意答案

如何理解MQL4自定义指标中的EMPTY_VALUE?

MQL4的约定不是在条形图上绘制/显示CustomIndicator -line-segments,其中CustomIndicator -storageBuffer包含一个特别识别的“ Empty_Value== { EMPTY_VALUE | a value pre-set via SetIndexEmptyValue() } == { EMPTY_VALUE | a value pre-set via SetIndexEmptyValue() }

默认情况下,“ Empty_Value ”为EMPTY_VALUE 。

关键的一步是这个诀窍:

if ( main5 < signal5 && Low[0] < ma5 ){ ExtMapBuffer2[i] = ( ( Close[i+1] + Close[i] ) / 2 ); // .CALC/.STO values = MAIN_UNDER_SIGNAL; // .SET if ( values_PREV!= MAIN_UNDER_SIGNAL ){ // ? WAS A FLIP values_PREV = MAIN_UNDER_SIGNAL; // .SET ExtMapBuffer3[i+1] = ExtMapBuffer1[i+1]; // .STO[i+1] ExtMapBuffer3[i ] = ExtMapBuffer2[i ]; // .STO[i+0] } }

New-MQL4代码的上下文中建议的更改如下:

// ------------------------------------------------------------------------------------ // FOR AN EA-INTEGRATION INTERFACE, ref. below // ------------------------------------------------------------------------------------ #property strict // check this against OnCalculate() syntax requirement #property indicator_separate_window //roperty indicator_level1 75.0 // N/A for aPriceDOMAIN line //roperty indicator_level2 25.0 // N/A for aPriceDOMAIN line //roperty indicator_levelcolor clrLimeGreen //roperty indicator_levelwidth 1 //roperty indicator_levelstyle 0 //roperty indicator_buffers 5 // not used #property indicator_buffers 3 #property indicator_color1 clrGreen #property indicator_color2 clrRed #property indicator_color3 clrDimGray /*roperty indicator_color4 Green // not used #property indicator_color5 Red // not used */ #property description "Scalping in M5 Custom Indicator......................" #property description "How to use it ......................................." #property description "How to setup ........................................" extern string howtouse = "scalping in M5"; // "New"-MQL4 shows comments in dialog box extern string contact = "reiz_gamer@yahoo.co.id"; // Contact Email extern string created = "created by reza rahmad"; // copyright notice extern int barsToProcess = 100; // Bars To Process ( Depth ) double ExtMapBuffer1[], ExtMapBuffer2[], ExtMapBuffer3[]; double buy[]; double sell[]; int values, values_PREV = EMPTY; // <STATE-FULL>-logic #define MAIN_ABOVE_SIGNAL 1 #define MAIN_UNDER_SIGNAL 2 //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { IndicatorShortName( "SigREZ( " + DoubleToStr( barsToProcess, 0 ) + " )"); IndicatorDigits( Digits + 1 ); // override default decimal points // to be distinguishable once AVG(Close1,Close0) values are calculated SetIndexStyle( 0, DRAW_LINE ); // MAIN_ABOVE_SIGNAL SetIndexBuffer( 0, ExtMapBuffer1 ); // segments for values == 1 SetIndexDrawBegin( 0, barsToProcess ); SetIndexStyle( 1, DRAW_LINE ); // MAIN_UNDER_SIGNAL SetIndexBuffer( 1, ExtMapBuffer2 ); // segments for values == 2 SetIndexDrawBegin( 1, barsToProcess ); SetIndexStyle( 2, DRAW_LINE ); // EMPTY_SEGMENTs SetIndexBuffer( 2, ExtMapBuffer3 ); SetIndexDrawBegin( 2, barsToProcess ); /* SetIndexStyle( 3, DRAW_NONE ); // not used SetIndexBuffer( 3, buy ); SetIndexEmptyValue( 3, 0.0 ); SetIndexStyle( 4, DRAW_ARROW, EMPTY, 3, Magenta ); SetIndexArrow( 4, 234 ); SetIndexBuffer( 4, sell ); SetIndexEmptyValue( 4, 0.0 ); */ // ---------------------------------------------------------------------------------- // initialization of the generator of random numbers // ---------------------------------------------------------------------------------- ObjectCreate( "sig", OBJ_TEXT, 0, 0, 0, 0, 0 ); ObjectSetText( "sig", "TAHAN", 10, "Times New Roman", Magenta ); ObjectCreate( "sig1", OBJ_LABEL, 0, 0, 0, 0, 0 ); ObjectSet( "sig1", OBJPROP_XDISTANCE, 750 ); ObjectSet( "sig1", OBJPROP_YDISTANCE, 20 ); ObjectSetText( "sig1", "created by reza rahmad scalping use in tf 5m", 10, "Times New Roman", Magenta ); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int deinit() { ObjectDelete( "tare" ); ObjectDelete( "tarmid" ); ObjectDelete( "tare1" ); ObjectDelete( "sig" ); ObjectDelete( "sig1" ); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int limit = Bars, counted_bars = IndicatorCounted(); if ( counted_bars > 0 ) counted_bars--; limit -= counted_bars; if ( limit > barsToProcess ) limit = barsToProcess; for ( int i = 0; i < limit; i++ ) { double main5 = iStochastic( NULL, PERIOD_M5, 14, 3, 3, MODE_SMMA, 0, MODE_MAIN, i ); double signal5 = iStochastic( NULL, PERIOD_M5, 14, 3, 3, MODE_SMMA, 0, MODE_SIGNAL, i ); double ma20 = iMA( NULL, PERIOD_M5, 20, 0, MODE_SMA, PRICE_CLOSE, 0 ); double ma5 = iMA( NULL, PERIOD_M5, 5, 0, MODE_SMA, PRICE_CLOSE, 0 ); if ( main5 > signal5 && High[0] > ma5 ){ ExtMapBuffer1[i] = ( ( Close[i+1] + Close[i] ) / 2 ); // .CALC/.STO values = MAIN_ABOVE_SIGNAL; // .SET if ( values_PREV!= MAIN_ABOVE_SIGNAL ){ // ? WAS A FLIP values_PREV = MAIN_ABOVE_SIGNAL; // .SET ExtMapBuffer3[i+1] = ExtMapBuffer2[i+1]; // .STO[i+1] ExtMapBuffer3[i ] = ExtMapBuffer1[i ]; // .STO[i+0] } } if ( main5 < signal5 && Low[0] < ma5 ){ ExtMapBuffer2[i] = ( ( Close[i+1] + Close[i] ) / 2 ); // .CALC/.STO values = MAIN_UNDER_SIGNAL; // .SET if ( values_PREV!= MAIN_UNDER_SIGNAL ){ // ? WAS A FLIP values_PREV = MAIN_UNDER_SIGNAL; // .SET ExtMapBuffer3[i+1] = ExtMapBuffer1[i+1]; // .STO[i+1] ExtMapBuffer3[i ] = ExtMapBuffer2[i ]; // .STO[i+0] } } } }

EA和自定义指标之间更安全的MQL4集成接口的工具

由于iCustom()语法的性质和参数的排序, 在自定义指标设计阶段 创建复制/粘贴接口模板作为EA的标题部分更加安全 ,这将准备安全呼叫API合同的所有相关细节(无论技术上有多弱)

这个模板工具避免了无数的麻烦和调试语法上可行的生产力的损失,但是由于传递了错误的,混合不良的参数(缺少一个/一个错误的值/一个错误的顺序/),iCustom()的错误调用。 ..)

// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| // COPY/PASTE.START // |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| // CALL-er SIDE INTERFACE ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| // // #define sIndicatorPathNAME "#AliceInTheWonderlands_msMOD_0.00" // // //_____________________________________INPUT(s) // // NONE // n/a // // //_____________________________________OUTPUT(s): // #define iOutputDoubleOpenBUFFER 0 // #define iOutputDoubleHighBUFFER 1 // #define iOutputDoubleLowBUFFER 2 // #define iOutputDoubleCloseBUFFER 3 // #define iOutputDoubleVolumeBUFFER 4 // #define iOutputDoubleTimeBUFFER 5 // // double iCustom( _Symbol, // string symbol, // symbol: Symbol name on the data of which the indicator will be calculated. NULL means the current symbol. // PERIOD_CURRENT, // int timeframe, // timeframe // sIndicatorPathNAME, // string name, // path/name of the custom indicator compiled program: Custom indicator compiled program name, relative to the root indicators directory (MQL4/Indicators/). If the indicator is located in subdirectory, for example, in MQL4/Indicators/Examples, its name must be specified as "Examples\\indicator_name" (double backslash "\\"must be specified as separator instead of a single one). // <<N/A>>, // ...[1] ..., // custom indicator [1]-st input parameters (if necessary) // // ...[2+] // custom indicator further input parameters (if necessary) // <iOutputDouble*BUFFER>, // int mode, // line index: Line index. Can be from 0 to 7 and must correspond with the index, specified in call of the SetIndexBuffer() function. // i // int bar_shift // shift // ); // |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| // COPY/PASTE.END // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

剩下的差距来自代码设计。 使用三重缓冲线构建的演示方法完全涵盖了问题

剩下的问题与业务逻辑算法有关,它是由O / P以if(){...} -constructors的独立串行序列的形式编码的,它们根本无法正确处理所有现有的三态FSA转换。

Indicator_Line

How to understand EMPTY_VALUE in MQL4 Custom Indicators?

MQL4's convention is not to paint / show CustomIndicator-line-segments to/from Bars, where CustomIndicator-storageBuffer contains a specially recognised "Empty_Value" == { EMPTY_VALUE | a value pre-set via SetIndexEmptyValue() }.

By default, "Empty_Value" is EMPTY_VALUE.

The key step is this trick:

if ( main5 < signal5 && Low[0] < ma5 ){ ExtMapBuffer2[i] = ( ( Close[i+1] + Close[i] ) / 2 ); // .CALC/.STO values = MAIN_UNDER_SIGNAL; // .SET if ( values_PREV!= MAIN_UNDER_SIGNAL ){ // ? WAS A FLIP values_PREV = MAIN_UNDER_SIGNAL; // .SET ExtMapBuffer3[i+1] = ExtMapBuffer1[i+1]; // .STO[i+1] ExtMapBuffer3[i ] = ExtMapBuffer2[i ]; // .STO[i+0] } }

The recommended changes in context of the New-MQL4 code are here:

// ------------------------------------------------------------------------------------ // FOR AN EA-INTEGRATION INTERFACE, ref. below // ------------------------------------------------------------------------------------ #property strict // check this against OnCalculate() syntax requirement #property indicator_separate_window //roperty indicator_level1 75.0 // N/A for aPriceDOMAIN line //roperty indicator_level2 25.0 // N/A for aPriceDOMAIN line //roperty indicator_levelcolor clrLimeGreen //roperty indicator_levelwidth 1 //roperty indicator_levelstyle 0 //roperty indicator_buffers 5 // not used #property indicator_buffers 3 #property indicator_color1 clrGreen #property indicator_color2 clrRed #property indicator_color3 clrDimGray /*roperty indicator_color4 Green // not used #property indicator_color5 Red // not used */ #property description "Scalping in M5 Custom Indicator......................" #property description "How to use it ......................................." #property description "How to setup ........................................" extern string howtouse = "scalping in M5"; // "New"-MQL4 shows comments in dialog box extern string contact = "reiz_gamer@yahoo.co.id"; // Contact Email extern string created = "created by reza rahmad"; // copyright notice extern int barsToProcess = 100; // Bars To Process ( Depth ) double ExtMapBuffer1[], ExtMapBuffer2[], ExtMapBuffer3[]; double buy[]; double sell[]; int values, values_PREV = EMPTY; // <STATE-FULL>-logic #define MAIN_ABOVE_SIGNAL 1 #define MAIN_UNDER_SIGNAL 2 //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { IndicatorShortName( "SigREZ( " + DoubleToStr( barsToProcess, 0 ) + " )"); IndicatorDigits( Digits + 1 ); // override default decimal points // to be distinguishable once AVG(Close1,Close0) values are calculated SetIndexStyle( 0, DRAW_LINE ); // MAIN_ABOVE_SIGNAL SetIndexBuffer( 0, ExtMapBuffer1 ); // segments for values == 1 SetIndexDrawBegin( 0, barsToProcess ); SetIndexStyle( 1, DRAW_LINE ); // MAIN_UNDER_SIGNAL SetIndexBuffer( 1, ExtMapBuffer2 ); // segments for values == 2 SetIndexDrawBegin( 1, barsToProcess ); SetIndexStyle( 2, DRAW_LINE ); // EMPTY_SEGMENTs SetIndexBuffer( 2, ExtMapBuffer3 ); SetIndexDrawBegin( 2, barsToProcess ); /* SetIndexStyle( 3, DRAW_NONE ); // not used SetIndexBuffer( 3, buy ); SetIndexEmptyValue( 3, 0.0 ); SetIndexStyle( 4, DRAW_ARROW, EMPTY, 3, Magenta ); SetIndexArrow( 4, 234 ); SetIndexBuffer( 4, sell ); SetIndexEmptyValue( 4, 0.0 ); */ // ---------------------------------------------------------------------------------- // initialization of the generator of random numbers // ---------------------------------------------------------------------------------- ObjectCreate( "sig", OBJ_TEXT, 0, 0, 0, 0, 0 ); ObjectSetText( "sig", "TAHAN", 10, "Times New Roman", Magenta ); ObjectCreate( "sig1", OBJ_LABEL, 0, 0, 0, 0, 0 ); ObjectSet( "sig1", OBJPROP_XDISTANCE, 750 ); ObjectSet( "sig1", OBJPROP_YDISTANCE, 20 ); ObjectSetText( "sig1", "created by reza rahmad scalping use in tf 5m", 10, "Times New Roman", Magenta ); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int deinit() { ObjectDelete( "tare" ); ObjectDelete( "tarmid" ); ObjectDelete( "tare1" ); ObjectDelete( "sig" ); ObjectDelete( "sig1" ); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int limit = Bars, counted_bars = IndicatorCounted(); if ( counted_bars > 0 ) counted_bars--; limit -= counted_bars; if ( limit > barsToProcess ) limit = barsToProcess; for ( int i = 0; i < limit; i++ ) { double main5 = iStochastic( NULL, PERIOD_M5, 14, 3, 3, MODE_SMMA, 0, MODE_MAIN, i ); double signal5 = iStochastic( NULL, PERIOD_M5, 14, 3, 3, MODE_SMMA, 0, MODE_SIGNAL, i ); double ma20 = iMA( NULL, PERIOD_M5, 20, 0, MODE_SMA, PRICE_CLOSE, 0 ); double ma5 = iMA( NULL, PERIOD_M5, 5, 0, MODE_SMA, PRICE_CLOSE, 0 ); if ( main5 > signal5 && High[0] > ma5 ){ ExtMapBuffer1[i] = ( ( Close[i+1] + Close[i] ) / 2 ); // .CALC/.STO values = MAIN_ABOVE_SIGNAL; // .SET if ( values_PREV!= MAIN_ABOVE_SIGNAL ){ // ? WAS A FLIP values_PREV = MAIN_ABOVE_SIGNAL; // .SET ExtMapBuffer3[i+1] = ExtMapBuffer2[i+1]; // .STO[i+1] ExtMapBuffer3[i ] = ExtMapBuffer1[i ]; // .STO[i+0] } } if ( main5 < signal5 && Low[0] < ma5 ){ ExtMapBuffer2[i] = ( ( Close[i+1] + Close[i] ) / 2 ); // .CALC/.STO values = MAIN_UNDER_SIGNAL; // .SET if ( values_PREV!= MAIN_UNDER_SIGNAL ){ // ? WAS A FLIP values_PREV = MAIN_UNDER_SIGNAL; // .SET ExtMapBuffer3[i+1] = ExtMapBuffer1[i+1]; // .STO[i+1] ExtMapBuffer3[i ] = ExtMapBuffer2[i ]; // .STO[i+0] } } } }

Tool for a safer MQL4 integration Interface between EA & Custom Indicator

Due to the nature of the iCustom() syntax and ordering of the parameters, it is much safer to create a copy/paste-interface-template as a header-section for an EA, right during the Custom Indicator design phase, that will prepare all relevant details for a safe-call-API contract ( irrespective how weak it technically is )

This template-tool avoids countless troubles and loss of productivity on debugging a syntactically feasible, however wrong calls of iCustom() due to passing wrong, ill-mixed parameters ( a missing-one / a wrong-value / a wrong-order / ... )

// |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| // COPY/PASTE.START // |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| // CALL-er SIDE INTERFACE ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| // // #define sIndicatorPathNAME "#AliceInTheWonderlands_msMOD_0.00" // // //_____________________________________INPUT(s) // // NONE // n/a // // //_____________________________________OUTPUT(s): // #define iOutputDoubleOpenBUFFER 0 // #define iOutputDoubleHighBUFFER 1 // #define iOutputDoubleLowBUFFER 2 // #define iOutputDoubleCloseBUFFER 3 // #define iOutputDoubleVolumeBUFFER 4 // #define iOutputDoubleTimeBUFFER 5 // // double iCustom( _Symbol, // string symbol, // symbol: Symbol name on the data of which the indicator will be calculated. NULL means the current symbol. // PERIOD_CURRENT, // int timeframe, // timeframe // sIndicatorPathNAME, // string name, // path/name of the custom indicator compiled program: Custom indicator compiled program name, relative to the root indicators directory (MQL4/Indicators/). If the indicator is located in subdirectory, for example, in MQL4/Indicators/Examples, its name must be specified as "Examples\\indicator_name" (double backslash "\\"must be specified as separator instead of a single one). // <<N/A>>, // ...[1] ..., // custom indicator [1]-st input parameters (if necessary) // // ...[2+] // custom indicator further input parameters (if necessary) // <iOutputDouble*BUFFER>, // int mode, // line index: Line index. Can be from 0 to 7 and must correspond with the index, specified in call of the SetIndexBuffer() function. // i // int bar_shift // shift // ); // |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| // COPY/PASTE.END // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

The remaining gaps result from code-design. The demonstrated approach with using triple-buffer-ed line construction fully covered the Question asked.

The remaining issue is related with business-logic algorithmisation, that was coded by O/P in a form of independent, serial-sequence of if(){...}-constructors, that are simply not able of proper handling all the existing Tri-State-FSA transitions.

Indicator_Line

更多推荐

本文发布于:2023-07-15 22:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1119382.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓冲区   coding   line   buffer   empty

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!