กองทุน SPDR GOLD SHARES
ถือทองก่อนหน้า
ถือทองล่าสุด
0.00
*หน่วยตัน / ราคาอ้างอิงล่าสุดจากสมาคมค้าทองคำ
สถิติกองทุน SPDR
ราคาทองคำแท่ง 96.5%
ราคาอ้างอิงล่าสุดจากสมาคมค้าทองคำ
ครั้งที่
ราคาก่อนหน้า
ราคาล่าสุด
0
(หน่วย บาท*) / อัปเดตล่าสุดเมื่อวันที่ 13 ก.ค. 2566 เวลา 13:04 น.
สถิติราคาทองคำ ไทย

ขอความช่วยเหลือครับจะปรับอินดี้ CCI ให้แสดงค่าปัจจุบันแต่ให้เลื่อนถอยหลังไป 50 แท่งครับ

  • 4 replies
  • 2,107 views
*

with

ขอความช่วยเหลือครับจะปรับอินดี้ CCI ให้แสดงค่าปัจจุบันแต่ให้เลื่อนถอยหลังไป 50 แท่งครับจะต้องปรับแก้ code ตรงไหนครับ  มือใหม่ครับรบกวนด้วยครับ

*

with


อันนี้เป็น code ของอินดี้ครับจะแก้ตรงไหนครับ......



#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[];
//+------------------------------------------------------------------+
//| 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);
  }
//+------------------------------------------------------------------+

*

iRuler

  • 1,282
ถอยหลังไป 50แท่งแล้วมันจะเป็นค่าปัจจุบันยังไงอ่ะครับ xc7*

อ้างจาก: iRuler ที่ 01, กันยายน  2019, 10:08:27 PM
ถอยหลังไป 50แท่งแล้วมันจะเป็นค่าปัจจุบันยังไงอ่ะครับ xc7*

ผมก็งง เหมือนกันครับ

แต่เดาไปเองว่า  คิดว่าน่าจะอยากเอาค่าของ 50 แท่งก่อนมาเป็นซิกแนลปัจจุบันมั้งครับ   
คิดว่าไม่น่าจะแก้จากอินดี้โดยตรงไ้ด้นะครับ

*

with