Open Forex4you Account

Server รัน EA 1000 / ปี

สั่งชื้อคู่มือการโปรแรกม MQL4

Author Topic: ใครถนัดเขียน indicator มั้งครับ รบกวนขอความรู้หน่อยครับ เรื่องวาดสีลงแท่งเทียน  (Read 50887 times)

D_Diamond

  • Hero Member
  • *****
  • Posts: 673
    • Expert Forex Trading
ยังไม่หายครับ งงจริงๆ อิอิ 

แก้วงเล็บแล้ว ใส่ max bar แล้ว  วันนี้เปิดไม่กี่ชม.ก็เป็นแล้วครับ

ทั้งที่โค้ดมันมาจาก heiken ashi แต่ทำไม heiken ashi ไม่เห็นเพี้ยน

admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 2386
ใส่  RefreshRates( )  ;  ก่อน return หรือยังครับของผมเปิดไวตั้งแต่เมื่อวานยังไม่เจอ กำลังรอดูต่อไปอยู่ครับ

admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 2386
อันนี้ code ที่ผมแก้รอผลมันอยู่ครับ ผมปรับ length ให้สั้นลง เพราะอยากเห็นมันแสดงผลเยอะๆๆ เปิดไวตั้งแต่เมื่อวานยังไม่เจอกำลังรูอดูต่อไป


#property copyright "Copyright ฉ 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Violet
#property indicator_color2 Violet
#property indicator_color3 Magenta
#property indicator_color4 Magenta
#property indicator_color5 Red
#property indicator_color6 Red


//----
extern color color1 = Violet;
extern int width1 = 3;
extern double lenght1 = 10.0;
extern color color2 = Magenta;
extern int width2 = 3;
extern double lenght2 = 15.0;
extern color color3 = Red;
extern int width3 = 3;
extern double lenght3 = 25.0;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];

//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|
int init()
  {
 
  if ( Digits == 5 || Digits == 3 ) { lenght1*=10;lenght2*=10;lenght3*=10; }
//---- indicators

//----
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
   SetIndexDrawBegin(2,10);
   SetIndexDrawBegin(3,10);
   SetIndexDrawBegin(4,10);
   SetIndexDrawBegin(5,10);
 

//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexBuffer(5,ExtMapBuffer6);

   SetIndexStyle(0,DRAW_HISTOGRAM, 0, width1, color1);
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, width1, color1);
   SetIndexStyle(2,DRAW_HISTOGRAM, 0, width2, color2);
   SetIndexStyle(3,DRAW_HISTOGRAM, 0, width2, color2);
   SetIndexStyle(4,DRAW_HISTOGRAM, 0, width3, color3);
   SetIndexStyle(5,DRAW_HISTOGRAM, 0, width3, color3);

//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double  haHigh, haLow;
   if(Bars<=10) return(0);
   ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted

   if (ExtCountedBars>0) ExtCountedBars--;
   
   int pos=Bars-ExtCountedBars-1;
   while(pos>=0)
     {
      haHigh=High[pos];
      haLow=Low[pos];

       ExtMapBuffer1[pos]=haLow;


       double lenght=High[pos]- Low[pos];

            if ( lenght >= lenght3 * Point)
            {
            ExtMapBuffer5[pos]=haLow;
            ExtMapBuffer6[pos]=haHigh; 
            ExtMapBuffer1[pos]=EMPTY; 
            ExtMapBuffer2[pos]=EMPTY;
            ExtMapBuffer3[pos]=EMPTY; 
            ExtMapBuffer4[pos]=EMPTY; 
            }
           
               if ( lenght >= lenght2 * Point  )
               {
               ExtMapBuffer3[pos]=haLow;
               ExtMapBuffer4[pos]=haHigh; 
               ExtMapBuffer1[pos]=EMPTY; 
               ExtMapBuffer2[pos]=EMPTY;
               ExtMapBuffer5[pos]=EMPTY; 
               ExtMapBuffer6[pos]=EMPTY; 
               }
               
                   if ( lenght >= lenght1 * Point  )
                  {
                  ExtMapBuffer1[pos]=haLow;
                  ExtMapBuffer2[pos]=haHigh; 
                  ExtMapBuffer3[pos]=EMPTY;
                  ExtMapBuffer4[pos]=EMPTY;
                  ExtMapBuffer5[pos]=EMPTY;
                  ExtMapBuffer6[pos]=EMPTY;
                  }
        pos--;
        }
 
   RefreshRates( ) ;
   return(0);
  }

D_Diamond

  • Hero Member
  • *****
  • Posts: 673
    • Expert Forex Trading
ถ้าเปิดตั้งแต่เมื่อวานยังไม่เพี้ยน ก็คงหายแล้วครับ เพราะของผมมันเป็นทุกวันเลย อิอิ
เดี๋ยวพรุ่งนี้มารายงานใหม่ครับ

D_Diamond

  • Hero Member
  • *****
  • Posts: 673
    • Expert Forex Trading
RefreshRates( )  ก็ช่วยไม่ได้ครับ เพี้ยนอีกแล้ว  ???

admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 2386
RefreshRates( )  ก็ช่วยไม่ได้ครับ เพี้ยนอีกแล้ว  ???
แปลกดีแฮะ ผมเปิดไวที่บ้าน 2 วันแบบไม่ปิด MT4 ยังไม่มีนะเดียวผมลองเอาขึ้น Server ดูก่อน

D_Diamond

  • Hero Member
  • *****
  • Posts: 673
    • Expert Forex Trading
ที่บ้านผมก็เป็นครับ  พึ่งจะรีเซทเมื่อเช้า นี้เป็นอีกละ
แต่ที่แปลกมันคือ ทำไม Heiken Ashi ถึงปกติ  มันต่างกันตรงไหนนี่

admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 2386
ตัวของคุณ D_diamond ได้ลบ SetIndexBuffer(1, ExtMapBuffer2); ที่อยู่ใน start  ใกล้ๆๆ pos ออกหรือยังครับเพราะในตัวต้นแบบก็ไม่มีอันนี้นะครับ

D_Diamond

  • Hero Member
  • *****
  • Posts: 673
    • Expert Forex Trading
ลบแล้วครับเมื่อวันศุกร์ พึ่งจะเห็นว่ามันเกินมา  คนเขียนโค้ดให้  ท่าน pises999 ก็ไม่รู้หายไปไหนแล้ว หาตัวไม่เจอ อิอิ

admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 2386
ลบแล้วครับเมื่อวันศุกร์ พึ่งจะเห็นว่ามันเกินมา  คนเขียนโค้ดให้  ท่าน pises999 ก็ไม่รู้หายไปไหนแล้ว หาตัวไม่เจอ อิอิ
คุณ D_Diamond  ใช้บน โบรเกอร์ไหน  คู่เงินอะไร timeframe เท่าไรครับ ผมจะลอง set ให้ตรงกันดูครับ

D_Diamond

  • Hero Member
  • *****
  • Posts: 673
    • Expert Forex Trading
ใช้กราฟอียู 1นาที ครับ โบรกไหนก็เป็น

บน vps ผมใช้ thinkforex ใส่ในกราฟ MDP
ผมตั้ง maxbar in history กับ maxbar on chart ไว้ 5000 ด้วยครับ

แต่ไม่ว่ามันจะเป็นด้วยสาเหตุใด  ที่งงสุดๆคือทำไม heiken ashi ไม่เห็นจะเป็น

D_Diamond

  • Hero Member
  • *****
  • Posts: 673
    • Expert Forex Trading
เอารูปของวันนี้มาให้ดู เผื่อท่านแอดมินจะนึกอะไรดีๆออก อิอิ

จากในรูป สรุปได้ว่า  มันเพี้ยนอยู่ข้างเดียว  คือข้างบน

จาก low ถึง high มันทาสีได้ครบ  แต่ทาพ้นยาวขึ้นไปอีกเยอะ   พ้นเฉพาะด้านบน  ด้านล่างไม่พ้น

แต่สีม่วงแท่งที่2จากซ้าย อันนั้นทาไม่โดนแท่งเลย  เป็นแค่แท่งเดียวครับ

บางแท่งก็ทาได้เต็มแท่ง ปกติ ทั้งบน-ล่าง

อิอิ งงครับ

D_Diamond

  • Hero Member
  • *****
  • Posts: 673
    • Expert Forex Trading
ส่วนอีก terminal เป็นแบบนี้ครับ
อันนี้ฮามาก  ทาไม่ถูกเลยซักแท่ง  ทาทั้งบนทั้งล่าง  ไอ้ตรงแท่งกราฟดันไม่ทา
ไอ้กราฟยาวๆก็ไม่มีสีเลย  เขียวสะอาด

admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 2386
code ครับ


#property copyright "Copyright &copy; 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Violet
#property indicator_color2 Violet
#property indicator_color3 Yellow
#property indicator_color4 Yellow
#property indicator_color5 Red
#property indicator_color6 Red


//----
extern color color1 = Violet;
extern int width1 = 3;
extern double lenght1 = 5;
extern color color2 = Yellow;
extern int width2 = 3;
extern double lenght2 = 8;
extern color color3 = Red;
extern int width3 = 3;
extern double lenght3 = 12;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];

//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|
int init()
  {
 
  if ( Digits == 5 || Digits == 3 ) { lenght1*=10;lenght2*=10;lenght3*=10; }
//---- indicators

//----
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
   SetIndexDrawBegin(2,10);
   SetIndexDrawBegin(3,10);
   SetIndexDrawBegin(4,10);
   SetIndexDrawBegin(5,10);
 

//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexBuffer(5,ExtMapBuffer6);

   SetIndexStyle(0,DRAW_HISTOGRAM, 0, width1, color1);
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, width1, color1);
   SetIndexStyle(2,DRAW_HISTOGRAM, 0, width2, color2);
   SetIndexStyle(3,DRAW_HISTOGRAM, 0, width2, color2);
   SetIndexStyle(4,DRAW_HISTOGRAM, 0, width3, color3);
   SetIndexStyle(5,DRAW_HISTOGRAM, 0, width3, color3);

//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double  haHigh, haLow;
   if(Bars<=10) return(0);
   ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted

   if (ExtCountedBars>0) ExtCountedBars--;
   
   int pos=Bars-ExtCountedBars-1;
   while(pos>=0)
     {
      haHigh=High[pos];
      haLow=Low[pos];

       ExtMapBuffer1[pos]=haLow;


       double lenght=High[pos]- Low[pos];

            if ( lenght >= lenght3 * Point)
            {
            ExtMapBuffer5[pos]=haLow;
            ExtMapBuffer6[pos]=haHigh; 
   
            }
           
               if (    lenght >= lenght2 * Point         )
               {
               ExtMapBuffer3[pos]=haLow;
               ExtMapBuffer4[pos]=haHigh; 
   
               }
               
                   if ( lenght >= lenght1 * Point  )
                  {
                  ExtMapBuffer1[pos]=haLow;
                  ExtMapBuffer2[pos]=haHigh; 
   
                  }
        pos--;
        }
 
 
   return(0);
  }

D_Diamond

  • Hero Member
  • *****
  • Posts: 673
    • Expert Forex Trading
แก้ตรงไหนเหรอครับ ดูๆไปก็เหมือนเดิม หาที่แก้ไม่เจอ