0
туча различных преобразований. пока я встрял на том как собрать число, если в нем есть нули:


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

extern double Lots       = 0.1;      // лот
extern double KLot       = 1;        // умножение лота
extern double MaxLot     = 5;        // максимальный лот
extern int StopLoss      = 333;      // лось
extern int TakeProfit    = 444;      // язь
extern int Slip          = 30;       // реквот
extern int Magic         = 123;      // магик

input int count=2;
input double fibo=1.161;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Lot()
  {
   double lot=Lots;
   for(int i=OrdersHistoryTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderProfit()>0)
               break;
            if(OrderProfit()<0)
              {
               lot=OrderLots()*KLot;
               break;
              }
           }
        }
     }
   if(lot>MaxLot)
      lot=Lots;
   return(lot);
  }
//+------------------------------------------------------------------+
//| Подсчет ордеров по типу                                          |
//+------------------------------------------------------------------+
int CountOrders(int type=-1)
  {
   int coun=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 || type==-1)
               coun++;
           }
        }
     }
   return(coun);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   int pr=(int)(Bid*(MathPow(10,_Digits)));
   string s=(string)pr;
   string s1=StringSubstr(s,count);
   int pr1=(int)s1;
   int pr2=pr1*fibo;
   string s3=StringSubstr(s,0,count);

   double sell=0;


      if(Low[1]>Low[2] && Low[2]>Low[3] && Low[4]>Low[3] && Low[5]>Low[4] && CountOrders(0)<1)
         sell=0;


   Comment("\n Price: ",s,
           "\n Digits: ",_Digits,
           "\n String Length: ",StringLen(s),
           "\n Sub String: ",s1,
           "\n Price 1: ",pr1,
           "\n Price 2: ",pr2,
           "\n Price 3: ",s3);
  }
//+------------------------------------------------------------------+



может у вас есть идея как сделать все это иначе?
avatar

AM2

  • 17 октября 2019, 21:15
+1
п.1. поправил.
п.2. советник рассчитывает вход по следующей формуле:


   double lo=Low[iLowest(NULL,0,MODE_LOW,BarsCount,2)];
   double hi=High[iHighest(NULL,0,MODE_HIGH,BarsCount,2)];


т.е. пробой диапазона за указанное количество баров. полностью переносить индикатор в советник это не ко мне.

www.opentraders.ru/downloads/2453/
avatar

AM2

  • 17 октября 2019, 20:33
0
то что у вас есть идеи это хорошо. но у вас есть соображения как все это объяснить машине?
avatar

AM2

  • 17 октября 2019, 19:40
0
вот этот код считает тики, сумму и результат:



www.opentraders.ru/downloads/2455/
avatar

AM2

  • 16 октября 2019, 21:44
0
подпольный индикатор?
avatar

AM2

  • 16 октября 2019, 18:23
0
готово:




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

input int bars=111;
input int kper=5;
input int dper=3;
input int slow=3;

int cross[];
datetime t=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   ArrayResize(cross,bars,1);
//---
   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 count=0, d1=0, d2=0, d3=0, k=0;

   for(int i=0; i<bars; i++)
     {
      double sto1=iStochastic(NULL,0,kper,dper,slow,0,0,MODE_MAIN,i);
      double sto2=iStochastic(NULL,0,kper,dper,slow,0,0,MODE_MAIN,i+1);

      if((sto1>50 && sto2<50) || (sto1<50 && sto2>50))
        {
         count++;
         cross[k]=i;
         k++;
        }
     }

   d1=cross[1]-cross[0];
   d2=cross[2]-cross[1];
   d3=cross[3]-cross[2];


   if(d1>d2 && d2>d3 && t!=time[0])
     {
      Alert("Свершилось!!!");
      t=time[0];
     }

   Comment("\n I1: ",cross[0],
           "\n I2: ",cross[1],
           "\n I3: ",cross[2],
           "\n I4: ",cross[3],
           "\n ",
           "\n D1: ",d1,
           "\n D2: ",d2,
           "\n D3: ",d3,
           "\n ",
           "\n Count: ",count);

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

//+------------------------------------------------------------------+

avatar

AM2

  • 15 октября 2019, 22:01
0
на 22-е
avatar

AM2

  • 15 октября 2019, 20:48
0
а в чем смысл добавления? покажите на скринах
avatar

AM2

  • 15 октября 2019, 18:07
0
на 19-е
avatar

AM2

  • 15 октября 2019, 17:45
0
какой тф?
avatar

AM2

  • 15 октября 2019, 17:42