How to retrieve values from a CIndicator

 

I would like to use the classes derived from CIndicator (CiMA, CiStochastic etc) but have had no success.

The code below always shows DBL_MAX

#include <Indicators/trend.mqh>

CiMA extMA;
int OnInit()
  {
   extMA.Create(Symbol(),Period(),10,0,MODE_SMA,PRICE_CLOSE);
   return(0);
  }

void OnTick()
  {
   Comment(extMA.Main(0));
  }

Perhaps I need to use extMA.Refresh(flags), but if so I can't find a value of flags that will work.

Paul

http://paulsfxrandomwalk.blogspot.com/ 

Regularly emailing the status of an account
  • 2012.06.14
  • Paul
  • paulsfxrandomwalk.blogspot.com
Prompted by a query, I thought I'd post a useful little utility that I have used for ages which emails the status of the account every hour.  After lengthy deliberation I decided to call it .... EmailStatus.  With only a small modification it could be used to log the status to a file, and the time...
 

Try this, it should be more properly:

#include <Indicators/trend.mqh>

CiMA extMA;
int OnInit()
  {
   extMA.Create(Symbol(),Period(),10,0,MODE_SMA,PRICE_CLOSE);
   // setup length of indicator buffer as you need
   extMA.BuffSize(neededNumber);
   return(0);
  }

void OnTick()
  {
   extMA.Refresh(-1); // update all MA values
   Comment(extMA.Main(0));
  }

 
It is BufferResize(lenghofthebuffer).
For the rest everything works, thank you so, i mean it's crazy that a post more than 10 years ago is so useful.