//+------------------------------------------------------------------+
//| Script_ZZ.mq4 |
//| Oxy |
//| http://oxy.opentraders.ru/bio/ |
//+------------------------------------------------------------------+
#property copyright "Oxy"
#property link "http://oxy.opentraders.ru/bio/"
#property version "1.00"
#property strict
#property show_inputs
//------- external parameters ---------------------------------------+
input int candle_index = 0; // ИНДЕКС СВЕЧИ
input string pi ="_____________"; // indicator`s parameters
input int InpDepth =12; // Depth
input int InpDeviation =5; // Deviation
input int InpBackstep =3; // Backstep
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
int value = toZZ (candle_index,InpDepth,InpDeviation,InpBackstep);
if(value==-1) Print("Зиг-зага еще нет на баре №",candle_index, " По времени бар: ", Time[candle_index]);
if(value==1) Print("Бар №",candle_index, " на ВОСХОДЯЩЕЙ линии.", " По времени бар: ", Time[candle_index]);
if(value==0) Print("Бар №",candle_index, " на НИСХОДЯЩЕЙ линии.", " По времени бар: ", Time[candle_index]);
}
//+------------------------------------------------------------------+
// 1 up; 0 down; -1 - нет еще зиг-зага
int toZZ (int index, int depth, int deviation, int backstep) {
double _right_value = valueZZright(index,depth,deviation,backstep); if(_right_value==-1) return(-1);
double _left_value = valueZZleft (index+1,depth,deviation,backstep); if(_left_value==-1) return(-1);
if(_left_value>_right_value) return(0);
else return (1);
return(-1);
}
double valueZZright (int num, int depth, int deviation, int backstep) {
for (int i=num; i>=0; i--) {
double _zz = iCustom(NULL, 0, "zigzag",depth,deviation,backstep,0,i);
if(_zz!=0.0) return(_zz);
}
return(-1);
}
double valueZZleft (int num, int depth, int deviation, int backstep) {
for (int i=num; i<Bars-1; i++) {
double _zz = iCustom(NULL, 0, "zigzag",depth,deviation,backstep,0,i);
if(_zz!=0.0) return(_zz);
}
return(-1);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Alert_forOsMA.mq4 |
//| Oxy |
//| http://oxy.opentraders.ru/bio/ |
//+------------------------------------------------------------------+
#property copyright "Oxy"
#property link "http://oxy.opentraders.ru/bio/"
#property version "1.00"
#property strict
#property indicator_chart_window
//------- external parameters ---------------------------------------+
input int fast_ema_period = 12; // Быстрое EMA:
input int slow_ema_period = 26; // Медленное EMA:
input int signal_period = 9; // MACD SMA:
input ENUM_APPLIED_PRICE applied_price = PRICE_CLOSE; // Применить к:
input double Level1 = 0.001; // Уровень 1:
input double Level2 = -0.001; // Уровень 2:
input bool SetSound = false; // звук только
input bool SetAlert = true; // alert (текст и звук)
input bool SetPush = false; // push
input bool SetMail = false; // mail
//------- global variables ------------------------------------------+
datetime _time=-1;
double _osma;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
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[])
{
string txt="";
if(rates_total==0) return(rates_total);
if(prev_calculated==0 && rates_total>0) {
_osma = iOsMA(NULL, 0, fast_ema_period, slow_ema_period, signal_period, applied_price, 0);
}
double _s_osma = iOsMA(NULL, 0, fast_ema_period, slow_ema_period, signal_period, applied_price, 0);
if(Time[0]>_time && ((_s_osma>=Level1 && _osma<Level1) || (_s_osma<=Level1 && _osma>Level1))) {
if(_s_osma>=Level1 && _osma<Level1) txt="up 1";
if(_s_osma<=Level1 && _osma>Level1) txt="dn 1";
Set_notice (txt);
_time=Time[0];
}
if(Time[0]>_time && ((_s_osma>=Level2 && _osma<Level2) || (_s_osma<=Level2 && _osma>Level2))) {
if(_s_osma>=Level2 && _osma<Level2) txt="up 2";
if(_s_osma<=Level2 && _osma>Level2) txt="dn 2";
Set_notice (txt);
_time=Time[0];
}
_osma=_s_osma;
return(rates_total);
}
//+------------------------------------------------------------------+
void Set_notice (string txt) {
if(SetSound && !SetAlert) PlaySound("alert.wav");
if(SetAlert) Alert(Symbol()+": OsMA " + txt);
if(SetPush) SendNotification(Symbol()+": OsMA " + txt);
if(SetMail) SendMail("indicator: Alert_forOsMA", Symbol()+": OsMA " + txt);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Alert_forOsMA.mq4 |
//| Oxy |
//| http://oxy.opentraders.ru/bio/ |
//+------------------------------------------------------------------+
#property copyright "Oxy"
#property link "http://oxy.opentraders.ru/bio/"
#property version "1.00"
#property strict
#property indicator_chart_window
//------- external parameters ---------------------------------------+
input int fast_ema_period = 12; // Быстрое EMA:
input int slow_ema_period = 26; // Медленное EMA:
input int signal_period = 9; // MACD SMA:
input ENUM_APPLIED_PRICE applied_price = PRICE_CLOSE; // Применить к:
input double Level1 = 0.001; // Уровень 1:
input double Level2 = -0.001; // Уровень 2:
//------- global variables ------------------------------------------+
datetime _time=-1;
double _osma;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
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[])
{
if(rates_total==0) return(rates_total);
if(prev_calculated==0 && rates_total>0) {
_osma = iOsMA(NULL, 0, fast_ema_period, slow_ema_period, signal_period, applied_price, 0);
}
double _s_osma = iOsMA(NULL, 0, fast_ema_period, slow_ema_period, signal_period, applied_price, 0);
if(Time[0]>_time && ((_s_osma>=Level1 && _osma<Level1) || (_s_osma<=Level1 && _osma>Level1))) {
Alert(Symbol(),": OsMA уровень 1!");
_time=Time[0];
}
if(Time[0]>_time && ((_s_osma>=Level2 && _osma<Level2) || (_s_osma<=Level2 && _osma>Level2))) {
Alert(Symbol(),": OsMA уровень 2!");
_time=Time[0];
}
_osma=_s_osma;
return(rates_total);
}
//+------------------------------------------------------------------+
но нет открытие ордера по закрытию свечи выше/ниже МАнаписали в комментарии. Но! в самом тех задании в топике у вас все по-другому описано:
Когда проходим МА снизу вверх — открываем покупку.
Когда проходим МА с верху в низ — открываем продажу.
Условия — открываем ордер, после закрепления свечи за МА или при касании да/нет (вкл/выкл.) как вариант сделать диапозон от МА сдвигом max/min, но это потом если…
нужен очередной советник на 1 МА, юзая поиск не нашел подобного, было близко, но не тоА чем вас этот не устроил?: coding.opentraders.ru/32713.html
ЭТО МОЙ ТРУД, ВРЕМЯ, ЗДОРОВЬЕ И ОООООЧЕНЬ БОЛЬШИЕ ДЕНЬГИ В ПОТЕРЯХ ЗА 7 ЛЕТ ТРУДА! я и так дала СЛИШКОМ МНОГО ИНФОРМАЦИИ! ДЕЛО ВАШЕ. УДАЧИ
www.youtube.com/watch?v=odshivLkjqU
Oxy