Problem with ADX function +DI/-DI buffers!?

How to create strategies and indicators
Message
Author
fx_pete
Posts: 17
Joined: Mon Jan 30, 2012 2:31 pm

Problem with ADX function +DI/-DI buffers!?

#1 Postby fx_pete » Sat Feb 04, 2012 11:08 pm

according to the API doc. the definition of ADX is as follows:

'ADX'
'<Period: integer>; <ApplyToPrice: string>'
'14;Open'
0..2 :Internal buffers
3 : ADX buffer
4 : + Di buffer
5 :- Di buffer


now for some reason after successfuly geting the handle to the ADX function and storing it in indADX variable, the following code:

Code: Select all

dmi_p =
   GetIndicatorValue(indADX, 0, 4);  // 0=curr bar, 4=DI+ value buffer
dmi_m =
   GetIndicatorValue(indADX, 0, 5);  // 0=curr bar, 5=DI- value buffer

mostly returns 0 for dmi_p and a a value for dmi_m that looks like should infact be the value of dmi_p.

Actually, comparing the +DI and -DI values returned by the GetIndicatorValue() function with the ones plotted don't seem to match at all.

Has the definition of ADX changed so that I am using the wrong indeces for the DI buffers? Or am I missing something here?

Thanks to anyone that can shed some light on this ...

Peter

fx_pete
Posts: 17
Joined: Mon Jan 30, 2012 2:31 pm

FT support??

#2 Postby fx_pete » Sun Feb 05, 2012 2:20 pm

need help on this, I am not sure how much I can trust the API?

fx_pete
Posts: 17
Joined: Mon Jan 30, 2012 2:31 pm

weird ...

#3 Postby fx_pete » Sun Feb 05, 2012 5:05 pm

ok the GetIndicatorValue() function keeps returning weird numbers for+DI. The number will vary something like this ...
40, 50, 50, 50, 75, 50, 100, 100, 100, 66.666, 66.666, 33.33, 50, 0, 0, 0 ...

so yeah I dont know what to make of this , and would appreciate some feedback on this. Any one else encounter a problem with the +DI/-DI values returned from the ADX indicator?

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#4 Postby FT Support » Mon Feb 06, 2012 12:16 pm

Hello Pete,

please create a very simple strategy which only shows indicator values (use "Print" to show the value in journal). after that run this strategy and compare the values on the chart and in journal, if the values are different then post the code of your strategy and the screenshot with the difference here
Check our other product here:
http://www.forexcopier.com

fx_pete
Posts: 17
Joined: Mon Jan 30, 2012 2:31 pm

ok here goes ...

#5 Postby fx_pete » Mon Feb 06, 2012 3:11 pm

here is the code and the screenshot. Actually the numbers dont make sense to me. If you look at the timestamp for each close and compare the journal entries for +DI with what is being plotted then it looks way off.

Code: Select all

#include <windows.h>
#include "StrategyInterfaceUnit.h"
#include "TechnicalFunctions.h"

int         indADX;
int         lookback      = 14;         // stop in pips
int         timeFrame      = PERIOD_M5;   // 5MIN time frame
char*      currency      = "EURUSD";      // Pointer to definition of working currency


EXPORT void __stdcall InitStrategy()
{
   StrategyShortName("Function Test");
   StrategyDescription("Simple test to see if API function is working correctly");
}

EXPORT void __stdcall DoneStrategy()
{
   free(currency);
}

EXPORT void __stdcall  ResetStrategy()
{
   /* create ADX indicator and get its handle
    */
   char adx_buff[1000];

   // define CreateIndicator() parameters argument
   sprintf(adx_buff, "%d;Close", lookback, "ADX");

   // call function and get the indicator handle
   indADX = CreateIndicator(currency, timeFrame, "ADX", adx_buff);
}

EXPORT void __stdcall GetSingleTick()
{
   // vars
   double      dmi_p = 0.0;   // DMI plus value
   double      dmi_m = 0.0;   // DMI minus value

   if (strcmp(Symbol(), currency) != 0)
      exit; // ... when working currency does not match the symbol
   
   SetCurrencyAndTimeframe(currency, timeFrame);

   /* Get indicator values
    */

   dmi_p = GetIndicatorValue(indADX, 0, 4);            // 0=curr bar, 4=DI+ value buffer
   dmi_m = GetIndicatorValue(indADX, 0, 5);            // 0=curr bar, 5=DI- value buffer

   char buff[1000];

   //fill the text buffer
   sprintf(buff, "(+DI/-DI) =%.4f; / %.4f", dmi_p, dmi_m);

   Print(buff);

}
Attachments
FX Tester - ADX discrepancy.JPG
FX Tester - ADX discrepancy.JPG (222.99 KiB) Viewed 16125 times

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#6 Postby FT Support » Tue Feb 07, 2012 4:05 am

Thank you for the code

Please try using buffers 1 (DI+) and 2 (DI-) instead of 4 and 5

Code: Select all

dmi_p = GetIndicatorValue(indADX, 0, 1);            // maybe there is a mistake in help and buffer # 1 should be used
dmi_m = GetIndicatorValue(indADX, 0, 2);            // maybe there is a mistake in help and buffer # 2 should be used
Check our other product here:
http://www.forexcopier.com

fx_pete
Posts: 17
Joined: Mon Jan 30, 2012 2:31 pm

hey ...

#7 Postby fx_pete » Tue Feb 07, 2012 4:58 pm

:D now we are getting somewhere!! Thanks, that did it. I apreciate your help.

Peter


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 9 guests