но у меня почему то одна единственная стрелка(на покупку) за всю историю
Вы наверное не тот индикатор загрузили.
//+------------------------------------------------------------------+
//| RSICross.mq4 |
//| Copyright 2021, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
input int RSI=7;
input int Num=3;
input int Level=30;
input int Count=666;
double up[],dn[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexStyle(0,DRAW_ARROW,0,1,Aqua);
SetIndexArrow(0,233);
SetIndexBuffer(0,up);
SetIndexStyle(1,DRAW_ARROW,0,1,Red);
SetIndexArrow(1,234);
SetIndexBuffer(1,dn);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double PointPrice(int type,int k=0,int n=0)
{
int num=0;
double pr=0;
for(int i=k; i<Count; i++)
{
double rsi1=iRSI(NULL,0,RSI,0,i);
double rsi2=iRSI(NULL,0,RSI,0,i+1);
if(rsi1>Level && rsi2<Level && type==0)
num++;
if(rsi1<100-Level && rsi2>100-Level && type==1)
num++;
if(num==n)
{
pr=Close[i];
break;
}
}
return(pr);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
for(int i=0; i<Count; i++)
{
double rsi1=iRSI(NULL,0,RSI,0,i);
double rsi2=iRSI(NULL,0,RSI,0,i+1);
if(rsi1>Level && rsi2<Level && PointPrice(0,i,1)<PointPrice(0,i,2) && PointPrice(0,i,1)<PointPrice(0,i,Num))
{
up[i]=low[i];
}
if(rsi1<100-Level && rsi2>100-Level && PointPrice(1,i,1)>PointPrice(1,i,2) && PointPrice(1,i,1)>PointPrice(1,i,Num))
{
dn[i]=high[i];
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
AM2