อันนี้เป็น code อินดี้ อีกตัวครับที่ต้องการดึงค่า
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "
https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_separate_window
#property indicator_minimum -100
#property indicator_maximum 0
#property indicator_level1 -20
#property indicator_level2 -30
#property indicator_level3 -40
#property indicator_level4 -50
#property indicator_level5 -60
#property indicator_level6 -70
#property indicator_level7 -80
#property indicator_buffers 4
#property indicator_color1 Black
#property indicator_color2 Lime
#property indicator_color3 White
extern int Period_WPR = 30;
extern int Period_EMAWPR1 = 5;
extern int Period_EMAWPR2 = 5;
extern int Period_EMAWPR2_Shift=1;
extern int ModeMA = 0;
double WPR[];
double EMAWPR1[];
double EMAWPR2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
IndicatorBuffers(3);
SetIndexStyle (0,DRAW_LINE);
SetIndexStyle (1,DRAW_LINE);
SetIndexStyle (2,DRAW_LINE);
SetIndexBuffer(0,WPR);
SetIndexBuffer(1,EMAWPR1);
SetIndexBuffer(2,EMAWPR2);
SetIndexLabel(0,"WPR");
SetIndexLabel(1,"EMAWPR1");
SetIndexLabel(2,"EMAWPR2");
IndicatorShortName("WPR_Multi");
SetIndexDrawBegin(0,Period_WPR);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
int i;
if(Bars<=Period_WPR || Period_WPR<2)
return(0);
for(i=0; i<rates_total; i++) WPR
=iWPR(Symbol(),0,Period_WPR,i);
for(i=0; i<rates_total; i++) EMAWPR1=iMAOnArray(WPR,0,Period_EMAWPR1,0,MODE_EMA,i);
for(i=0; i<rates_total; i++) EMAWPR2=iMAOnArray(WPR,0,Period_EMAWPR1,0,MODE_EMA,Period_EMAWPR2_Shift+i);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
สี Lime กับ สี White ครับ ที่ต้องการดึงค่าแต่พอดึงออกมาแล้วมันไม่ใช้ครับผมทำผิดตรงไหนครับ
สูตร code ที่ใช้ดึง
iCustom(Symbol(),0, "WPR_Multi", 30, 5, 5, 1, 0, 1, 0); ใช้ดึงค่าสี Lime
iCustom(Symbol(),0, "WPR_Multi", 30, 5, 5, 1, 0, 2, 0);ใช้ดึงค่าสี White