потому что рисует
Насколько я понял когда уже выставлена пара на определенной цене и свеча пересекает многократно эту отметку, советник
выставляет на этой цене ещё одни ордера. Получается на одной цене многократное наложение, иногда до 9 ордеров. (скрин закрытия)
//+------------------------------------------------------------------+
//| 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 Level=20;
input int Count=111;
bool b=1,s=1;
double up[],dn[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexStyle(0,DRAW_ARROW,0,2,Lime);
SetIndexArrow(0,233);
SetIndexBuffer(0,up);
SetIndexStyle(1,DRAW_ARROW,0,2,Red);
SetIndexArrow(1,234);
SetIndexBuffer(1,dn);
//---
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[])
{
//---
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 && b)
{
up[i]=low[i];
b=0;s=1;
}
if(rsi1<100-Level && rsi2>100-Level && s)
{
dn[i]=high[i];
s=0;b=1;
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
AM2