//+------------------------------------------------------------------+
//| MACDSig.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
extern int FastEMA = 12;
extern int SlowEMA = 26;
extern int SignalSMA = 9;
extern string IndName = "MACD_Signal";
double up[];
double dn[];
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
SetIndexStyle(0,DRAW_ARROW,0,2,Blue);
SetIndexArrow(0,233);
SetIndexBuffer(0,up);
SetIndexStyle(1,DRAW_ARROW,0,2,Red);
SetIndexArrow(1,234);
SetIndexBuffer(1,dn);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Up(int n=0)
{
int count=0;
double ups=0;
for(int i=0; i<Bars; i++)
{
double lim = iCustom(NULL,0,IndName,4,i);
if(lim!=EMPTY_VALUE && lim<0)
{
count++;
}
if(count==n)
{
ups=Low[i];
break;
}
}
return(ups);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Dn(int n=0)
{
int count=0;
double dns=0;
for(int i=0; i<Bars; i++)
{
double red = iCustom(NULL,0,IndName,5,i);
if(red!=EMPTY_VALUE && red>0)
{
count++;
}
if(count==n)
{
dns=High[i];
break;
}
}
return(dns);
}
//+------------------------------------------------------------------+
//| 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<Bars; i++)
{
double lim = iCustom(NULL,0,IndName,4,i);
double red = iCustom(NULL,0,IndName,5,i);
if(lim!=EMPTY_VALUE && lim<0)
up[i]=low[i];
if(red!=EMPTY_VALUE && red>0)
dn[i]=high[i];
}
Comment("\n UP1: ",Up(1),
"\n UP2: ",Up(2),
"\n UP3: ",Up(3),
"\n DN1: ",Dn(1),
"\n DN2: ",Dn(2),
"\n DN3: ",Dn(3));
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Но есть пропуски сделок также как и в тестере.
Прошу переделать советника (делал для себя на заказ).
1. ордера открываем на каждой свече?
2. открываем только бай селл?
AM2