Topic: Calling standard indicator in mqh fails

I just copy-pasted ATR call, and I get ton of errors. After thorough check it does not seem my error, it must be FSB's bug.

// ----------------------------------------------------
   AverageTrueRange *atr=new AverageTrueRange(SlotType);
   atr.ListParam[1].Index= ListParam[1].Index;
   atr.NumParam[0].Value = NumParam[0].Value;
   atr.CheckParam[0].Checked=CheckParam[0].Checked;
   atr.Calculate(dataSet);

   double indicator1[];
   ArrayResize(indicator1,Data.Bars);
   ArrayCopy(indicator1,atr.Component[0].Value);

   delete atr;

   double indicator2[];
   MovingAverage(period2,0,maSignalMaMethod,indicator1,indicator2);
// -----------------------------------------------------

http://s9.postimg.org/j3hrj3sjv/errs.jpg

Re: Calling standard indicator in mqh fails

Where you pasted this code? Can you attach whole strategy?

I just exported a strategy with ATR MA Oscillator and it works perfectly.

http://s28.postimg.org/oyf4m5di1/screenshot_853.jpg

Re: Calling standard indicator in mqh fails

Do you develop a custom indicator that requires ATR? If you do so, you have to add this line in your indicator:

//## Requires AverageTrueRange.mqh

Like that:

#include <Forexsb.com/Indicator.mqh>
#include <Forexsb.com/Enumerations.mqh>
#include <Forexsb.com/Indicators/AverageTrueRange.mqh>
//## Requires AverageTrueRange.mqh

class ATRMAOscillator : public Indicator
  {
public:
   ATRMAOscillator(SlotTypes slotType)
     {
      SlotType=slotType;

Re: Calling standard indicator in mqh fails

//## Requires AverageTrueRange.mqh  -- Isn't this line commented out? I did add the line above it --> #include <Forexsb.com/Indicators/AverageTrueRange.mqh>

Yep, it works for me too when I export FSB's standard indicators which call another standard indicator, like in your case with ATRMaOsc.

My point was that when developing custom indicators, where I call FSB's standard indicators, I get the errors. As a matter of fact I just tried doing it with RSI, and the same list of errors if not more occur, so I'll stand by my previous post.

EDIT: substituted the call with standard indi calculation and everything compiles.

Re: Calling standard indicator in mqh fails

To prove my words there are 2 files, put them in their respective places, export it as an EA and see what happens! wink

Post's attachments

FAIL.cs 12.98 kb, 4 downloads since 2015-04-01 

FAIL.mqh 6.1 kb, 4 downloads since 2015-04-01 

You don't have the permssions to download the attachments of this post.

Re: Calling standard indicator in mqh fails

Include that line:

//## Requires AverageTrueRange.mqh

It is commented, but it has another purpose. I'll explain its meaning.
When you export an EA from FSB Pro, the program includes the indicators codes also in the expert. It however, includes only indicators used by the strategy. In your case you have an indi that requires  AverageTrueRange , but your strategy doesn't use AverageTrueRange directly. That's why the exported EA doesn't include the ATR code and gives errors. The program uses such lines as //## Requires AverageTrueRange.mqh as commands to include other indicators in the expert. If you write this line in your custom indi code, FSB will include the original ATR in the expert and everything will be fine.

If you see the first error of the expert: 'AverageTrueRange' - undeclared identifier, it means that the expert doesn't include that code.

The line is commented because it must not give effects on your custom indicator code directly.

#include <Forexsb.com/Indicators/AverageTrueRange.mqh> lines are removed when FSB Pro generates an expert.

Everything will be fine, if you follow the standard format.
It is however my fault that the process is not documented.

Re: Calling standard indicator in mqh fails

Thanks for the info!

If you look at my example "FAIL", you'll see that the comment is there but still it won't compile.

Re: Calling standard indicator in mqh fails

You are right,
No idea why it doesn't work. I'll fix it.

Re: Calling standard indicator in mqh fails

The problem is the program checks for indicator dependencies before adding the custom indicators.

I can show you a hack to make it running.
Set //## Requires RSI.mqh to one of your standard indicators and the program will load it.

http://s28.postimg.org/ghfmb88t5/screenshot_855.jpg

Re: Calling standard indicator in mqh fails

Thanks, will take note of this!

Re: Calling standard indicator in mqh fails

Footon,
I fixed that issue. I'll upload FSB Pro update on Saturday.

Re: Calling standard indicator in mqh fails

Thanks! Great effort!

Re: Calling standard indicator in mqh fails

I got finally a chance to test this out again, but unfortunately the same set of errors remain. Should I upload the files?

Re: Calling standard indicator in mqh fails

Yes of course. Send me the file that fails.

Re: Calling standard indicator in mqh fails

Here it is: .cs, .mqh and the EA.

Post's attachments

ST.rar 40.71 kb, 3 downloads since 2015-06-01 

You don't have the permssions to download the attachments of this post.

Re: Calling standard indicator in mqh fails

Try to add "//## Requires AverageTrueRange.mqh" on the beginning of the file like that:

#include <Forexsb.com/Indicator.mqh>
#include <Forexsb.com/Enumerations.mqh>
//## Requires AverageTrueRange.mqh

This will force FSB to include ATR code in the expert.

Re: Calling standard indicator in mqh fails

I have done it already! (I put the wrong version into the archive, I corrected it now. All testing has been done with the current one found in the archive)


http://s17.postimg.org/j1fpqur7v/error.jpg

Re: Calling standard indicator in mqh fails

I'm not on the comp now, but the previous file opened. Try removing the "include ATR..." line.

Re: Calling standard indicator in mqh fails

No problems, take your time.

It's not working, I've combined it this way and the other, but it's just not working. It might be a silly mistake from my side, but I can't locate it.

Re: Calling standard indicator in mqh fails

The expert compiles but gives another error with the calculation of ATR. I'll try to figure out what it happens and will upload the indicator file.

Re: Calling standard indicator in mqh fails

I don't know why it doesn't run on your comp. I just added the "//## Requires AverageTrueRange.mqh" code and the expert compiles. However another error appeared and I see you have fixed in the mqh file. The required ATR needs one bar more than the SuperTrend and probably this was the reason to add +1 to the firstBar in the mqh file. The problem was that the firstBar was not edited in the SuperTrend.cs file.

Please find the files attached. The changes are:
Added "//## Requires AverageTrueRange.mqh" on line 31 of the mqh file;

Added +1 to the firstBar on line 134 of the cs file.

int iFirstBar = iPeriod + iPrvs +1;
Post's attachments

SuperTrend.cs 18.32 kb, 4 downloads since 2015-06-01 

SuperTrend.mqh 10.23 kb, 7 downloads since 2015-06-01 

You don't have the permssions to download the attachments of this post.

Re: Calling standard indicator in mqh fails

Thanks for looking into this, but bloody hell, it still won't compile on my end. MT compiler is daft on my end???

Re: Calling standard indicator in mqh fails

What kind of Metaeditor build are you using?

Re: Calling standard indicator in mqh fails

I tried it on MT5, same issues are there too. A bit more global this is.

If anyone wants to help out, please download those 2 indi files, export and try compiling them. It would be somewhat helpful to know if I'm the isolated case here.

Thank you!

Re: Calling standard indicator in mqh fails

Can you try my experet. It runs in both MT4 and MT5.


http://s28.postimg.org/3q9ef3f7t/screenshot_946.jpg

Post's attachments

New Strategy.mq4 269.89 kb, 7 downloads since 2015-06-01 

You don't have the permssions to download the attachments of this post.