//+------------------------------------------------------------------+
//| FF_Indicator_MA_Cross.mq4 |
//| FruitFOREX |
//| https://www.FruitFOREX.com |
//+------------------------------------------------------------------+
#property copyright "FruitFOREX"
#property link "https://www.FruitFOREX.com"
#property version "2.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_type1 DRAW_LINE
#property indicator_type2 DRAW_LINE
#property indicator_type3 DRAW_ARROW
#property indicator_type4 DRAW_ARROW
#property indicator_color1 clrYellow
#property indicator_color2 clrGreen
#property indicator_color3 clrBlue
#property indicator_color4 clrRed
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
double Fast_MA[];
double Slow_MA[];
double Up_Arrow[];
double Down_Arrow[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,Fast_MA);
SetIndexBuffer(1,Slow_MA);
SetIndexBuffer(2,Up_Arrow);
SetIndexArrow(2,233);
SetIndexBuffer(3,Down_Arrow);
SetIndexArrow(3,234);
//---
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=Bars-IndicatorCounted();
for(int i=0; i<limit; i++)
{
double current_fast_ma=iMA(NULL,0,5,0,MODE_SMA,PRICE_CLOSE,i);
double current_slow_ma=iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,i);
double previous_fast_ma=iMA(NULL,0,5,0,MODE_SMA,PRICE_CLOSE,i+1);
double previous_slow_ma=iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,i+1);
Fast_MA[i]=current_fast_ma;
Slow_MA[i]=current_slow_ma;
if(current_fast_ma>current_slow_ma && previous_fast_ma<previous_slow_ma)
{
Up_Arrow[i]=Low[i]-5*_Point;
}
else if(current_fast_ma<current_slow_ma && previous_fast_ma>previous_slow_ma)
{
Down_Arrow[i]=High[i]+5*_Point;
}
else
{
Up_Arrow[i]=EMPTY_VALUE;
Down_Arrow[i]=EMPTY_VALUE;
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
댓글
댓글 리스트-
작성자좋은군사 작성시간 16.03.18 감사 합니다 ...강의 내용 참 알차고 좋네요...
-
답댓글 작성자쟈니윤 작성자 본인 여부 작성자 작성시간 16.03.18 칭찬 감사합니다.
-
작성자하루살이 작성시간 16.03.18 교육 영상 덕분에 난장판으로 구현 하던 것을 차츰 체계적으로 블럭화 되고 있습니다..감사합니다...^^
-
작성자웅이 작성시간 16.09.09 강의 잘 듣고 있습니다.^^
골든크로스나 데드크로스때 발생하는 화살표를 표시함에 있어 Low[]나 High[] (직전캔들의 저가,고가)를 쓰면 캔들부근에 화살표가 표시되는거 아닌가요? 원하는건 이평선에 표시되어야 하는데 말이죠.. -
답댓글 작성자쟈니윤 작성자 본인 여부 작성자 작성시간 16.09.14 답변이 늦었네요. 죄송~~
네. 맞습니다. 이평선 위에 표시되면 더 알기 쉬울 수가 있겠네요. 그런데 제 생각에는 화살표가 이평선을 가려버리는게 좀 답답한 것 같아서 캔들 끝부분에서 조금 아래에 표시되도록 했습니다. 화살표는 그냥 보조적인 "표시"이기 때문에 어디에 표시되든지 주문로직에는 전혀 영향을 미치지 않습니다. ^-^