0
После выходных гляну.
avatar

AM2

  • 2 июля 2016, 19:21
+1
Есть ссылка?
avatar

AM2

  • 2 июля 2016, 19:20
+1
Готово:




//+------------------------------------------------------------------+
//|                                                  Custom MACD.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "http://www.mql4.com"
#property description "Moving Averages Convergence/Divergence"
#property strict

#include <MovingAverages.mqh>

//--- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Silver
#property  indicator_color3  Blue
#property  indicator_color2  Red
#property  indicator_width1  2
#property  indicator_width3  2
//--- indicator parameters
input int InpFastEMA=12;   // Fast EMA Period
input int InpSlowEMA=26;   // Slow EMA Period
input int InpSignalSMA=9;  // Signal SMA Period

input int Procent = 80;
//--- indicator buffers
double    ExtMacdBuffer[];
double    ExtSignalBuffer[];
double    ExtMacdBlueBuffer[];
//--- right input parameters flag
bool      ExtParameters=false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   IndicatorDigits(Digits+1);
//--- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexDrawBegin(1,InpSignalSMA);
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtMacdBuffer);
   SetIndexBuffer(1,ExtSignalBuffer);
   SetIndexBuffer(2,ExtMacdBlueBuffer);
//--- name for DataWindow and indicator subwindow label
   IndicatorShortName("MACD("+IntegerToString(InpFastEMA)+","+IntegerToString(InpSlowEMA)+","+IntegerToString(InpSignalSMA)+")");
   SetIndexLabel(0,"MACD");
   SetIndexLabel(1,"Signal");
//--- check for input parameters
   if(InpFastEMA<=1 || InpSlowEMA<=1 || InpSignalSMA<=1 || InpFastEMA>=InpSlowEMA)
     {
      Print("Wrong input parameters");
      ExtParameters=false;
      return(INIT_FAILED);
     }
   else
      ExtParameters=true;
//--- initialization done
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
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[])
  {
   int i,limit;
//---
   if(rates_total<=InpSignalSMA || !ExtParameters)
      return(0);
//--- last counted bar will be recounted
   limit=rates_total-prev_calculated;
   if(prev_calculated>0)
      limit++;
//--- macd counted in the 1-st buffer
   for(i=0; i<limit; i++)
     {
      ExtMacdBuffer[i]=iMA(NULL,0,InpFastEMA,0,MODE_EMA,PRICE_CLOSE,i)-
                       iMA(NULL,0,InpSlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
      ExtMacdBlueBuffer[i]=ExtMacdBuffer[i]*Procent*0.01;
     }
//--- signal line counted in the 2-nd buffer
   SimpleMAOnBuffer(rates_total,prev_calculated,0,InpSignalSMA,ExtMacdBuffer,ExtSignalBuffer);
//--- done
   return(rates_total);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 2 июля 2016, 18:21
0
Я даже не представляю как это сделать, если вообще возможно.
avatar

AM2

  • 2 июля 2016, 17:22
0
Один бар в разные цвета не берусь красить.
avatar

AM2

  • 2 июля 2016, 17:19
0
Настройки добавлю после выходных, мм тоже, а сигнал по машкам опишите. Судя по скринам индикатора, стрелка появляется когда идет пересечение 50 и 100. Так могу сделать.
avatar

AM2

  • 1 июля 2016, 19:38
0
Вот переписанный вариант, вход когда 3 вряд, выход 50><100. Если наложить, один в один входы выходы.




//+------------------------------------------------------------------+
//|                                                          3MA.mq4 |
//|                                              Copyright 2016, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.00"
#property description "Simple expert advisor"

//--- Inputs

extern int    MA1Period     = 50;
extern int    MA2Period     = 100;
extern int    MA3Period     = 200;

extern int    StopLoss      = 500;
extern int    TakeProfit    = 500;
extern int    Slip          = 30;
extern int    TrailingStop  = 0;
extern double Lots          = 0.1;
extern int    Magic         = 123;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Comment("");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountTrades()
  {
   int count=0;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()<2) count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
  {
   int r=0;
   color clr=Green;
   double sl=0,tp=0;

   if(type==1 || type==3 || type==5)
     {
      clr=Red;
      if(StopLoss>0) sl=NormalizeDouble(price+StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
     }

   if(type==0 || type==2 || type==4)
     {
      clr=Blue;
      if(StopLoss>0) sl=NormalizeDouble(price-StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
     }

   r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
   return;
  }
//+------------------------------------------------------------------+
//| Закрытие позиции по типу ордера                                  |
//+------------------------------------------------------------------+
void CloseAll(int ot=-1)
  {
   bool cl;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==0 && (ot==0 || ot==-1))
              {
               RefreshRates();
               cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),Slip,White);
              }
            if(OrderType()==1 && (ot==1 || ot==-1))
              {
               RefreshRates();
               cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),Slip,White);
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OpenPos()
  {
   double MA1=iMA(NULL,0,MA1Period,0,1,0,1);
   double MA2=iMA(NULL,0,MA2Period,0,1,0,1);
   double MA3=iMA(NULL,0,MA3Period,0,1,0,1);
   double MA12=iMA(NULL,0,MA1Period,0,1,0,2);
   double MA22=iMA(NULL,0,MA2Period,0,1,0,2);
   double MA32=iMA(NULL,0,MA3Period,0,1,0,2);

   bool buy=MA1>MA2 && MA1>MA3;
   bool sell=MA1<MA2 && MA1<MA3;

//--- sell 
   if(sell)
     {
      PutOrder(1,Bid);
     }

//--- buy 
   if(buy)
     {
      PutOrder(0,Ask);
     }
//---
  }
//+------------------------------------------------------------------+
void ClosePos()
  {
   double MA1=iMA(NULL,0,MA1Period,0,1,0,1);
   double MA2=iMA(NULL,0,MA2Period,0,1,0,1);
   double MA3=iMA(NULL,0,MA3Period,0,1,0,1);
   double MA12=iMA(NULL,0,MA1Period,0,1,0,2);
   double MA22=iMA(NULL,0,MA2Period,0,1,0,2);
   double MA32=iMA(NULL,0,MA3Period,0,1,0,2);

   bool buy=MA1>MA2;
   bool sell=MA1<MA2;

   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderMagicNumber()==Magic || OrderSymbol()==Symbol())
           {
            //--- check order type 
            if(OrderType()==OP_BUY)
               if(sell) CloseAll(0);

            if(OrderType()==OP_SELL)
               if(buy)CloseAll(1);
           }
        }
     }
//---
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Trailing()
  {
   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
            if(OrderType()==OP_BUY)
              {
               if(TrailingStop>0)
                 {
                  double BID=MarketInfo(Symbol(),MODE_BID);
                  if(BID-OrderOpenPrice()>Point*TrailingStop)
                    {
                     if(OrderStopLoss()<BID-Point*TrailingStop)
                       {
                        bool m=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(BID-Point*TrailingStop,Digits),OrderTakeProfit(),0,Yellow);
                       }
                    }
                 }
              }

      if(OrderType()==OP_SELL)
        {
         if(TrailingStop>0)
           {
            double ASK=MarketInfo(Symbol(),MODE_ASK);
            if((OrderOpenPrice()-ASK)>(Point*TrailingStop))
              {
               if((OrderStopLoss()>(ASK+Point*TrailingStop)) || (OrderStopLoss()==0))
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(ASK+Point*TrailingStop,Digits),OrderTakeProfit(),0,Yellow);
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| OnTick function                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(CountTrades()<1) OpenPos();
   if(CountTrades()>0) ClosePos();

   if(TrailingStop>0) Trailing();
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 1 июля 2016, 17:06
0
Вечером еще сам проверю.
avatar

AM2

  • 1 июля 2016, 11:59
0
Сейчас есть все самые основные моменты ТЗ. И это нарисовало мне такую картику за полтора года <img src='http://opentraders.ru/templates/skin/g6h/images/smilies/002.gif' alt=' :) '>&nbsp; 



www.opentraders.ru/downloads/1226/
avatar

AM2

  • 1 июля 2016, 11:36
0
Cоветник непростой, буду делать шаг за шагом. Сейчас есть тянулка и бу.




//+------------------------------------------------------------------+
//|                                                        Casha.mq4 |
//|                                              Copyright 2016, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.00"

//--- Inputs
extern double Lots       = 0.1;      // лот
extern int StopLoss      = 50;       // лось
extern int TakeProfit    = 70;       // язь
extern int BULevel       = 0;        // уровень БУ
extern int BUPoint       = 30;       // пункты БУ
extern int Expiration    = 3;        // истечение ордера в часах
extern int Delta         = 100;      // дельта
extern int Slip          = 30;       // реквот
extern int Magic         = 123;      // магик

datetime t=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Comment("");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
  {
   int r=0;
   color clr=Green;
   double sl=0,tp=0;

   if(type==1 || type==3 || type==5)
     {
      clr=Red;
      if(StopLoss>0) sl=NormalizeDouble(price+StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
     }

   if(type==0 || type==2 || type==4)
     {
      clr=Blue;
      if(StopLoss>0) sl=NormalizeDouble(price-StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
     }

   r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,TimeCurrent()+Expiration*3600,clr);
   return;
  }
//+------------------------------------------------------------------+
//| Подсчет ордеров по типу                                          |
//+------------------------------------------------------------------+
int CountOrders(int type)
  {
   int count=0;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==type) count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BU()
  {
   bool m;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(OrderOpenPrice()<=(Bid-(BULevel+BUPoint)*Point) && OrderOpenPrice()>OrderStopLoss())
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+BUPoint*Point,OrderTakeProfit(),0,Yellow);
                  return;
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if(OrderOpenPrice()>=(Ask+(BULevel+BUPoint)*Point) && (OrderOpenPrice()<OrderStopLoss() || OrderStopLoss()==0))
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-BUPoint*Point,OrderTakeProfit(),0,Yellow);
                  return;
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Mode()
  {
   bool m;
   double delta=0;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUYSTOP)
              {
               delta=NormalizeDouble(OrderOpenPrice()-Bid,Digits);
               if(delta>Delta*Point)
                 {
                  m=OrderModify(OrderTicket(),NormalizeDouble(Bid+Delta*Point,Digits),OrderStopLoss(),OrderTakeProfit(),0,Yellow);
                  return;
                 }
              }

            if(OrderType()==OP_SELLSTOP)
              {
               delta=NormalizeDouble(Bid-OrderOpenPrice(),Digits);
               if(delta>Delta*Point)
                 {                  
                  m=OrderModify(OrderTicket(),NormalizeDouble(Bid-Delta*Point,Digits),OrderStopLoss(),OrderTakeProfit(),0,Yellow);
                  return;
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   Mode();
   if(BULevel>0) BU();
   if(CountOrders(4)<1) PutOrder(4,Bid+Delta*Point);
   if(CountOrders(5)<1) PutOrder(5,Bid-Delta*Point);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 1 июля 2016, 11:08
0
Сейчас буду смотреть.
avatar

AM2

  • 1 июля 2016, 10:27
0
Скачайте советник по ссылке выше, поставьте МА 50,100 и 200 и увидите.
avatar

AM2

  • 1 июля 2016, 10:20
0
Дайте кому то еще потестить, если нормально то что то у вас.
avatar

AM2

  • 30 июня 2016, 23:49
0
Поставил, 3 машки они и в африке 3 машки :) 

avatar

AM2

  • 30 июня 2016, 23:43
0
Значки штатного фрактала не нужны(либо параметр на отключение). Нужны только точки и только в местах пропадания фрактала, желательно с отображением истории. Точка ровно на том месте, где пропал, без смещения.

Доделал все таки, но раз Анатолий просил не светить лишний раз, не буду <img src='http://opentraders.ru/templates/skin/g6h/images/smilies/002.gif' alt=' :) '>&nbsp; 

На форуме реально помогли! *good* 


avatar

AM2

  • 30 июня 2016, 23:30