我可以從指標中獲得任何計算值嗎?
Results 1 to 2 of 2

Thread: 我可以從指標中獲得任何計算值嗎?

  1. #1
    我如何從這個indior到EA獲得O [_i]的值。
    O [_]是室內疊加圖的開放價格。

    插入的代碼// --------------------------------------------- --------------------- /| OverlayChart.mq5 |/|版權所有2014-2016,EarnForex.com |/| http://www.earnforex.com |/|由http://www.irxfx.com轉換自MT4版本|/ ----------------------------------------------- ------------------- #property copyright Copyright 2014-2016,EarnForex.com #property link http://www.earnforex.com #property version 1.01 #property indior_chart_window #property indior_buffers 5 #property indior_plots 1 #property indior_type1 DRAW_COLOR_BARS #property indior_color1 clrMediumSeaGreen,clrOrange #property indior_width1 1/Indior參數輸入字符串SubSymbol = GBPUSD;輸入bool Mirroring = false;輸入ENUM_DRAW_TYPE DrawType = DRAW_COLOR_BARS;輸入顏色GridColor = clrBlack;/Indior Buffers double O#91;#93 ;;雙H#91;#93 ;;雙L#91;#93 ;;雙C#91;#93 ;;雙色#91;#93 ;;/全局變量double SubOpen#91;#93 ;; double SubHigh#91;#93 ;; double SubLow#91;#93 ;; double SubClos​​e#91;#93 ;; string Prefix = OverlayChart;/Indior Prefix int Grid = 10;/網格線int SnapPips = 10;/網格線的捕捉點// ---------------------------------------- -------------------------- /|自定義indior初始化函數|/ ----------------------------------------------- ------------------- int OnInit(){IndiorSetString(INDICATOR_SHORTNAME,OverLay Chart( SubSymbol )); SetIndexBuffer(0,O,INDICATOR_DATA); SetIndexBuffer(1,H,INDICATOR_DATA); SetIndexBuffer(2,L,INDICATOR_DATA); SetIndexBuffer(3,C,INDICATOR_DATA); SetIndexBuffer(4,Color,INDICATOR_COLOR_INDEX); ArraySetAsSeries(O,true); ArraySetAsSeries(H,true); ArraySetAsSeries(L,true); ArraySetAsSeries(C,true); ArraySetAsSeries(Color,true); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0); PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DrawType); ArraySetAsSeries(SubOpen,true); ArraySetAsSeries(SubHigh,true); ArraySetAsSeries(SubLow,true); ArraySetAsSeries(SubClos​​e,true);返回(INIT_SUCCEEDED); }/ ---------------------------------------------- -------------------- /|定制indior deinitialization功能|/ ----------------------------------------------- ------------------- void OnDeinit(const int reason){ObjectsDeleteAll(0,Prefix);* for(int _i = 1; _i lt; = Grid; _i ){ObjectDelete(0,Prefix Grid IntegerToString(_i)); ObjectDelete(0,Prefix Price IntegerToString(_i)); } *}/ ------------------------------------------- ----------------------- /|自定義indior迭代功能|/ ----------------------------------------------- ------------------- int OnCalculate(const int rates_total,const int prev_calculated,constdatetime時間#91;#93;,const double打開#91;#93;,const double高#91;#93;,const double低#91;#93;,const double關閉#91;#93;,const long tick_volume#91;#93;,const long volume#91;#93;,const int spread#91;#93;){int _BarsCount; double _CurRangeHigh,_CurRangeLow,_CurRangeCenter; double _SubRangeHigh,_SubRangeLow,_SubRangeCenter; double _SubPoint; int _SubDigit; double _SubOpen,_SubHigh,_SubLow,_SubClos​​e; double _PipsRatio; double _GridPips,_GridPrice; int _i; ArraySetAsSeries(Open,true); ArraySetAsSeries(高,真); ArraySetAsSeries(低,真); ArraySetAsSeries(Close,true); ArraySetAsSeries(Time,true); ArrayInitialize(O,0); ArrayInitialize(H,0); ArrayInitialize(L,0); ArrayInitialize(C,0);/計算可見條_BarsCount =(int)ChartGetInteger(0,CHART_VISIBLE_BARS) 1; int _FirstBar =(int)ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR); int _LastBar = _FirstBar - _BarsCount 1; if(_LastBar lt; 0){_ LastBar = 0; _BarsCount = _FirstBar 1; }/計算圖表比率_CurRangeHigh =高#91; ArrayMaximum(高,_LastBar,_BarsCount)#93 ;; _CurRangeLow = Low#91; ArrayMinimum(Low,_LastBar,_BarsCount)#93 ;; _CurRangeCenter =(_ CurRangeHigh _CurRangeLow)/2; int n; n = CopyOpen(SubSymbol,0,_LastBar,_BarsCount,SubOpen); if(!CheckData(n,_BarsCount))return(0); n = CopyHigh(SubSymbol,0,_LastBar,_BarsCount,SubHigh); if(!CheckData(n,_BarsCount))return(0); n = CopyLow(SubSymbol,0,_LastBar,_BarsCount,SubLow); if(!CheckData(n,_BarsCount))return(0); n = CopyClose(SubSymbol,0,_LastBar,_BarsCount,SubClos​​e); if(!CheckData(n,_BarsCount))return(0); double SubMax = SubHigh#91; ArrayMaximum(SubHigh)#93 ;; double SubMin = SubLow#91; ArrayMinimum(SubLow)#93 ;; if(鏡像){_ SubRangeHigh = SubMin; _SubRangeLow = SubMax; } else {_SubRangeHigh = SubMax; _SubRangeLow = SubMin; } _SubRangeCenter =(_ SubRangeHigh _SubRangeLow)/2; _SubPoint = SymbolInfoDouble(SubSymbol,SYMBOL_POINT); _SubDigit =(int)SymbolInfoInteger(SubSymbol,SYMBOL_DIGITS); if(_SubRangeHigh - _SubRangeLow == 0)return(0); _PipsRatio =(_ CurRangeHigh - _CurRangeLow)/(_ SubRangeHigh - _SubRangeLow); _GridPips =(_ SubRangeHigh - _SubRangeLow)/Grid; _GridPips = MathRound((_ SubRangeHigh - _SubRangeLow)/Grid(_ SubPoint * SnapPips))*(_ SubPoint * SnapPips);/為(_i = _LastBar; _i lt; _LastBar _BarsCount; _i ){int i = _i - _LastBar;繪製燭台_SubOpen = SubOpen#91; i#93; - _SubRangeCenter; _SubHigh = SubHigh#91;我#93; - _SubRangeCenter; _SubLow = SubLow#91;我#93; - _SubRangeCenter; _SubClos​​e = SubClos​​e#91; i#93; - _SubRangeCenter; if(鏡像){if(_SubOpen lt; _SubClos​​e){H#91; _i#93; = _CurRangeCenter _SubHigh * _PipsRatio; L#91;#_i 93; = _CurRangeCenter _SubLow * _PipsRatio;顏色#91;#_I 93; = 0; } else {L#91; _i#93; = _CurRangeCenter _SubLow * _PipsRatio; ħ#91;#_i 93; = _CurRangeCenter _SubHigh * _PipsRatio;顏色#91;#_I 93; = 1; C#91; _i#93; = _CurRangeCenter _SubClos​​e * _PipsRatio; O#上91; _i#93; = _CurRangeCenter _SubOpen * _PipsRatio; } else {if(_SubOpen lt; _SubClos​​e){H#91; _i#93; = _CurRangeCenter _SubHigh * _PipsRatio; L#91;#_i 93; = _CurRangeCenter _SubLow * _PipsRatio;顏色#91;#_I 93; = 0; } else {L#91; _i#93; = _CurRangeCenter _SubLow * _PipsRatio; ħ#91;#_i 93; = _CurRangeCenter _SubHigh * _PipsRatio;顏色#91;#_I 93; = 1; C#91; _i#93; = _CurRangeCenter _SubClos​​e * _PipsRatio; O#上91; _i#93; = _CurRangeCenter _SubOpen * _PipsRatio; for(_i = 1; _i lt; = Grid; _i ){_ GridPrice = MathRound(_SubRangeCenter(_ SubPoint * SnapPips))*(_ SubPoint * SnapPips); _GridPrice =((_ GridPrice _GridPips2) _GridPips *(Grid2 - 1)) - (_GridPips *(_ i - 1)); string grid_string = Prefix Grid IntegerToString(_i); ObjectCreate(0,grid_string,OBJ_TREND,0,0,0); ObjectSetInteger(0,grid_string,OBJPROP_TIME,0,Time#91; _FirstBar#93;); ObjectSetDouble(0,grid_string,OBJPROP_PRICE,0,_CurRangeCenter (_ GridPrice - _SubRangeCenter)* _PipsRatio); ObjectSetInteger(0,grid_string,OBJPROP_TIME,1,Time#91; _LastBar#93;); ObjectSetDouble(0,grid_string,OBJPROP_PRICE,1,_CurRangeCenter (_ GridPrice - _SubRangeCenter)* _PipsRatio); ObjectSetInteger(0,grid_string,OBJPROP_COLOR,GridColor); ObjectSetInteger(0,grid_string,OBJPROP_STYLE,STYLE_DOT); ObjectSetInteger(0,grid_string,OBJPROP_WIDTH,1); ObjectSetInteger(0,grid_string,OBJPROP_RAY_RIGHT,true); grid_string = Prefix Price IntegerToString(_i); ObjectCreate(0,grid_string,OBJ_TEXT,0,0,0); ObjectSetInteger(0,grid_string,OBJPROP_TIME,0,Time#91; _FirstBar - _BarsCount10#93;); ObjectSetDouble(0,grid_string,OBJPROP_PRICE,0,_CurRangeCenter (_ GridPrice - _SubRangeCenter)* _PipsRatio); ObjectSetInteger(0,grid_string,OBJPROP_COLOR,GridColor); ObjectSetString(0,grid_string,OBJPROP_TEXT,DoubleToString(_GridPrice,_SubDigit)); } return(rates_total); }/檢查時間序列條的數量並返回true(OK)或false(Error)。 bool CheckData(int n,int _BarsCount){if(n == -1){Print(圖表數據不可用:,SubSymbol);返回(假); } if(n!= _BarsCount){Print(圖表數據仍在加載:,SubSymbol);返回(假); } return(true); }/ ---------------------------------------------- --------------------

  2. #2
    您必須在EA中使用調用正確緩衝區的iCustom()函數。在您的示例中,如果需要O []值,則iCustom()的緩衝區為0(零)。

發布權限

  • 您不可發布新主題
  • 您不可回复
  • 您不可發布附件
  • 您不可編輯您的帖子
  •  
  • BB代碼是打開的
  • 表情符號是打開的
  • [IMG]代碼是打開的
  • [視頻]代碼是打開的
  • HTML代碼是關閉的
forex-pedia網站使用cookie 文字跟蹤
forex-pedia.com網站使用cookie 文字跟蹤,某些設定已經固定。您可以點擊此處閱讀我們的Cookie使用說明。 請點擊右鍵接受我們的cookies。如果您選擇繼續使用forex-pedia.com網站,我們將認為您接受我們的cookies。