0
можете только подправить что бы TP каждой позиции был ни у каждого свой, а усреднённый


Скачал версию из базы. Ставит усредненный тейк:



Когда у вас такая штука проявляется и что в журнале?
avatar

AM2

  • 16 октября 2017, 20:49
0
Один индикатор нанесет МА на график, другой рисует столбики:



Машки


//+------------------------------------------------------------------+
//|                                                          5MA.mq4 |
//|                                              Copyright 2017, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.00"
#property strict
#property indicator_chart_window

#property  indicator_buffers 5

#property  indicator_color1  Red
#property  indicator_color2  Red
#property  indicator_color3  Red
#property  indicator_color4  Red
#property  indicator_color5  Red

#property  indicator_width1  1
#property  indicator_width2  1
#property  indicator_width3  1
#property  indicator_width4  1
#property  indicator_width5  1

input int ma1period=5;
input int ma2period=10;
input int ma3period=15;
input int ma4period=20;
input int ma5period=25;

//--- indicator buffers
double  ma1[];
double  ma2[];
double  ma3[];
double  ma4[];
double  ma5[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(0,ma1);
   SetIndexBuffer(1,ma2);
   SetIndexBuffer(2,ma3);
   SetIndexBuffer(3,ma4);
   SetIndexBuffer(4,ma5);
   
//---
   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[])
  {
//---
   for(int i=0;i<1000;i++)
     {
      ma1[i]=iMA(NULL,0,ma1period,0,0,0,i);
      ma2[i]=iMA(NULL,0,ma2period,0,0,0,i);
      ma3[i]=iMA(NULL,0,ma3period,0,0,0,i);
      ma4[i]=iMA(NULL,0,ma4period,0,0,0,i);
      ma5[i]=iMA(NULL,0,ma5period,0,0,0,i);
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+



Столбики


//+------------------------------------------------------------------+
//|                                                      5Mashek.mq4 |
//|                                              Copyright 2017, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.00"
#property strict
#property indicator_separate_window

#property  indicator_buffers 1

#property  indicator_maximum 1
#property  indicator_minimum -0.2

#property  indicator_color1  Red

#property  indicator_width1  2

input int ma1period=5;
input int ma2period=10;
input int ma3period=15;
input int ma4period=20;
input int ma5period=25;

//--- indicator buffers
double  buff[];
datetime t=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,buff);
//---
   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[])
  {
//---
   int lim=rates_total-prev_calculated;

   for(int i=0;i<lim;i++)
     {
      double MA1=iMA(NULL,0,ma1period,0,0,0,i);
      double MA2=iMA(NULL,0,ma2period,0,0,0,i);
      double MA3=iMA(NULL,0,ma3period,0,0,0,i);
      double MA4=iMA(NULL,0,ma4period,0,0,0,i);
      double MA5=iMA(NULL,0,ma5period,0,0,0,i);
      
      if((MA1>high[i] || MA1<low[i]) && 
         (MA2>high[i] || MA2<low[i]) && 
         (MA3>high[i] || MA3<low[i]) && 
         (MA4>high[i] || MA4<low[i]) && 
         (MA5>high[i] || MA5<low[i])) buff[i]=0.9;
     }
     
   if(t!=time[0])
     {
      if(buff[1]==0.9) Alert(_Symbol+" Не было пересечения с МА!!!");
      t=time[0];
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 16 октября 2017, 20:40
0
Посмотрю сегодня
avatar

AM2

  • 16 октября 2017, 17:16
0
Можно подробнее и со скринами.
avatar

AM2

  • 16 октября 2017, 17:13
0
То что смог сделал: www.opentraders.ru/downloads/1692/



За более точным соответствием ТЗ к платному. Одновременное существование разнонаправленных позиций и отложек у меня так и не вышло как я не бился )
avatar

AM2

  • 15 октября 2017, 10:31
0
Сделал такой вариант, но дальше править не возьмусь. Чужой код, с ним намучаешься только: www.opentraders.ru/downloads/1691/


avatar

AM2

  • 13 октября 2017, 18:58
0
Скиньте пожалуйста в топик чтобы было перед глазами. После выходных буду смотреть.
avatar

AM2

  • 13 октября 2017, 17:15
0
На закрытие оставьте только один индикатор, а то ерунда получается:




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

//--- Inputs
extern double Lots       = 0.1;      // лот
extern int StopLoss      = 2000;     // лось
extern int TakeProfit    = 3000;     // язь
extern int Slip          = 30;       // реквот
extern int Shift         = 1;        // на каком баре сигнал индикатора
extern int CloseOn       = 1;        // 1-закрытие в конце работы
extern int Magic         = 123;      // магик
extern string IndName    = "Fiji Trend_alerts mtf";
extern string IndName1   = "BB_Alert Arrows";
//+------------------------------------------------------------------+
//| 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,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 lime= iCustom(NULL,0,IndName,2,Shift);
   double red = iCustom(NULL,0,IndName,3,Shift);

   if(lime<1000)
     {
      PutOrder(0,Ask);
     }

   if(red<1000)
     {
      PutOrder(1,Bid);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ClosePos()
  {
   double lime= iCustom(NULL,0,IndName,2,Shift);
   double red = iCustom(NULL,0,IndName,3,Shift);
   double up=iCustom(NULL,0,IndName1,1,Shift);
   double dn=iCustom(NULL,0,IndName1,0,Shift);

   if(red<1000 || dn<1000)
     {
      CloseAll(0);
     }

   if(lime<1000 || up<1000)
     {
      CloseAll(1);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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);
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   double lime= iCustom(NULL,0,IndName,2,Shift);
   double red = iCustom(NULL,0,IndName,3,Shift);
   double up=iCustom(NULL,0,IndName1,1,Shift);
   double dn=iCustom(NULL,0,IndName1,0,Shift);

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

   Comment("\n lime: ",lime,
           "\n red: ",red,
           "\n up: ",up,
           "\n dn: ",dn);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 12 октября 2017, 21:18
0
Поясните все со скринами?
avatar

AM2

  • 12 октября 2017, 20:31
0
За чужой код обычно не берусь но я правил такой индюк для мт4 м.б. и здесь получится. Завтра посмотрю.
avatar

AM2

  • 12 октября 2017, 17:56
0
пишите новым топиком и тз текстом не на скрине
avatar

AM2

  • 12 октября 2017, 17:53
0
Похоже на правду?




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

input int RSIPeriod=14;
input int RSILevel=45;
input int CCI1Period=15;
input int CCI2Period=10;
input int CCI3Period=5;
input bool mail=1;
input bool push=1;
input bool alert=1;

datetime t=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   Comment("");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void PutArrow(string name,int code,double p,datetime time,color clr)
  {
//--- создадим стрелку
   ObjectCreate(0,name,OBJ_ARROW,0,time,p);
//--- установим код стрелки
   ObjectSetInteger(0,name,OBJPROP_ARROWCODE,code);
//--- установим способ привязки
   ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_CENTER);
//--- установим цвет стрелки
   ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим размер стрелки
   ObjectSetInteger(0,name,OBJPROP_WIDTH,2);
  }
//+------------------------------------------------------------------+
//|   Цена фрактала                                                  |
//+------------------------------------------------------------------+
double FractalPrice(int num,int mode)
  {
   double f=0;
   int up=0,dn=0,n=0;
   for(int i=2; i<100; i++)
     {
      f=iFractals(NULL,0,MODE_UPPER,i);
      if(f>0 && mode==1)
        {
         n++;
         if(n==num) break;
        }

      f=iFractals(NULL,0,MODE_LOWER,i);
      if(f>0 && mode==2)
        {
         n++;
         if(n==num) break;
        }
     }
   return(f);
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
   double rsi=iRSI(NULL,0,RSIPeriod,0,1);
   double cci1=iCCI(NULL,0,CCI1Period,0,1);
   double cci2=iCCI(NULL,0,CCI2Period,0,1);
   double cci31=iCCI(NULL,0,CCI3Period,0,1);
   double cci32=iCCI(NULL,0,CCI3Period,0,2);
   double up=FractalPrice(1,1);
   double dn=FractalPrice(1,2);

   if(t!=time[0])
     {
      if(cci1>0 && cci2>0 && cci31>0 && cci32<0 && rsi>100-RSILevel && close[1]>up)
        {
         PutArrow((string)time[1],233,high[1],time[1],Blue);
         if(alert) Alert(_Symbol+" Buy!!!");
         if(push) SendNotification(_Symbol+" Buy!!!");
         if(mail) SendMail("Signal",_Symbol+" Buy!!!");
        }

      if(cci1<0 && cci2<0  && cci31<0 && cci32>0 && rsi<RSILevel && close[1]<dn)
        {
         PutArrow((string)time[1],234,low[1],time[1],Red);
         if(alert) Alert(_Symbol+" Sell!!!");
         if(push) SendNotification(_Symbol+" Sell!!!");
         if(mail) SendMail("Signal",_Symbol+" Sell!!!");
        }
      t=time[0];
     }

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 11 октября 2017, 20:34
0
Завтра буду смотреть.
avatar

AM2

  • 11 октября 2017, 17:40
0
Это к совмещению индикаторов. А советник на данных индикаторах можно попробовать написать.
avatar

AM2

  • 10 октября 2017, 20:18
0
при закрытии дня выскакивал алерт если цена находится выше заданной


Может быть что то вроде:

if(TimeCurrent()==StringToTime("23:55") && Bid>ATR) Alert("Цена выше ",ATR);
avatar

AM2

  • 10 октября 2017, 17:24
0
ТЗ на индикатор рассмотрю.
avatar

AM2

  • 10 октября 2017, 17:16
0
Делают люди, но очень редко.
avatar

AM2

  • 10 октября 2017, 17:15
Начать торговлю с Альпари