Indikator im Trailing class nicht abrufbar

Einloggen oder registrieren, um einen Kommentar zu schreiben
Михаил Е.К.
22
Михаил Е.К.  

Hallo, ich versuche seit Tagen Pufferwerte von meinem Indikator im Trailing Stop abzurufen, bis jetzt vergeblich. Das Indikator mk_mt_outer_bars hat 5 Puffer, ich will den ersten (0) abrufen. Dabei kommen grenzwertige Zahlen raus:


2019.05.27 23:17:09.747 Core 1 2019.03.06 21:00:00   ob0:3.727723230668816e-181
2019.05.27 23:17:09.747 Core 1 2019.03.06 22:00:00   ob0:3.921734163908961e+185
2019.05.27 23:17:09.747 Core 1 2019.03.06 23:30:00   ob0:1.022437207614106e+103

Habe bereits sämtliche Ansätze durchprobiert, jedesmal das gleiche. 

//+------------------------------------------------------------------+
//|                                                 MkTrailingMt.mqh |
//|                   Copyright 2009-2013, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#include <Expert\ExpertTrailing.mqh>
//#property tester_indicator "Examples\\mkOuterBarsMt.ex5"
// wizard description start
//+------------------------------------------------------------------+
//| Description of the class                                         |
//| Title=Trailing Stop based on Outer Bars MT                       |
//| Type=Trailing                                                    |
//| Name=OB                                                          |
//| Class=CMkTrailingMt                                              |
//| Page=Not needed                                                  |
//| Parameter=ExtDeviation,int,4,Deviation                           |
//| Parameter=ExtObHistory,int,3000,OB history                       |
//+------------------------------------------------------------------+
// wizard description end
//+------------------------------------------------------------------+
//| Class CMkTrailingMt.                                             |
//| Purpose: Class of trailing stops based on OB.                    |
//|              Derives from class CExpertTrailing.                 |
//+------------------------------------------------------------------+
class CMkTrailingMt : public CExpertTrailing
  {
protected:
   CiCustom             mk_mt_outer_bars;
   //--- input parameters
   int               extDeviation;
   int               extObHistory;
   //--- indicator initialization method
   bool              InitMyCustomIndicator(CIndicators *indicators);   

public:
                     CMkTrailingMt(void);
                    ~CMkTrailingMt(void);
                    
   //--- methods of initialization of protected data
   void              ExtDeviation(int val)                  { extDeviation=val;   }
   void              ExtObHistory(int val)                    { extObHistory=val;     }
   virtual bool      InitIndicators(CIndicators *indicators);
   virtual bool      ValidationSettings(void);
   //--- Access to indicator data
   double            ObBottom(const int index)             const { return(mk_mt_outer_bars.GetData(0,index)); }
   double            ObTop(const int index)             const { return(mk_mt_outer_bars.GetData(2,index)); }     
   //---
   virtual bool      CheckTrailingStopLong(CPositionInfo *position,double &sl,double &tp);
   virtual bool      CheckTrailingStopShort(CPositionInfo *position,double &sl,double &tp);
  };
//+------------------------------------------------------------------+
//| Constructor                                                      |
//+------------------------------------------------------------------+
void CMkTrailingMt::CMkTrailingMt(void) : extDeviation(4),
                                          extObHistory(3000)
  {
  }
//+------------------------------------------------------------------+
//| Destructor                                                       |
//+------------------------------------------------------------------+
void CMkTrailingMt::~CMkTrailingMt(void)
  {
  }
//+------------------------------------------------------------------+
//| Validation settings protected data.                              |
//+------------------------------------------------------------------+
bool CMkTrailingMt::ValidationSettings(void)
  {
   if(!CExpertTrailing::ValidationSettings())
      return(false);
//--- initial data checks
   if(extDeviation<=0)
     {
      printf(__FUNCTION__+": extDeviation must be greater than 0");
      return(false);
     }
//--- ok
   return(true);
  }
//+------------------------------------------------------------------+
//| Checking for input parameters and setting protected data.        |
//+------------------------------------------------------------------+
bool CMkTrailingMt::InitIndicators(CIndicators *indicators)
  {
//--- check
   if(indicators==NULL)
      return(false);
   //--- Initializing indicators and timeseries in additional filters
   if(!CExpertTrailing::InitIndicators(indicators)) 
      {
      printf(__FUNCTION__+": error Initializing indicators and timeseries");
      //delete m_MA;
      return(false);
     }
//--- creation and initialization of the custom indicator
   if(!InitMyCustomIndicator(indicators))
     {
      printf(__FUNCTION__+": error initializing Trailling object");
      return(false);
     }

   //mk_mt_outer_bars.BufferResize(3);
// Обязательно установить размер буфера!!!
   //mk_mt_outer_bars.BufferResize(SeriesInfoInteger(Symbol(), Period(), 1));


//--- ok
   return(true);
  }
  
  //+------------------------------------------------------------------+
//| Initialization of indicators.                                    |
//+------------------------------------------------------------------+
bool CMkTrailingMt::InitMyCustomIndicator(CIndicators *indicators)
  {
//--- add an object to the collection
   if(!indicators.Add(GetPointer(mk_mt_outer_bars)))
     {
       //#ifdef TRACE printf(__FUNCTION__ +", "+__FILE__+", "+__LINE__);  #endif
      printf(__FUNCTION__+": error adding object");
      return(false);
     }
//--- Setting parameters of the fast MA
   MqlParam parameters[3];
//---
   parameters[0].type=TYPE_STRING;
   parameters[0].string_value="Examples\\mkOuterBarsMt.ex5";
   parameters[1].type=TYPE_INT;
   parameters[1].integer_value=extDeviation;      // 
   parameters[2].type=TYPE_INT;
   parameters[2].integer_value=3000;              // 
//--- object initialization
   if(!mk_mt_outer_bars.Create(m_symbol.Name(),m_period,IND_CUSTOM,3,parameters))
     {
      printf(__FUNCTION__+": error initializing object");
      return(false);
     }
//--- number of buffers
   if(!mk_mt_outer_bars.NumBuffers(5)) return(false);
   Print("Nbr Parameters: "+mk_mt_outer_bars.NumParams());
//--- ok
   return(true);
  }
  
//+------------------------------------------------------------------+
//| Checking trailing stop and/or profit for long position.          |
//+------------------------------------------------------------------+
bool CMkTrailingMt::CheckTrailingStopLong(CPositionInfo *position,double &sl,double &tp)
  {
//--- check
   if(position==NULL)
      return(false);
//---
   int idx=StartIndex();
   double level =NormalizeDouble(m_symbol.Bid()-m_symbol.StopsLevel()*m_symbol.Point(),m_symbol.Digits());
   //mk_mt_outer_bars.Refresh(OBJ_ALL_PERIODS);
   
   double new_sl=NormalizeDouble(ObBottom(idx),m_symbol.Digits());
/*
double Do_Signal[1];
mk_mt_outer_bars.GetData(0,1,0,Do_Signal);
if (Do_Signal[0]>0) {
    Print("Do_Signal 0:",Do_Signal[0]);
}*/

   double pos_sl=position.StopLoss();
   double base  =(pos_sl==0.0) ? position.PriceOpen() : pos_sl;
//---
   sl=EMPTY_VALUE;
   tp=EMPTY_VALUE;
   if(new_sl > 0) {
       Print("level:",level," new_sl:",new_sl," pos_sl:",pos_sl," base",base," idx:",idx," ObBottom(idx):",ObBottom(idx));
    
   }
   if(new_sl>base && new_sl<level)
      sl=new_sl;
//---
   return(sl!=EMPTY_VALUE);
  }
//+------------------------------------------------------------------+
//| Checking trailing stop and/or profit for short position.         |
//+------------------------------------------------------------------+
bool CMkTrailingMt::CheckTrailingStopShort(CPositionInfo *position,double &sl,double &tp)
  {
//--- check
   if(position==NULL)
      return(false);
//---
   double level =NormalizeDouble(m_symbol.Ask()+m_symbol.StopsLevel()*m_symbol.Point(),m_symbol.Digits());
   //double new_sl=NormalizeDouble(mk_mt_outer_bars.Main(1)+m_symbol.Spread()*m_symbol.Point(),m_symbol.Digits());
   double pos_sl=position.StopLoss();
   double base  =(pos_sl==0.0) ? position.PriceOpen() : pos_sl;
//---
   sl=EMPTY_VALUE;
   tp=EMPTY_VALUE;
   //if(new_sl<base && new_sl>level)
   //   sl=new_sl;
//---
   return(sl!=EMPTY_VALUE);
  }
//+------------------------------------------------------------------+
Christian
3193
Christian  
Михаил Е.К.:

Hallo, ich versuche seit Tagen Pufferwerte von meinem Indikator im Trailing Stop abzurufen, bis jetzt vergeblich. Das Indikator mk_mt_outer_bars hat 5 Puffer, ich will den ersten (0) abrufen. Dabei kommen grenzwertige Zahlen raus:


2019.05.27 23:17:09.747 Core 1 2019.03.06 21:00:00   ob0:3.727723230668816e-181
2019.05.27 23:17:09.747 Core 1 2019.03.06 22:00:00   ob0:3.921734163908961e+185
2019.05.27 23:17:09.747 Core 1 2019.03.06 23:30:00   ob0:1.022437207614106e+103

Habe bereits sämtliche Ansätze durchprobiert, jedesmal das gleiche. 

Hallo Михаил Е.К. um dein Problem zu lösen ist es wichtig das du ALLE Dateien postest.

Wenn du wichtiges nicht veröffenlichen kannst/willst dann mach ein Skript/kleinen EA wo dein Problem auftritt.

Das ist immer der schnellste Weg

Du hast nur eine include Datei gezeigt keinen EA


Gruß Christian

Einloggen oder registrieren, um einen Kommentar zu schreiben