Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1275

 
Aleksandr Egorov:

read it already )

I looked it up now too. The article is from 2011... But, most importantly, there is an explanation of how ticks are generated in "all ticks" mode. And "Based on real ticks" speaks for itself. That's the difference.

 
Question on the tester.

In visualisation mode, the prints are not displayed. Is this supposed to be the case, or am I doing something wrong?
 
Hi all!!! And Happy New Year!!! I got my programming curve in classes. And here I have a puzzlement. I have in the folder #include/ChartObject a class file -- ChartObjectsLines and it contains not only a class of trendlines, but also other classes with lines and constructors for all these classes. And here is the question, the answer to which I have not found, that in one class can be many classes and constructors for these classes?
 
And another question)) How do you get the price and date from the X / Y coordinates in the graph window???
 
Kira27:
And another question))) How do I get the price and date from the X / Y coordinates in the graph window???

https://www.mql5.com/ru/docs/chart_operations/charttimepricetoxy

https://www.mql5.com/ru/docs/chart_operations/chartxytotimeprice

Документация по MQL5: Операции с графиками / ChartTimePriceToXY
Документация по MQL5: Операции с графиками / ChartTimePriceToXY
  • www.mql5.com
ChartTimePriceToXY - Операции с графиками - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
I have another question)) Do not send me to read the manual, I have read it more than once, I still do not understand everything in the classes) There is a class Trailing Stop for Parabolic SAR, located in the folder Expert\Trailing\ named TrailingParabolicSAR.mqh Please tell me how to interact with it, if it is not difficult. I understand it better through examples))) Thanks in advance to those who respond)
//+------------------------------------------------------------------+
//|                                         TrailingParabolicSAR.mqh |
//|                   Copyright 2009-2013, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#include <Expert\ExpertTrailing.mqh>
// wizard description start
//+------------------------------------------------------------------+
//| Description of the class                                         |
//| Title=Trailing Stop based on Parabolic SAR                       |
//| Type=Trailing                                                    |
//| Name=ParabolicSAR                                                |
//| Class=CTrailingPSAR                                              |
//| Page=                                                            |
//| Parameter=Step,double,0.02,Speed increment                       |
//| Parameter=Maximum,double,0.2,Maximum rate                        |
//+------------------------------------------------------------------+
// wizard description end
//+------------------------------------------------------------------+
//| Class CTrailingPSAR.                                             |
//| Appointment: Class traling stops with Parabolic SAR.             |
//| Derives from class CExpertTrailing.                              |
//+------------------------------------------------------------------+
class CTrailingPSAR : public CExpertTrailing
  {
protected:
   CiSAR             m_sar;            // object-indicator
   //--- adjusted parameters
   double            m_step;           // the "speed increment" parameter of the indicator
   double            m_maximum;        // the "maximum rate" parameter of the indicator

public:
                     CTrailingPSAR(void);
                    ~CTrailingPSAR(void);
   //--- methods of setting adjustable parameters
   void              Step(double step)       { m_step=step;       }
   void              Maximum(double maximum) { m_maximum=maximum; }
   //--- method of creating the indicator and timeseries
   virtual bool      InitIndicators(CIndicators *indicators);
   //---
   virtual bool      CheckTrailingStopLong(CPositionInfo *position,double &sl,double &tp);
   virtual bool      CheckTrailingStopShort(CPositionInfo *position,double &sl,double &tp);
  };
//+------------------------------------------------------------------+
//| Constructor                                                      |
//+------------------------------------------------------------------+
void CTrailingPSAR::CTrailingPSAR(void) : m_step(0.02),
                                          m_maximum(0.2)

  {
  }
//+------------------------------------------------------------------+
//| Destructor                                                       |
//+------------------------------------------------------------------+
void CTrailingPSAR::~CTrailingPSAR(void)
  {
  }
//+------------------------------------------------------------------+
//| Create indicators.                                               |
//+------------------------------------------------------------------+
bool CTrailingPSAR::InitIndicators(CIndicators *indicators)
  {
//--- check pointer
   if(indicators==NULL)
      return(false);
//--- add object to collection
   if(!indicators.Add(GetPointer(m_sar)))
     {
      printf(__FUNCTION__+": error adding object");
      return(false);
     }
//--- initialize object
   if(!m_sar.Create(m_symbol.Name(),m_period,m_step,m_maximum))
     {
      printf(__FUNCTION__+": error initializing object");
      return(false);
     }
//--- ok
   return(true);
  }
//+------------------------------------------------------------------+
//| Checking trailing stop and/or profit for long position.          |
//+------------------------------------------------------------------+
bool CTrailingPSAR::CheckTrailingStopLong(CPositionInfo *position,double &sl,double &tp)
  {
//--- check
   if(position==NULL)
      return(false);
//---
   double level =NormalizeDouble(m_symbol.Bid()-m_symbol.StopsLevel()*m_symbol.Point(),m_symbol.Digits());
   double new_sl=NormalizeDouble(m_sar.Main(1),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);
  }
//+------------------------------------------------------------------+
//| Checking trailing stop and/or profit for short position.         |
//+------------------------------------------------------------------+
bool CTrailingPSAR::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(m_sar.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);
  }
//+------------------------------------------------------------------+
 
Kira27:
I have another question)) Please don't send me to read instructions, I have read it many times, I still don't understand all classes) There is a Trailing Stop class for Parabolic SAR, located in Expert\Trailing\ folder and named TrailingParabolicSAR.mqh Please tell me how to use it. I understand it better through examples))) Thanks in advance to those who respond)

An example usage example is given in [dta folder]\MQL5\Experts\Advisors\ExpertMAPSAR.mq5

 
Vladimir Karputov:

An example usage example is given in [dta folder]\MQL5\Experts\Advisors\ExpertMAPSAR.mq5

Thank you!!!

 
User_mt5:
Question on the tester.

In visualisation mode, the prints are not displayed. Is this supposed to be the case, or am I doing something wrong?
I don't think anyone knows.