エントリータイミングを示すインジケーターではありません。
単にMT4で指定したボリンジャーσに達したときにアラームが鳴って矢印を表示するだけのものです。初期設定ではボリンジャー2.0ですが任意で変更可能。
//+------------------------------------------------------------------+
//| ニャン吉アラーム・ボリンジャー.mq4 |
//| Copyright 2023, ニャン吉ちゃんねる |
//| https://ニャン吉ちゃんねる.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, ニャン吉ちゃんねる"
#property link "https://ニャン吉ちゃんねる.com"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Orange
#property indicator_color2 Aqua
#property indicator_width1 3
#property indicator_width2 3
input double BBsigma =2.0;//ボリンジャーσ
double ArrowUp[];
double ArrowDown[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit(){
SetIndexBuffer(0,ArrowDown);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,242);
SetIndexEmptyValue(0,0.0);
SetIndexLabel(0,"arrow_Down");
SetIndexBuffer(1,ArrowUp);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,241);
SetIndexEmptyValue(1,0.0);
SetIndexLabel(1,"arrow_Up");
//---
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;
int n = 2;
if (limit > 1) {limit = rates_total - n - 1;}
for(int i=limit; i>=0; i--){
if(i+1 >= Bars-1){continue;}
double BBUpper = iBands(NULL,0,20,BBsigma,0,PRICE_CLOSE,MODE_UPPER,i);
double BBLower = iBands(NULL,0,20,BBsigma,0,PRICE_CLOSE,MODE_LOWER,i);
if(BBUpper<=High[i]){
Alert("");
ArrowUp[i] =0;
ArrowDown[i]=High[i];
}
else if(BBLower>=Low[i]){
Alert("");
ArrowUp[i]=Low[i];
ArrowDown[i]=0;
}
else{
ArrowDown[i]=0;
ArrowUp[i] =0;
}
}
return(rates_total);
}