CExpertSignal: get signal results from specified bar index - page 2

 

@harryma23, some advice ...

Before using the Standard Library, you should strive to first fully understand the functional mechanics behind the class implementations. In other words, you should at least be familiar and understand the basics of the functional aspects of how to process Timeseries and Indicator data access. Otherwise you will have difficulty understanding the logic behind the Standard Library.

In fact, I would highly recommend that you be able to program a basic EA purely using the native MQL5 functions first, so that when you start using the Standard Library, you will understand how it works behind the scenes. That will allow you to use it correctly and also how to go about extending it if necessary.

 
harryma23 #:

Harry, you have spent the entire thread misinterpreting what you have been told.

  • "evaluation shift" was not an existing function or parameter. It was a name invented to describe the idea of evaluating a bar other than the current one. You took it literally and misapplied it to StartIndex(), which obviously does not serve that purpose. Then you blamed others for your mistake. 

Forum on trading, automated trading systems and testing trading strategies

CExpertSignal: get signal results from specified bar index

Miguel Angel Vico Alba, 2025.08.31 10:44

What you propose with signal.Shift(200) does not work for scanning past bars: that parameter shifts the moving average, it does not indicate which bar to evaluate. LongCondition() always works on the current bar.

If you want to print historical signals, you need to make a bar loop and replicate the CSignalMA logic with iMA/CopyBuffer, or Inherit/edit CSignalMA to add an "evaluation shift" and thus evaluate each bar in the past.

  • No one ever told you that checkSignal(i) existed. It was explained to you that this function does not exist because the library is designed to work in real time or in the Tester, evaluating only the current bar. They repeated this to you several times. If you still expected a function like that, then you did not understand the most basic aspects of the framework.
  • You were given two viable solutions: replicate the logic with indicators or extend the class to add a method such as EvaluateAt(i). You rejected them as "unclean", but you did not propose any realistic alternatives. You want advanced functionality without doing the work involved.
  • You claim that the answers were confusing, but in reality, it was you who misinterpreted terms, mixed up concepts, and then diverted attention with sarcasm and personal reproaches.

This is not a problem of a lack of functions in MetaTrader. It is a problem that you want something outside of the intended design and do not accept what that implies: programming it yourself or commissioning someone else to do it.

 
Fernando Carreiro #:

Solid advice, but don't waste your time on this guy. He's not trying to understand anything, just waiting for a copy/paste.

He knows as much about programming as I do about nuclear astrophysics.

And that's not the problem. We're here to help, but you can't help someone who doesn't listen, misinterprets everything, and then blames others for confusing him.

My first post:

Forum on trading, automated trading systems and testing trading strategies

CExpertSignal: get signal results from specified bar index

Miguel Angel Vico Alba, 2025.08.31 09:58

Options:

  • Clone CSignalMA and add a shift parameter to it to go through past bars (the cleanest option). --------->>> And the guy goes and turns this into an "evaluation_shift"...Nice!
  • Replicate the logic of the moving average crossover with iMA and CopyBuffer in a test script/EA.

This will allow you to print signals from the last 200 candles without using the Strategy Tester.

Forum on trading, automated trading systems and testing trading strategies

CExpertSignal: get signal results from specified bar index

harryma23, 2025.08.31 11:15

I want to inherit/edit CSignalMa and add an "evaluation shift":

class MySignalMA : public CSignalMA
  {
protected:
   CiMA              m_ma;             // object-indicator

   //--- adjusted parameters
   int               evaluation_shift; // evaluates the signal from StartIndex() - evaluation_shift

...

int CSignalMA::LongCondition(void)
  {
   int result=0;
   int idx   = StartIndex() - evaluation_shift; // ok?
   ..

  }

But I don't know how to implement this specifically and then iterate to get the desired Print() statements.

Have you done this before? Can you give me an example signal implementation with such an evaluation_shift?

Or is there another source/tutorial that explains this approach in detail? 

I laugh so I don't cry...

 
Miguel Angel Vico Alba #:

Solid advice, but don't waste your time on this guy. He's not trying to understand anything, just waiting for a copy paste.

He knows as much about programming as I do about nuclear astrophysics.

And that's not the problem. We're here to help, but you can't help someone who doesn't listen, misinterprets everything, and then blames others for confusing him.

My first post:


>This is not a problem of a lack of functions in MetaTrader.

Certainly. Maybe MetaTrader StrategyTester has such functions, but doesn't return them to the MQL standard library. Nevertheless, a method like "testing a Signal based on a specific bar index" should exist. So please don't gloss over the lack of such a trivial method.


>He knows as much about programming as I do about nuclear astrophysics.

It's very disrespectful of you to approach me like this, even though I asked simple, objective, clear questions. What can I do if you're beating around the bush while trying to advertise for freelancers?

The fact that you advised me to hurt DRY, replicate the signal logic, deal with buffers again, etc., shows your lack of understanding of good programming and demonstrates your disqualification in this area. And again: if you're giving irrelevant answers to a factual topic, then it's better not to answer at all, and above all: don't insult or irritate others with unprofessional, contradictory answers while talking about hiring a freelancer. My final words to you. 

 
harryma23 #:

Harry, no one glossed over anything. From the very first reply, it was clearly explained that there is no function like checkSignal(i), and that if you want to evaluate a specific bar, you need to implement that logic yourself. That is not "advertising freelancers", it is simply stating the facts.

You keep insisting that it is a "trivial lack" in the library, but you are expecting it to work outside of its intended context. That is not trivial. What is trivial is understanding that if you want something different, it requires different code.

As for your final accusation, suggesting that you use the Freelance section when you clearly do not know how to implement what you are asking for is not an insult. It is the most honest and practical advice you can be given. What is inappropriate is returning with insults and trying to lecture others on software design after admitting that you do not even know how to implement the basic idea yourself.

You have been given detailed replies and several alternatives yet never once acknowledged any of them or showed any appreciation. Demanding solutions without contributing anything is not how this forum works.

If you are not satisfied with the library as it is which is free by the way then extend it or build your own tools but do not expect others to write it for you.

Do you know what the real problem is with requests like yours? If we tell you what to do you do not know how to implement it. If we tell you to leave it to a professional we are accused of selling freelance services.

Learning to program is not part of your modus operandi, is it? Clever move ...