Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 589

 

Why is the virtual Compare method overridden in the CListNode class ignored?

#include <Arrays\List.mqh>
#define  SIZE 10

class CData : public CObject
  {
public:
   int m_data;
  };

class CListNode : public CList
  {
public:
   virtual int Compare(const CObject *node,const int mode=0) const {
      int _test=1;
      return(_test);
   }
  };

int OnInit() {
        CListNode *node=new CListNode;
        if(CheckPointer(node)==POINTER_INVALID) {
           Print("Не могу создать объект");
           return(INIT_FAILED);
        }
        else Print("Объект создан, работаем дальше");

        MathSrand(GetTickCount());
        for(int i=0;i<SIZE;i++) {
           CData *data=new CData;
           if(data==NULL) {
              Print("Нет возможности получить указатель");delete node;return(INIT_FAILED);
           }
           printf("Узел %i, данные узла %i",i,data.m_data=MathRand());
           node.Add(data);
        }
        
        node.Sort(0);
        int _total=node.Total();
        for(int i=0;i<_total;i++) {
           CData *data=node.GetNodeAtIndex(i);
           if(data==NULL) {
              Print("Нет возможности получить указатель");delete node;return(INIT_FAILED);
           }
           printf("Узел %i, данные узла %i",i,data.m_data);
        }

        if(CheckPointer(node)==POINTER_DYNAMIC) {Alert("Удаляем объект");delete node;}
        else Alert("Non-dynamic object");
   return(INIT_SUCCEEDED);
}
Checked in debugger, always uses Compare from CObject
 

Hi, I wrote an EA like this. Why does it report a sell signal almost every second?

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

//| Peresechenie TM.mq4 |

//| Popov Vladimir |

//| http://vk.com/id143715412 |

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

#property copyright "Popov Vladimir"

#property link "http://vk.com/id143715412"


double SellPrice;

double TakeProfit;

double StopLoss;


extern string TimeFrame = "current time frame";

extern int HalfLength = 20;

extern int Price = PRICE_CLOSE;

extern double ATRMultiplier = 2.0;

extern inttern ATRPeriod = 100;

extern bool Interpolate = true;



double PriceHigh, PriceLow, PriceMiddle;

double HighesBuffer[];

double LowesBuffer[];

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

//| expert initialization function |

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

int init()

{

if (Digits == 3 || Digits == 5)

{

TakeProfit *= 10;

StopLoss *= 10;

}

return(0);

}

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

//| expert deinitialization function |

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

int deinit()

{





return(0);

}

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

int start()

{

PriceHigh = iCustom (Symbol (), 0, "Time", TimeFrame, HalfLength, Price, ATRMultiplier, ATRPeriod, Interpolate, 2, 0);

PriceLow = iCustom (Symbol (), 0, "Time", TimeFrame, HalfLength, Price, ATRMultiplier, ATRPeriod, Interpolate, 1, 0);

PriceMiddle = iCustom (Symbol (), 0, "Time", TimeFrame, HalfLength, Price, ATRMultiplier, ATRPeriod, Interpolate, 0, 0);


if(Ask <= PriceLow)

{

Alert("Signal to Buy");

}

if(Bid >= PriceHigh)

{

Alert("Signal to sell");

}

return(0);

}

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

 

Can you please tell me if it is possible to automatically save the report after testing?

I just need to do a lot of test runs in automatic mode (I plan to do it through optimisation without GA) and to save the full report (including picture) on HDD.

 
tuner:

Can you please tell me if it is possible to automatically save the report after testing?

I just need to do a lot of test runs in automatic mode (I plan to do it through optimization without GA) and to save full report (including picture) on HDD.


There is function TesterStatistics() andOnTester()

Take a look at them, it may help

 
Pr0t0tip:

Hi, I wrote an EA like this. Why does it report a sell signal almost every second?



Try replacing

if(Ask <= PriceLow)

 {

 Alert("Сигнал к покупке");

 }

 if(Bid >= PriceHigh)

 {

 Alert("Сигнал к продаже");

 }

 return(0);

at

int static flag=0;
if(Ask <= PriceLow && flag<1)

 {

 Alert("Сигнал к покупке");
flag=1;
 }

 else if(Bid >= PriceHigh && flag>-1)

 {

 Alert("Сигнал к продаже");
flag=-1;
 }
else flag=0;

 return(0);
 
Vinin:


There is a TesterStatistics() and OnTester() function

Take a look at them, it might help.


Thanks for the advice, but it doesn't seem to help as it's the report itself in its original form (htm) with an image that is needed. There seems to be no ready-made solution. I will try to make a script in autoit, which in the tester specified number of times presses the "Start" button and after each run goes to the tab "Report" and saves the results in the file
 

Hello! Please help me with the following problem: starting from build 625, the values from the Alert (...), Print(...), Comment(...) functions are not displayed on the indicator chart in the MT4 tester; these values are displayed during the indicator launching for real trading or through the debugger. So, it becomes impossible to monitor parameter changes on historical data using the Print(...) function at least. I had no problems with the 610th build as all values were displayed in the "Experts" tab of the terminal.

Perhaps, the code should be reworked in some other way similar to MQL5? I do not know what to do, I still have to use the old build...

 

Hello. Has anyone encountered this problem yet?

I have several EAs in the folder, but the terminal (MT 4, build 625) does not have them. And those that are on the terminal are not in the folder. Is it a miracle?



 
Ale-xander:

Hello. Has anyone encountered this problem yet?

I have several EAs in the folder, but the terminal (MT 4, build 625) does not have them. And those that are on the terminal are not in the folder. Is it a miracle?



No miracles.

File --> Open Data Folder --> In the window that opens --> MQL4 --> and that's where the folders you are used to are located. The link to this article on the main page of the forum. I am just too lazy to do it.

 
Barbarian:

Why is the virtual Compare method overridden in the CListNode class ignored?

Checked in debugger, always uses Compare from CObject


Need to override Compare in CData class.
Reason: