กองทุน SPDR Gold Shares

ประจำวันที่

เวลา ครั้งที่ ก่อนหน้า ถือล่าสุด เปลี่ยนแปลง
- - - - -
รวมวันนี้-
เดือนนี้ - : 
ปีนี้  : 
*หน่วยตัน
*อ้างอิงจาก SPDR Gold Share

ราคาทองตามประกาศสมาคมค้าทองคำ

ประจำวันที่ ครั้งที่ เวลา น.

ชนิดทองคำ รับซื้อ ขายออก
ทองคำแท่ง 96.5% - -
ทองรูปพรรณ 96.5% - -
รวมวันนี้-
เปลี่ยนแปลงล่าสุด-
*หน่วยเงินบาท
*ราคาอ้างอิงล่าสุดจากสมาคมค้าทองคำ

รบกวนครับคือผมอยากดึงค่า อินดี้ มาทำเป็น EA แต่ดึงไม่ได้ครับ iCustom

  • 6 replies
  • 4,868 views
*

with

ถ้าผิดห้องต้องขออภัยนะครับ  คือผมจะเอาอินดี้มา ทำเป็น EA ครับ แต่มันดึงค่าออกมาไม่ได้ ผมใช้ iCustom  ในการดึงค่า
แต่ก็ดึงออกมาไม่ได้ครับ เป็นอินดี้ RSI+MA+Label  คือ ต้องการดึงค่าเส้นที่ตัดกันครับ  รบกวนผู้รู้ด้วนครับ

*

admin

  • 82,762
ต้องรอเพื่อนๆ ล่ะครับ ท่านใด ทำได้บ้าง
พอดี Admin ไม่ค่อย ถนัดสาย EA
(TH)** (TH)** (TH)**
"เอาชนะใจตัวเองให้ได้ ก่อนที่จะไปเอาชนะตลาด"

*

with


ผมต้องการดึงค่าของเส้น MA 2 เส้นที่ตัดกันเอามาเป็นตัวเปิด ปิด order ครับ
extern int RSIPeriod = 14;
extern int MAofRSI   = 8;
รบกวนผู้รู้ช่วยเขียน code ตัวอย่างให้ดูด้วยครับ

ตัวอย่าง code ที่ผมใช้

double val=iCustom(NULL,0,"sample",13,1,0);


สูตรของอินดี้ครับ

#property indicator_separate_window

#property indicator_buffers 2
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_style2 STYLE_SOLID
#property indicator_level1 30
#property indicator_level2 50
#property indicator_level3 70
#property indicator_levelcolor DimGray



//--- input parameters
extern int RSIPeriod = 14;
extern int MAofRSI   = 8;
extern int MA_method = 1; //Mode EMA

//--- buffers
double RSIBuffer[];
double MAofRSIBuffer[];


color tColor;
color tColor1;
color tColor3;
color tColor4;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   
//--- 2 buffers used for counting.
   IndicatorBuffers(2);
   SetIndexBuffer(0,RSIBuffer);
   SetIndexBuffer(1,MAofRSIBuffer);
 
//--- indicator line
   SetIndexDrawBegin(0,RSIPeriod);
   SetIndexDrawBegin(1,RSIPeriod);
 
//--- name for DataWindow and indicator subwindow label
   IndicatorShortName("RSI("+RSIPeriod+")");
   SetIndexLabel(0,"RSI("+RSIPeriod+")");
   SetIndexLabel(1,"MA("+MAofRSI+")");
   return(0);
  }
 
//+------------------------------------------------------------------+
//| Relative Strength Index                                          |
//+------------------------------------------------------------------+
int start()
  {
   int i;
   int limit;
   int counted_bars=IndicatorCounted();
   
   //---- check for possible errors
   if(counted_bars<0) return(-1);
   
   //---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   //--- main loops 1 and 2
   for(i=0; i < limit; i++)
      {
        RSIBuffer=iRSI(Symbol(),0,RSIPeriod,PRICE_CLOSE,i);
      }
 
   for(i=0; i < limit; i++)
      {
        MAofRSIBuffer=iMAOnArray(RSIBuffer,0,MAofRSI,0,MA_method,i);
      }



  //--- Set Object label (_____)
  ObjectCreate("RSI_line", OBJ_LABEL, WindowFind("RSI("+RSIPeriod+")"), 0, 0);
     ObjectSet("RSI_line", OBJPROP_CORNER,1);
     ObjectSet("RSI_line", OBJPROP_XDISTANCE, 66);
     ObjectSet("RSI_line", OBJPROP_YDISTANCE, 0);
     ObjectSetText("RSI_line","_____", 12, "Calibri", Blue);
  ObjectCreate("MA_rsi_line", OBJ_LABEL, WindowFind("RSI("+RSIPeriod+")"), 0, 0);
     ObjectSet("MA_rsi_line", OBJPROP_CORNER,1);
     ObjectSet("MA_rsi_line", OBJPROP_XDISTANCE, 66);
     ObjectSet("MA_rsi_line", OBJPROP_YDISTANCE, 15);
     ObjectSetText("MA_rsi_line","_____", 12, "Calibri", Red);     
     
     
   //--- Set Label RSI value
   ObjectCreate("RSI_value", OBJ_LABEL, WindowFind("RSI("+RSIPeriod+")"), 0, 0);
     ObjectSet("RSI_value", OBJPROP_CORNER,1);
     ObjectSet("RSI_value", OBJPROP_XDISTANCE, 26);
     ObjectSet("RSI_value", OBJPROP_YDISTANCE, 7);
   ObjectCreate("MArsi_value", OBJ_LABEL, WindowFind("RSI("+RSIPeriod+")"), 0, 0);
     ObjectSet("MArsi_value", OBJPROP_CORNER,1);
     ObjectSet("MArsi_value", OBJPROP_XDISTANCE, 26);
     ObjectSet("MArsi_value", OBJPROP_YDISTANCE, 23);
   ObjectCreate("RSI_phase", OBJ_LABEL,  WindowFind("RSI("+RSIPeriod+")"), 0, 0);
     ObjectSet("RSI_phase", OBJPROP_CORNER, 1);
     ObjectSet("RSI_phase", OBJPROP_XDISTANCE, 8);
     ObjectSet("RSI_phase", OBJPROP_YDISTANCE,9);
   ObjectCreate("MArsi_phase", OBJ_LABEL,  WindowFind("RSI("+RSIPeriod+")"), 0, 0);
     ObjectSet("MArsi_phase", OBJPROP_CORNER, 1);
     ObjectSet("MArsi_phase", OBJPROP_XDISTANCE, 8);
     ObjectSet("MArsi_phase", OBJPROP_YDISTANCE,25);
     
     
     //--- Set Label RSI phase
    if(RSIBuffer[0] > 50 )tColor=Green;
         else tColor=Red;
         ObjectSetText("RSI_value",DoubleToStr(RSIBuffer[0],2), 11, "Calibri", tColor);
         
      //---
    if(MAofRSIBuffer[0] > 50 )tColor1=Green;
         else tColor1=Red;
         ObjectSetText("MArsi_value",DoubleToStr(MAofRSIBuffer[0],2), 11, "Calibri", tColor1);
         
      //---   
    if(RSIBuffer[0] > RSIBuffer[1])
           {
            tColor3=Green;
            ObjectSetText("RSI_phase","p",10,"Wingdings 3", tColor3);
           }
    else
           {
            tColor3=Red;
            ObjectSetText("RSI_phase","q",10,"Wingdings 3", tColor3);
           }
           
    //---     
    if(MAofRSIBuffer[0] > MAofRSIBuffer[1])
           {
            tColor4=Green;
            ObjectSetText("MArsi_phase","p",10,"Wingdings 3", tColor4);
           }
    else
           {
            tColor4=Red;
            ObjectSetText("MArsi_phase","q",10,"Wingdings 3", tColor4);
           }
           
           
    return(0);
  }

*

with

อันนี้เป็น 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

*

5harever

ใช้ Globalvariable ในการส่งค่าไปมาระหว่าง Indicator กับ EA ได้ครับ

*

admin

  • 82,762
อ้างจาก: 5harever ที่ 24, สิงหาคม  2016, 09:07:35 PM
ใช้ Globalvariable ในการส่งค่าไปมาระหว่าง Indicator กับ EA ได้ครับ

ขอบคุณ ที่มาช่วยตอบนะครับ
(TH)**
"เอาชนะใจตัวเองให้ได้ ก่อนที่จะไปเอาชนะตลาด"

*

with

รบกวนครับ พอจะเขียนให้ดูได้ไหมครับ พอดีหัดเขียนใหม่ครับ

 

XM Global Limited