IndicatorCounted in FT3

How to create strategies and indicators
Message
Author
egorpe
Posts: 2
Joined: Thu Jun 29, 2017 5:09 am

IndicatorCounted in FT3

#1 Postby egorpe » Thu Jun 29, 2017 5:14 am

IndicatorCounted function is not present in FT3 API, so how would you convert this MQL4 loop to FT3?

Code: Select all

int counted_bars = IndicatorCounted();
if (counted_bars > 0) { counted_bars--; }
int limit = Bars - counted_bars;

for (int i = 0; i < limit; i++) {
   // calculations happen here using High(i), Low(i), Volume(i), etc...
}


I couldn't figure it out from the documentation.

User avatar
neHcioHep
Posts: 18
Joined: Sat Nov 21, 2009 5:49 pm
Contact:

Re: IndicatorCounted in FT3

#2 Postby neHcioHep » Fri Jun 30, 2017 7:51 am

egorpe wrote:IndicatorCounted function is not present in FT3 API, so how would you convert this MQL4 loop to FT3?

Code: Select all

int counted_bars = IndicatorCounted();
if (counted_bars > 0) { counted_bars--; }
int limit = Bars - counted_bars;

for (int i = 0; i < limit; i++) {
   // calculations happen here using High(i), Low(i), Volume(i), etc...
}


I couldn't figure it out from the documentation.



You can use your calculations in the Calculate method.

For example, you have next code

Code: Select all

in start()
{
   int counted_bars = IndicatorCounted();
   if (counted_bars > 0) { counted_bars--; }
   int limit = Bars - counted_bars;

   for (int i = 0; i < limit; i++) {
      // calculations happen here using High(i), Low(i), Volume(i), etc...
   }
}


So in ForexTester this code should be like this

Code: Select all

EXPORT void __stdcall Calculate(int index)
{
   // calculations happen here using High(index), Low(index), Volume(index), etc...
}

egorpe
Posts: 2
Joined: Thu Jun 29, 2017 5:09 am

Re: IndicatorCounted in FT3

#3 Postby egorpe » Tue Jul 11, 2017 11:13 pm

Yeah, I figured that out but it is still messed up in some way.

I tried to port a better volume indicator from MQL to ForexTester.

My code is on GitHub.

The original is here https://github.com/egorpe/ForexTester-B ... me-1.4.mq4

The port is here https://github.com/egorpe/ForexTester-B ... me-1.4.cpp

It is a basic copy and paste but the results are completely messed up in ForexTester version.

What am I doing wrong?


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 28 guests