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

ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม

  • 16 replies
  • 5,202 views
ใครก็ได้ช่วยเขียน Indicator 2ema ให้สักตัวได้ไหมครับ

เงื่อนไข BUY
1. Ema 20 ตัดขึ้นเหนือ Ema 50
2. รอให้กราฟ กลับมาชน Ema 50 แล้วเกิดลูกศรชี้ขึ้น

เงื่อนไข SELL
1. Ema 20 ตัดลงใต้ Ema 50
2. รอให้กราฟ กลับมาชน Ema 50 แล้วเกิดลูกศรชี้ลง

ให้สามารถกำหนดได้ว่า ลูกศรใหม่ที่เกิดฝั่งเดียวกัน ต้องมีระยะห่างกันอย่างน้อยกี่แท่งเทียน เช่นถ้ากำหนดเลขเป็น 10 ใน Input
ก็จะหมายความว่า เมื่อเกิดลูกศรแรกแล้ว ลูกศรฝั่งเดียวกันจะไม่เกิดอีกหากไม่เกิน 10 แท่งเทียน (อันนี้ป้องกันการเกิดลูกศรบริเวณใกล้ๆกัน ซ้ำๆกันถี่ๆ)

หวังว่าจะมีสักท่านที่ใจดีช่วยเขียนเป็น mql4 ให้ใช้งานนะครับ ขอบคุณล่วงหน้าจ้าาาาา

Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #1 เมื่อ: 30, สิงหาคม 2019, 01:18:18 PM »

ลองอันนี้เลยครับ

https://www.foxzard.com/
https://www.eabuilder.com/

ลงทะเบียนใช้งานฟรี ทำอินดี้ด้วยตัวเอง

https://www.forexgenerator.com/


Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #2 เมื่อ: 30, สิงหาคม 2019, 02:28:34 PM »
ลอง EA Buider แล้ว ทีนี้ พอได้ลูกศรมา อยากให้มันโชว์แค่อันเดียว มันทำไม่ได้ครับ
ต้องทำยังไงทีจะไม่ให้ลูกศรออกซ้ำ ประมาณว่าให้แท่นเทียนห่างไปสัก 10 แท่ง แล้วค่อยเริ่มใหม่อะไรงี้อ่ะครับ


Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #3 เมื่อ: 30, สิงหาคม 2019, 03:09:14 PM »
อ้างจาก: krabeedeodai ที่ 30, สิงหาคม  2019, 02:28:34 PM
ลอง EA Buider แล้ว ทีนี้ พอได้ลูกศรมา อยากให้มันโชว์แค่อันเดียว มันทำไม่ได้ครับ
ต้องทำยังไงทีจะไม่ให้ลูกศรออกซ้ำ ประมาณว่าให้แท่นเทียนห่างไปสัก 10 แท่ง แล้วค่อยเริ่มใหม่อะไรงี้อ่ะครับ



ตอนนี้นึกไม่ออกว่าจะเขียนออกมายังไง 


1.  ลองคิดเงื่อนไข เพิ่ม filter เข้าไปอีกสักอันดูครับ เผื่อใช้ได้ผล


2. คงต้องขอ(รอ)ให้โปรแกรมเมอร์ช่วยเขียน code ให้แล้ว เอาไปใส่ใน custom code ครับ


3. โพส file codeอินดี้ไว้ รอให้คนมาช่วยแก้ไขดูครับ


Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #4 เมื่อ: 30, สิงหาคม 2019, 10:20:07 PM »
//+------------------------------------------------------------------+
//|                                       Indicator: Trand Trade.mq4 |
//|                                       Created with EABuilder.com |
//|                                             http://eabuilder.com |
//+------------------------------------------------------------------+
#property copyright "Created with EABuilder.com"
#property link      "http://eabuilder.com"
#property version   "1.00"
#property description ""

#include <stdlib.mqh>
#include <stderror.mqh>

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2

#property indicator_type1 DRAW_ARROW
#property indicator_width1 4
#property indicator_color1 0xFFAA00
#property indicator_label1 "Buy"

#property indicator_type2 DRAW_ARROW
#property indicator_width2 4
#property indicator_color2 0x0000FF
#property indicator_label2 "Sell"

//--- indicator buffers
double Buffer1[];
double Buffer2[];

double myPoint; //initialized in OnInit

void myAlert(string type, string message)
  {
   if(type == "print")
      Print(message);
   else if(type == "error")
     {
      Print(type+" | Trand Trade @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
     }
   else if(type == "order")
     {
     }
   else if(type == "modify")
     {
     }
  }

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {   
   IndicatorBuffers(2);
   SetIndexBuffer(0, Buffer1);
   SetIndexEmptyValue(0, 0);
   SetIndexArrow(0, 241);
   SetIndexBuffer(1, Buffer2);
   SetIndexEmptyValue(1, 0);
   SetIndexArrow(1, 242);
   //initialize myPoint
   myPoint = Point();
   if(Digits() == 5 || Digits() == 3)
     {
      myPoint *= 10;
     }
   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 limit = rates_total - prev_calculated;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1, true);
   ArraySetAsSeries(Buffer2, true);
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(Buffer1, 0);
      ArrayInitialize(Buffer2, 0);
     }
   else
      limit++;
   
   //--- main loop
   for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   
      //Indicator Buffer 1
      if(iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_EMA, PRICE_CLOSE, i) > iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Moving Average > Moving Average
      && Low <= iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick Low <= Moving Average
      )
        {
         Buffer1 = Low; //Set indicator value at Candlestick Low
        }
      else
        {
         Buffer1 = 0;
        }
      //Indicator Buffer 2
      if(iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_EMA, PRICE_CLOSE, i) < iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Moving Average < Moving Average
      && High >= iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick High >= Moving Average
      )
        {
         Buffer2 = High; //Set indicator value at Candlestick High
        }
      else
        {
         Buffer2 = 0;
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+

*

admin

  • 80,402
Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #5 เมื่อ: 30, สิงหาคม 2019, 10:23:18 PM »
อ้างจาก: krabeedeodai ที่ 30, สิงหาคม  2019, 10:20:07 PM
//+------------------------------------------------------------------+
//|                                       Indicator: Trand Trade.mq4 |
//|                                       Created with EABuilder.com |
//|                                             http://eabuilder.com |
//+------------------------------------------------------------------+
#property copyright "Created with EABuilder.com"
#property link      "http://eabuilder.com"
#property version   "1.00"
#property description ""

#include <stdlib.mqh>
#include <stderror.mqh>

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2

#property indicator_type1 DRAW_ARROW
#property indicator_width1 4
#property indicator_color1 0xFFAA00
#property indicator_label1 "Buy"

#property indicator_type2 DRAW_ARROW
#property indicator_width2 4
#property indicator_color2 0x0000FF
#property indicator_label2 "Sell"

//--- indicator buffers
double Buffer1[];
double Buffer2[];

double myPoint; //initialized in OnInit

void myAlert(string type, string message)
  {
   if(type == "print")
      Print(message);
   else if(type == "error")
     {
      Print(type+" | Trand Trade @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
     }
   else if(type == "order")
     {
     }
   else if(type == "modify")
     {
     }
  }

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {   
   IndicatorBuffers(2);
   SetIndexBuffer(0, Buffer1);
   SetIndexEmptyValue(0, 0);
   SetIndexArrow(0, 241);
   SetIndexBuffer(1, Buffer2);
   SetIndexEmptyValue(1, 0);
   SetIndexArrow(1, 242);
   //initialize myPoint
   myPoint = Point();
   if(Digits() == 5 || Digits() == 3)
     {
      myPoint *= 10;
     }
   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 limit = rates_total - prev_calculated;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1, true);
   ArraySetAsSeries(Buffer2, true);
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(Buffer1, 0);
      ArrayInitialize(Buffer2, 0);
     }
   else
      limit++;
   
   //--- main loop
   for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   
      //Indicator Buffer 1
      if(iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_EMA, PRICE_CLOSE, i) > iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Moving Average > Moving Average
      && Low <= iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick Low <= Moving Average
      )
        {
         Buffer1 = Low; //Set indicator value at Candlestick Low
        }
      else
        {
         Buffer1 = 0;
        }
      //Indicator Buffer 2
      if(iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_EMA, PRICE_CLOSE, i) < iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Moving Average < Moving Average
      && High >= iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick High >= Moving Average
      )
        {
         Buffer2 = High; //Set indicator value at Candlestick High
        }
      else
        {
         Buffer2 = 0;
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+

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

Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #6 เมื่อ: 31, สิงหาคม 2019, 07:47:25 AM »
อ้างจาก: admin ที่ 30, สิงหาคม  2019, 10:23:18 PM
อ้างจาก: krabeedeodai ที่ 30, สิงหาคม  2019, 10:20:07 PM
//+------------------------------------------------------------------+
//|                                       Indicator: Trand Trade.mq4 |
//|                                       Created with EABuilder.com |
//|                                             http://eabuilder.com |
//+------------------------------------------------------------------+
#property copyright "Created with EABuilder.com"
#property link      "http://eabuilder.com"
#property version   "1.00"
#property description ""

#include <stdlib.mqh>
#include <stderror.mqh>

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2

#property indicator_type1 DRAW_ARROW
#property indicator_width1 4
#property indicator_color1 0xFFAA00
#property indicator_label1 "Buy"

#property indicator_type2 DRAW_ARROW
#property indicator_width2 4
#property indicator_color2 0x0000FF
#property indicator_label2 "Sell"

//--- indicator buffers
double Buffer1[];
double Buffer2[];

double myPoint; //initialized in OnInit

void myAlert(string type, string message)
  {
   if(type == "print")
      Print(message);
   else if(type == "error")
     {
      Print(type+" | Trand Trade @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
     }
   else if(type == "order")
     {
     }
   else if(type == "modify")
     {
     }
  }

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {   
   IndicatorBuffers(2);
   SetIndexBuffer(0, Buffer1);
   SetIndexEmptyValue(0, 0);
   SetIndexArrow(0, 241);
   SetIndexBuffer(1, Buffer2);
   SetIndexEmptyValue(1, 0);
   SetIndexArrow(1, 242);
   //initialize myPoint
   myPoint = Point();
   if(Digits() == 5 || Digits() == 3)
     {
      myPoint *= 10;
     }
   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 limit = rates_total - prev_calculated;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1, true);
   ArraySetAsSeries(Buffer2, true);
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(Buffer1, 0);
      ArrayInitialize(Buffer2, 0);
     }
   else
      limit++;
   
   //--- main loop
   for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   
      //Indicator Buffer 1
      if(iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_EMA, PRICE_CLOSE, i) > iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Moving Average > Moving Average
      && Low <= iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick Low <= Moving Average
      )
        {
         Buffer1 = Low; //Set indicator value at Candlestick Low
        }
      else
        {
         Buffer1 = 0;
        }
      //Indicator Buffer 2
      if(iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_EMA, PRICE_CLOSE, i) < iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Moving Average < Moving Average
      && High >= iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick High >= Moving Average
      )
        {
         Buffer2 = High; //Set indicator value at Candlestick High
        }
      else
        {
         Buffer2 = 0;
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+

เดี๋ยว ทีม Programmer จะ ดูให้นะ ครับผม
(TH)**
(TH)** (TH)** (TH)** (TH)**
ขอบคุณมากมายครับ

*

iRuler

  • 1,282
Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #7 เมื่อ: 31, สิงหาคม 2019, 09:36:38 AM »
โค๊ด [Select]
//+------------------------------------------------------------------+
//|                                       Indicator: Trand Trade.mq4 |
//|                                       Created with EABuilder.com |
//|                                             http://eabuilder.com |
//|                                 Modified by [email protected]|
//+------------------------------------------------------------------+
#property copyright "Created with EABuilder.com"
#property link      "http://eabuilder.com"
#property version   "1.00"
#property description ""

#include <stdlib.mqh>
#include <stderror.mqh>

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2

#property indicator_type1 DRAW_ARROW
#property indicator_width1 4
#property indicator_color1 0xFFAA00
#property indicator_label1 "Buy"

#property indicator_type2 DRAW_ARROW
#property indicator_width2 4
#property indicator_color2 0x0000FF
#property indicator_label2 "Sell"

//--- indicator buffers
double Buffer1[];
double Buffer2[];

double myPoint; //initialized in OnInit
int latest_low_index=0;
int latest_hi_index=0;

input int MinDistance=10;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void myAlert(string type,string message)
  {
   if(type=="print")
      Print(message);
   else if(type=="error")
     {
      Print(type+" | Trand Trade @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
     }
   else if(type=="order")
     {
     }
   else if(type=="modify")
     {
     }
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   IndicatorBuffers(2);
   SetIndexBuffer(0,Buffer1);
   SetIndexEmptyValue(0,0);
   SetIndexArrow(0,241);
   SetIndexBuffer(1,Buffer2);
   SetIndexEmptyValue(1,0);
   SetIndexArrow(1,242);
//initialize myPoint
   myPoint=Point();
   if(Digits()==5 || Digits()==3)
     {
      myPoint*=10;
     }
   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 limit=rates_total-prev_calculated;
//--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1,true);
   ArraySetAsSeries(Buffer2,true);
//--- initial zero
   if(prev_calculated<1)
     {
      ArrayInitialize(Buffer1,0);
      ArrayInitialize(Buffer2,0);
     }
   else
      limit++;

//--- main loop
   latest_low_index=limit;
   latest_hi_index=limit;

   for(int i=limit-1; i>=0; i--)
     {
      if(i>=MathMin(5000-1,rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   
                                                        //Indicator Buffer 1
      if(iMA(NULL,PERIOD_CURRENT,20,0,MODE_EMA,PRICE_CLOSE,i)>iMA(NULL,PERIOD_CURRENT,50,0,MODE_EMA,PRICE_CLOSE,i) //Moving Average > Moving Average
         && Low[i]<=iMA(NULL,PERIOD_CURRENT,50,0,MODE_EMA,PRICE_CLOSE,i) //Candlestick Low <= Moving Average
         && latest_low_index-i>MinDistance
         )
        {
         Buffer1[i]=Low[i]; //Set indicator value at Candlestick Low
         latest_low_index=i;
        }
      else
        {
         Buffer1[i]=0;
        }
      //Indicator Buffer 2
      if(iMA(NULL,PERIOD_CURRENT,20,0,MODE_EMA,PRICE_CLOSE,i)<iMA(NULL,PERIOD_CURRENT,50,0,MODE_EMA,PRICE_CLOSE,i) //Moving Average < Moving Average
         && High[i]>=iMA(NULL,PERIOD_CURRENT,50,0,MODE_EMA,PRICE_CLOSE,i) //Candlestick High >= Moving Average
         && latest_hi_index-i>MinDistance
         )
        {
         Buffer2[i]=High[i]; //Set indicator value at Candlestick High
         latest_hi_index=i;
        }
      else
        {
         Buffer2[i]=0;
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+



Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #8 เมื่อ: 31, สิงหาคม 2019, 10:50:23 AM »
ขอบคุณมากครับท่าน iRuler


สอบถามครับว่า เราสามารถเขียนให้อินดี้แสดงผลออกลูกศรเยื้องไปจากที่ออกสัญญาญสัก 2 แท่งเทียน ได้ใหมครับ

คือสมมุติอย่างที่เห็น อินดี้ลูกศรทั่วไปที่มันออก จะแสดงที่แท่งที่มีราคาต่ำสุด หรือสูงสุด ซึ่งตอนที่มันออกต้องปิดแท่งเทียนก่อน ดังนั้นราคาที่อินดี้แสดงมันไม่ใช่แท่งนั้นหรือจุดนั้นแล้ว ราคาจริงๆ และเวลาเราใช้งานจริงๆ มันเลยไปนานแล้ว กว่าที่เรามาเห็น หรือแม้แต่ทำตัว alert เตือนแล้วมาดู มันก็ไม่ใช่จุดที่แสดงลูกศร จุดเข้าสวยๆ แล้ว 

ที่อยากลองทำก็คือโมให้จุดที่มันออก signal เป็นจุดไข่ปลา แล้วเลื่อนออกไปสัก 2-3 แท่งเทียน แล้วออกลูกศรชี้ เพื่อเอามาเปิดดูคล้าย backtest ว่าอินดี้มันออกสัญยาณแล้วกว่าเราจะเข้าอีกนาน มันจะทันและเอามาใช้งานดีหรือเปล่า ถ้าไม่ work ก็จะไม่ได้ใช้งาน ไม่ต้องเสียเวลามานั่ง backtest และ forward test อีกให้เสียเวลา

ต้องแทรก code ยังไง เข้าไปตรงจุดที่มัน เช็คค่า buffer ให้ออก signal ลูกศรครับ

Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #9 เมื่อ: 31, สิงหาคม 2019, 05:45:01 PM »

สอบถามอีกเคสครับท่าน iRuler  สามารถทำได้ใหมครับ

อินดี้ข้างบน ถ้าอันแรกๆเป็น fail signal บ่อย เราสามารถเขียนให้มัน แสดง signal อันสุดท้ายได้ใหมครับ ประมาณว่าให้แสดง signal อันที่ 4
อย่างเช่นรูปแรก มันมีลูกศรติดๆ กัน 5 อัน  เราจะสามารถสั่งให้มันโชวเฉพาะอันที่ 4 และ 5 ได้ใหมครับ
คือลูกศร 5 อันติดๆ กัน  ให้ซ่อนอันที่ 1234 แล้วแสดงเฉพาะ อันที่ 5  หรือ ลูกศร 5 อันติดกัน ให้แสดงอันที่ 1-2-3-4 เป็นแสดงเครื่องหมายจุดไข่ปลา หรือกากะบาท  แล้วอันที่ 4 และ 5 เป็นแสดงเป็นลูกศร แบบนี้ได้ใหมครับ



Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #10 เมื่อ: 31, สิงหาคม 2019, 06:05:58 PM »
อ้างจาก: iRuler ที่ 31, สิงหาคม  2019, 09:36:38 AM
โค๊ด [Select]
//+------------------------------------------------------------------+
//|                                       Indicator: Trand Trade.mq4 |
//|                                       Created with EABuilder.com |
//|                                             http://eabuilder.com |
//|                                 Modified by [email protected]|
//+------------------------------------------------------------------+
#property copyright "Created with EABuilder.com"
#property link      "http://eabuilder.com"
#property version   "1.00"
#property description ""

#include <stdlib.mqh>
#include <stderror.mqh>

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2

#property indicator_type1 DRAW_ARROW
#property indicator_width1 4
#property indicator_color1 0xFFAA00
#property indicator_label1 "Buy"

#property indicator_type2 DRAW_ARROW
#property indicator_width2 4
#property indicator_color2 0x0000FF
#property indicator_label2 "Sell"

//--- indicator buffers
double Buffer1[];
double Buffer2[];

double myPoint; //initialized in OnInit
int latest_low_index=0;
int latest_hi_index=0;

input int MinDistance=10;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void myAlert(string type,string message)
  {
   if(type=="print")
      Print(message);
   else if(type=="error")
     {
      Print(type+" | Trand Trade @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
     }
   else if(type=="order")
     {
     }
   else if(type=="modify")
     {
     }
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   IndicatorBuffers(2);
   SetIndexBuffer(0,Buffer1);
   SetIndexEmptyValue(0,0);
   SetIndexArrow(0,241);
   SetIndexBuffer(1,Buffer2);
   SetIndexEmptyValue(1,0);
   SetIndexArrow(1,242);
//initialize myPoint
   myPoint=Point();
   if(Digits()==5 || Digits()==3)
     {
      myPoint*=10;
     }
   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 limit=rates_total-prev_calculated;
//--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1,true);
   ArraySetAsSeries(Buffer2,true);
//--- initial zero
   if(prev_calculated<1)
     {
      ArrayInitialize(Buffer1,0);
      ArrayInitialize(Buffer2,0);
     }
   else
      limit++;

//--- main loop
   latest_low_index=limit;
   latest_hi_index=limit;

   for(int i=limit-1; i>=0; i--)
     {
      if(i>=MathMin(5000-1,rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   
                                                        //Indicator Buffer 1
      if(iMA(NULL,PERIOD_CURRENT,20,0,MODE_EMA,PRICE_CLOSE,i)>iMA(NULL,PERIOD_CURRENT,50,0,MODE_EMA,PRICE_CLOSE,i) //Moving Average > Moving Average
         && Low[i]<=iMA(NULL,PERIOD_CURRENT,50,0,MODE_EMA,PRICE_CLOSE,i) //Candlestick Low <= Moving Average
         && latest_low_index-i>MinDistance
         )
        {
         Buffer1[i]=Low[i]; //Set indicator value at Candlestick Low
         latest_low_index=i;
        }
      else
        {
         Buffer1[i]=0;
        }
      //Indicator Buffer 2
      if(iMA(NULL,PERIOD_CURRENT,20,0,MODE_EMA,PRICE_CLOSE,i)<iMA(NULL,PERIOD_CURRENT,50,0,MODE_EMA,PRICE_CLOSE,i) //Moving Average < Moving Average
         && High[i]>=iMA(NULL,PERIOD_CURRENT,50,0,MODE_EMA,PRICE_CLOSE,i) //Candlestick High >= Moving Average
         && latest_hi_index-i>MinDistance
         )
        {
         Buffer2[i]=High[i]; //Set indicator value at Candlestick High
         latest_hi_index=i;
        }
      else
        {
         Buffer2[i]=0;
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+




ขอบพระคุณมากมายเหลือเกินครับ

*

iRuler

  • 1,282
Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #11 เมื่อ: 01, กันยายน 2019, 10:43:12 AM »
อ้างจาก: forcebewithyou ที่ 31, สิงหาคม  2019, 05:45:01 PM

สอบถามอีกเคสครับท่าน iRuler  สามารถทำได้ใหมครับ

อินดี้ข้างบน ถ้าอันแรกๆเป็น fail signal บ่อย เราสามารถเขียนให้มัน แสดง signal อันสุดท้ายได้ใหมครับ ประมาณว่าให้แสดง signal อันที่ 4
อย่างเช่นรูปแรก มันมีลูกศรติดๆ กัน 5 อัน  เราจะสามารถสั่งให้มันโชวเฉพาะอันที่ 4 และ 5 ได้ใหมครับ
คือลูกศร 5 อันติดๆ กัน  ให้ซ่อนอันที่ 1234 แล้วแสดงเฉพาะ อันที่ 5  หรือ ลูกศร 5 อันติดกัน ให้แสดงอันที่ 1-2-3-4 เป็นแสดงเครื่องหมายจุดไข่ปลา หรือกากะบาท  แล้วอันที่ 4 และ 5 เป็นแสดงเป็นลูกศร แบบนี้ได้ใหมครับ




โค๊ด [Select]
if(i+4<limit-1 && Buffer1[i+1]>0 && Buffer1[i+2]>0&& Buffer1[i+3]>0&& Buffer1[i+4]>0)
Buffer1[i]=Low[i];


แบบนี้น่าจะได้นะครับ Indicator ผมไม่ถนัด

(TH)**

Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #12 เมื่อ: 01, กันยายน 2019, 11:35:56 AM »
อ้างจาก: iRuler ที่ 01, กันยายน  2019, 10:43:12 AM
อ้างจาก: forcebewithyou ที่ 31, สิงหาคม  2019, 05:45:01 PM

สอบถามอีกเคสครับท่าน iRuler  สามารถทำได้ใหมครับ

อินดี้ข้างบน ถ้าอันแรกๆเป็น fail signal บ่อย เราสามารถเขียนให้มัน แสดง signal อันสุดท้ายได้ใหมครับ ประมาณว่าให้แสดง signal อันที่ 4
อย่างเช่นรูปแรก มันมีลูกศรติดๆ กัน 5 อัน  เราจะสามารถสั่งให้มันโชวเฉพาะอันที่ 4 และ 5 ได้ใหมครับ
คือลูกศร 5 อันติดๆ กัน  ให้ซ่อนอันที่ 1234 แล้วแสดงเฉพาะ อันที่ 5  หรือ ลูกศร 5 อันติดกัน ให้แสดงอันที่ 1-2-3-4 เป็นแสดงเครื่องหมายจุดไข่ปลา หรือกากะบาท  แล้วอันที่ 4 และ 5 เป็นแสดงเป็นลูกศร แบบนี้ได้ใหมครับ




โค๊ด [Select]
if(i+4<limit-1 && Buffer1[i+1]>0 && Buffer1[i+2]>0&& Buffer1[i+3]>0&& Buffer1[i+4]>0)
Buffer1[i]=Low[i];


แบบนี้น่าจะได้นะครับ Indicator ผมไม่ถนัด

(TH)**

ขอบคุณมากครับท่าน

Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #13 เมื่อ: 01, กันยายน 2019, 01:20:47 PM »
ท่าน  iRuler ครับ
จะพอช่วยอีกสักนิดได้ไหมครับ ให้ลูกศรออกแค่ครั้งแรกครั้งเดียว ไม่ออกอีกเลยจนกว่าจะมีลูกศรอีกฝั่งเกิดขึ้น ถึงเริ่มใหม่
เช่น เมื่อเกิดลูกศรชี้ขึ้น ก็ให้รอเกิดลูกศรชี้ลง เมื่อลูกศรชี้ลงเกิดแล้วก็ให้รอลูกศรชี้ขึ้น วนสลับไปแบบนี้

ผมก็อธิบายไม่ค่อยเก่ง แต่ก็คือ ถ้าลูกศรฝั่งใดฝั่งหนึ่งเกิดแล้ว ก็ให้รออีกฝั่งเท่านั้น มันจะไม่ออกอีกเลย จนกว่าจะมีอีกฝั่ง

หากไม่รบกวนเกินไป อยากขออนุญาตช่วยเหลืออีกทีหน่อยครับ ขอบพระคุณมากเลยครับ

*

iRuler

  • 1,282
Re: ใครใจดีช่วยเขียน Indicator ง่ายๆให้สักตัวได้ไหม
« ตอบกลับ #14 เมื่อ: 01, กันยายน 2019, 10:04:10 PM »
เดวพรุ่งนี้ดูให้ครับ