вот индикатор yadi.sk/d/WgA-G41Z3N9U3n
//+------------------------------------------------------------------+
//| BBProcent.mq4 |
//| Copyright 2017, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Green
#property indicator_color3 Red
input int MAPeriod=8; // MA Period
input int BBPeriod=20; // Bands Period
input int BBShift=0; // Bands Shift
input double BBDeviations=2.0; // Bands Deviations
double up[];
double dn[];
double ma[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,up);
//--- upper band
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,dn);
//--- lower band
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ma);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double GetAppliedPrice(int nAppliedPrice, int nIndex)
{
double dPrice;
//----
switch(nAppliedPrice)
{
case 0: dPrice=Close[nIndex]; break;
case 1: dPrice=Open[nIndex]; break;
case 2: dPrice=High[nIndex]; break;
case 3: dPrice=Low[nIndex]; break;
case 4: dPrice=(High[nIndex]+Low[nIndex])/2.0; break;
case 5: dPrice=(High[nIndex]+Low[nIndex]+Close[nIndex])/3.0; break;
case 6: dPrice=(High[nIndex]+Low[nIndex]+2*Close[nIndex])/4.0; break;
default: dPrice=0.0;
}
//----
return(dPrice);
}
//+------------------------------------------------------------------+
//| 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<1000;i++)
{
double bup=iBands(NULL,0,BBPeriod,BBDeviations,BBShift,0,1,i);
double bdn=iBands(NULL,0,BBPeriod,BBDeviations,BBShift,0,2,i);
ma[i]=iMA(NULL,0,MAPeriod,0,0,0,i);
up[i]=bup;
dn[i]=bdn;
//ma[i]=(Close[i]-bdn)/(bup-bdn);
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Андрей, а проверку доливки (усреднения) от фильтра (машки) нельзя сделать?
double ma=iMA(NULL,0,MAPeriod,0,0,0,0);
bool b=(CountTrades(0)<1 && (Star()==1 || Pogl()==1) && (BuySell==0 || BuySell==2));
bool s=(CountTrades(1)<1 && (Star()==2 || Pogl()==2) && (BuySell==1 || BuySell==2));
bool b2=FindOrderType()==0 && FindLastBuyPrice()-Ask>=Step*Point;
bool s2=FindOrderType()==1 && Bid-FindLastSellPrice()>=Step*Point;
if(MA)
{
b=(CountTrades(0)<1 && Bid>ma && (Star()==1 || Pogl()==1) && (BuySell==0 || BuySell==2));
s=(CountTrades(1)<1 && Bid<ma && (Star()==2 || Pogl()==2) && (BuySell==1 || BuySell==2));
b2=FindOrderType()==0 && Bid>ma && FindLastBuyPrice()-Ask>=Step*Point;
s2=FindOrderType()==1 && Bid>ma && Bid-FindLastSellPrice()>=Step*Point;
}
AM2