Forex Tester Forum (Professional Training Software for Traders) Forum Index Forex Tester Forum (Professional Training Software for Traders)

Back to main site   Risk disclosure
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    Forex Tester Forum (Professional Training Software for Traders) Forum Index -> FT API
View previous topic :: View next topic  
Author Message
fx_pete



Joined: 30 Jan 2012
Posts: 17

PostPosted: Sun Feb 05, 2012 4:08 am    Post subject: Problem with ADX function +DI/-DI buffers!? Reply with quote

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

Quote:

'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:

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
Back to top
View user's profile Send private message
fx_pete



Joined: 30 Jan 2012
Posts: 17

PostPosted: Sun Feb 05, 2012 7:20 pm    Post subject: FT support?? Reply with quote

need help on this, I am not sure how much I can trust the API?
Back to top
View user's profile Send private message
fx_pete



Joined: 30 Jan 2012
Posts: 17

PostPosted: Sun Feb 05, 2012 10:05 pm    Post subject: weird ... Reply with quote

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?
Back to top
View user's profile Send private message
FT Support



Joined: 11 Jul 2009
Posts: 901

PostPosted: Mon Feb 06, 2012 5:16 pm    Post subject: Reply with quote

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 products here:
www.fx-metropolis.com
www.forexcopier.com
Back to top
View user's profile Send private message Visit poster's website
fx_pete



Joined: 30 Jan 2012
Posts: 17

PostPosted: Mon Feb 06, 2012 8:11 pm    Post subject: ok here goes ... Reply with quote

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:

#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);

}



FX Tester - ADX discrepancy.JPG
 Description:
 Filesize:  222.99 KB
 Viewed:  6211 Time(s)

FX Tester - ADX discrepancy.JPG


Back to top
View user's profile Send private message
FT Support



Joined: 11 Jul 2009
Posts: 901

PostPosted: Tue Feb 07, 2012 9:05 am    Post subject: Reply with quote

Thank you for the code

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

Code:

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 products here:
www.fx-metropolis.com
www.forexcopier.com
Back to top
View user's profile Send private message Visit poster's website
fx_pete



Joined: 30 Jan 2012
Posts: 17

PostPosted: Tue Feb 07, 2012 9:58 pm    Post subject: hey ... Reply with quote

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

Peter
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Forex Tester Forum (Professional Training Software for Traders) Forum Index -> FT API All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group