0
Мне будет намного проще и быстрее написать с нуля. Опишите ТЗ целиком максимально подробно. Вот образец: am2.opentraders.ru/29048.html
avatar

AM2

  • 1 марта 2016, 10:01
+1
Сделал:




//+------------------------------------------------------------------+
//|                                                        Bands.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 "Bollinger Bands"
#property strict

#include <MovingAverages.mqh>

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 LightSeaGreen
#property indicator_color2 LightSeaGreen
#property indicator_color3 LightSeaGreen
//--- indicator parameters
input int    InpBandsPeriod=20;      // Bands Period
input int    InpBandsShift=0;        // Bands Shift
input double InpBandsDeviations=1.0; // Bands Deviations
//--- buffers
double ExtMovingBuffer[];
double ExtUpperBuffer[];
double ExtLowerBuffer[];
double ExtStdDevBuffer[];

int b=0,s=0;
datetime t=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
//--- 1 additional buffer used for counting.
   IndicatorBuffers(4);
   IndicatorDigits(Digits);
//--- middle line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMovingBuffer);
   SetIndexShift(0,InpBandsShift);
   SetIndexLabel(0,"Bands SMA");
//--- upper band
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtUpperBuffer);
   SetIndexShift(1,InpBandsShift);
   SetIndexLabel(1,"Bands Upper");
//--- lower band
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtLowerBuffer);
   SetIndexShift(2,InpBandsShift);
   SetIndexLabel(2,"Bands Lower");
//--- work buffer
   SetIndexBuffer(3,ExtStdDevBuffer);
//--- check for input parameter
   if(InpBandsPeriod<=0)
     {
      Print("Wrong input parameter Bands Period=",InpBandsPeriod);
      return(INIT_FAILED);
     }
//---
   SetIndexDrawBegin(0,InpBandsPeriod+InpBandsShift);
   SetIndexDrawBegin(1,InpBandsPeriod+InpBandsShift);
   SetIndexDrawBegin(2,InpBandsPeriod+InpBandsShift);
//--- initialization done
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Bollinger Bands                                                  |
//+------------------------------------------------------------------+
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,pos;
//---
   if(rates_total<=InpBandsPeriod || InpBandsPeriod<=0)
      return(0);
//--- counting from 0 to rates_total
   ArraySetAsSeries(ExtMovingBuffer,false);
   ArraySetAsSeries(ExtUpperBuffer,false);
   ArraySetAsSeries(ExtLowerBuffer,false);
   ArraySetAsSeries(ExtStdDevBuffer,false);
   ArraySetAsSeries(close,false);

//--- initial zero
   if(prev_calculated<1)
     {
      for(i=0; i<InpBandsPeriod; i++)
        {
         ExtMovingBuffer[i]=EMPTY_VALUE;
         ExtUpperBuffer[i]=EMPTY_VALUE;
         ExtLowerBuffer[i]=EMPTY_VALUE;
        }
     }
//--- starting calculation
   if(prev_calculated>1)
      pos=prev_calculated-1;
   else
      pos=0;
//--- main cycle
   for(i=pos; i<rates_total && !IsStopped(); i++)
     {
      //--- middle line
      ExtMovingBuffer[i]=SimpleMA(i,InpBandsPeriod,close);
      //--- calculate and write down StdDev
      ExtStdDevBuffer[i]=StdDev_Func(i,close,ExtMovingBuffer,InpBandsPeriod);
      //--- upper line
      ExtUpperBuffer[i]=ExtMovingBuffer[i]+InpBandsDeviations*ExtStdDevBuffer[i];
      //--- lower line
      ExtLowerBuffer[i]=ExtMovingBuffer[i]-InpBandsDeviations*ExtStdDevBuffer[i];
      //---
     }
/*
   Comment("\n UP1: ",ExtUpperBuffer[rates_total-1],
           "\n DN1: ",ExtLowerBuffer[rates_total-1],
           "\n CL1: ",close[rates_total-1],
           "\n LOW1: ",low[1]);
*/
   double up=ExtUpperBuffer[rates_total-2];
   double dn=ExtLowerBuffer[rates_total-2];
   double cl=close[rates_total-2];
   
   if(t!=time[0])
     {
      if(cl>up && low[1]>up && s==0)  {Alert(Symbol()+" Одинокая свеча выше границы!!!");s++;b=0;}
      if(cl<dn && high[1]<dn && b==0) {Alert(Symbol()+" Одинокая свеча ниже границы!!!");b++;s=0;}
      t=time[0];
     }
//---- OnCalculate done. Return new prev_calculated.
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Calculate Standard Deviation                                     |
//+------------------------------------------------------------------+
double StdDev_Func(int position,const double &price[],const double &MAprice[],int period)
  {
//--- variables
   double StdDev_dTmp=0.0;
//--- check for position
   if(position>=period)
     {
      //--- calcualte StdDev
      for(int i=0; i<period; i++)
         StdDev_dTmp+=MathPow(price[position-i]-MAprice[position],2);
      StdDev_dTmp=MathSqrt(StdDev_dTmp/period);
     }
//--- return calculated value
   return(StdDev_dTmp);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 1 марта 2016, 09:38
0
Сегодня смотреть буду.
avatar

AM2

  • 1 марта 2016, 08:34
0
Такой тестер, вчера с 3.08.15 нормально проходил :) 
avatar

AM2

  • 29 февраля 2016, 19:13
0
Нет. Вы не уловили мысль. в задании я описала что должно быть в условиях. так получился полный слив.

А вы думаете если я пропишу все индикаторы будет иначе?
Поставьте на графики все индикаторы и вы увидите, что нужны только 2. Если вы на скрине сможете мне показать, что остальные на что то влияют, я их добавлю.
avatar

AM2

  • 29 февраля 2016, 19:08
0
В основном по условиям заказы: zakaz.opentraders.ru/25597.html
Когда появляется свободное время и за остальные берусь, но сейчас заказов хватает.
avatar

AM2

  • 29 февраля 2016, 17:52
0
Вот набросок: www.opentraders.ru/downloads/1078/



avatar

AM2

  • 29 февраля 2016, 17:46
0
Посмотрел, здесь достаточно вызова всего двух индикаторов на М5 макди и самой быстрой МА. Если на них условия совпадают то автоматически совпадут и на остальных 8-ми.
avatar

AM2

  • 29 февраля 2016, 16:49
0
Да сегодня гляну.
avatar

AM2

  • 29 февраля 2016, 14:58
0
Готово:




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

//--- Inputs
extern double Lots       = 0.1;      // лот
extern double KLot       = 1;        // умножение лота
extern double MaxLot     = 5;        // максимальный лот
extern int StopLoss      = 2000;     // лось
extern int TakeProfit    = 2000;     // язь
extern int TrailingStop  = 0;        // трал
extern int Slip          = 30;       // реквот
extern int Shift         = 2;        // сдвиг
extern int Magic         = 123;      // магик

extern string IndName="FractalZigZagNoRepaint";
extern string s="    ------ FractalZigZagNoRepaint -----";
extern bool CalculateOnBarClose    = true;
extern int  ZZDepth                = 12;
extern int  ZZDev                  = 5;

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,Lot(),NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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 OpenPos()
  {
   double white = iCustom(NULL,0,IndName,CalculateOnBarClose,ZZDepth,ZZDev,0,Shift);
   double red   = iCustom(NULL,0,IndName,CalculateOnBarClose,ZZDepth,ZZDev,1,Shift);

   if(white<100)
     {
      PutOrder(0,Ask);
     }

   if(red<100)
     {
      PutOrder(1,Bid);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ClosePos()
  {
   double white = iCustom(NULL,0,IndName,CalculateOnBarClose,ZZDepth,ZZDev,0,Shift);
   double red   = iCustom(NULL,0,IndName,CalculateOnBarClose,ZZDepth,ZZDev,1,Shift);
//---
   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(red<100)
                 {
                  if(!OrderClose(OrderTicket(),OrderLots(),Bid,Slip,Red))
                     Print("OrderClose error ",GetLastError());
                 }
              }
            if(OrderType()==OP_SELL)
              {
               if(white<100)
                 {
                  if(!OrderClose(OrderTicket(),OrderLots(),Ask,Slip,Blue))
                     Print("OrderClose error ",GetLastError());
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Lot()
  {
   double lot=Lots;

   if(OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY))
     {
      if(OrderProfit()<0)
        {
         lot=OrderLots()*KLot;
        }
     }
   if(lot>MaxLot)lot=Lots;
   return(lot);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Trailing()
  {
   bool mod;
   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(Bid-OrderOpenPrice()>TrailingStop*Point)
                 {
                  if(OrderStopLoss()<Bid-TrailingStop*Point)
                    {
                     mod=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                     return;
                    }
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if((OrderOpenPrice()-Ask)>TrailingStop*Point)
                 {
                  if((OrderStopLoss()>(Ask+TrailingStop*Point)) || (OrderStopLoss()==0))
                    {
                     mod=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                     return;
                    }
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   double white = iCustom(NULL,0,IndName,CalculateOnBarClose,ZZDepth,ZZDev,0,Shift);
   double red   = iCustom(NULL,0,IndName,CalculateOnBarClose,ZZDepth,ZZDev,1,Shift);

   if(CountTrades()<1)
     {
      OpenPos();
     }
   else ClosePos();

   if(TrailingStop>0) Trailing();

   Comment("\n White: ",white,
           "\n Red: ",red);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 29 февраля 2016, 14:54
0
Это уже в будущее смотрит, так нельзя.
avatar

AM2

  • 29 февраля 2016, 13:56
0
0-6 ставил сдвиг нормально все. А вы сколько загнули, покажите настройки?
avatar

AM2

  • 29 февраля 2016, 13:42
0
В самом конце настройку смотрите: www.opentraders.ru/downloads/1074/

input int Reverse=0; // Reverse 0-off 1-on 


avatar

AM2

  • 28 февраля 2016, 23:03
0
Можете ссылку на файл скинуть здесь в сообщениях.
avatar

AM2

  • 28 февраля 2016, 20:01
0
У вас запрет на участие в столе заказов. Обратитесь в администрацию сайта, может снимут, к бишопу или кауру.
avatar

AM2

  • 28 февраля 2016, 17:56