กองทุน SPDR Gold Shares

ประจำวันที่

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

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

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

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

ทำไมอินดิเคเตอร์ ไม่แสดงผล ครับ

  • 2 replies
  • 1,413 views
ทำไมอินดิเคเตอร์ ไม่แสดงผล ครับ
« เมื่อ: 29, ธันวาคม 2021, 01:51:06 PM »
//+------------------------------------------------------------------+
//|                                                          CCI.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "http://www.mql4.com"
#property description "Commodity Channel Index"
#property strict

#include <MovingAverages.mqh>

#property indicator_separate_window
#property indicator_buffers    1
#property indicator_color1     LightSeaGreen
#property indicator_level1    -100.0
#property indicator_level2     100.0
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT
//--- input parameter
input int InpCCIPeriod=14; // CCI Period
//--- buffers
double ExtCCIBuffer[];
double ExtPriceBuffer[];
double ExtMovBuffer[];

>>>int start()
{     //acc number
  if(AccountNumber()==5521865 && !IsDemo())
  {
    Alert("License Verified!");
  }
  else
  {
    Alert("EA Not Licensed For Your Account Number, Contact Seller: example@example.com");
  }
  return(0);
}
>>>

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   string short_name;
//--- 2 additional buffers are used for counting.
   IndicatorBuffers(3);
   SetIndexBuffer(1,ExtPriceBuffer);
   SetIndexBuffer(2,ExtMovBuffer);
//--- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtCCIBuffer);
//--- check for input parameter
   if(InpCCIPeriod<=1)
     {
      Print("Wrong input parameter CCI Period=",InpCCIPeriod);
      return(INIT_FAILED);
     }
//---
   SetIndexDrawBegin(0,InpCCIPeriod);
//--- name for DataWindow and indicator subwindow label
   short_name="CCI("+IntegerToString(InpCCIPeriod)+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//--- initialization done
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Commodity Channel Index                                          |
//+------------------------------------------------------------------+
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,k,pos;
   double dSum,dMul;
//---
   if(rates_total<=InpCCIPeriod || InpCCIPeriod<=1)
      return(0);
//--- counting from 0 to rates_total
   ArraySetAsSeries(ExtCCIBuffer,false);
   ArraySetAsSeries(ExtPriceBuffer,false);
   ArraySetAsSeries(ExtMovBuffer,false);
   ArraySetAsSeries(high,false);
   ArraySetAsSeries(low,false);
   ArraySetAsSeries(close,false);
//--- initial zero
   if(prev_calculated<1)
     {
      for(i=0; i<InpCCIPeriod; i++)
        {
         ExtCCIBuffer=0.0;
         ExtPriceBuffer=(high+low+close)/3;
         ExtMovBuffer=0.0;
        }
     }
//--- calculate position
   pos=prev_calculated-1;
   if(pos<InpCCIPeriod)
      pos=InpCCIPeriod;
//--- typical price and its moving average
   for(i=pos; i<rates_total; i++)
     {
      ExtPriceBuffer=(high+low+close)/3;
      ExtMovBuffer=SimpleMA(i,InpCCIPeriod,ExtPriceBuffer);
     }
//--- standard deviations and cci counting
   dMul=0.015/InpCCIPeriod;
   pos=InpCCIPeriod-1;
   if(pos<prev_calculated-1)
      pos=prev_calculated-2;
   i=pos;
   while(i<rates_total)
     {
      dSum=0.0;
      k=i+1-InpCCIPeriod;
      while(k<=i)
        {
         dSum+=MathAbs(ExtPriceBuffer[k]-ExtMovBuffer);
         k++;
        }
      dSum*=dMul;
      if(dSum==0.0)
         ExtCCIBuffer=0.0;
      else
         ExtCCIBuffer=(ExtPriceBuffer-ExtMovBuffer)/dSum;
      i++;
     }
//---
   return(rates_total);
  }
//+------------------------------------------------------------------+


>>>
.
.
.
.
.
>>>

คือข้อความที่เติมเข้าไป ก่อนใส่ อินดี้ทำงาน คือ แสดงเส้น  แต่พอใส่บรรทัดเหล่านี้ไป อินดี้ก็ไม่แสดงผล ครับ

*

admin

  • 84,261
Re: ทำไมอินดิเคเตอร์ ไม่แสดงผล ครับ
« ตอบกลับ #1 เมื่อ: 29, ธันวาคม 2021, 03:24:13 PM »
รอ IT มาตอบนะครับ
(TH)**
"เอาชนะใจตัวเองให้ได้ ก่อนที่จะไปเอาชนะตลาด"

*

iRuler

  • 1,284
Re: ทำไมอินดิเคเตอร์ ไม่แสดงผล ครับ
« ตอบกลับ #2 เมื่อ: 29, ธันวาคม 2021, 03:38:58 PM »
เอาไปใส่ตรงนั้นไม่ได้ครับ ต้องเออาไปใส่ใน OnInit() {}

int OnInit(void)
  {





 

XM Global Limited