Installing an indicator

How to create strategies and indicators
Message
Author
AnkaSoftware
Posts: 6
Joined: Sat Jan 28, 2012 2:54 pm

Installing an indicator

#1 Postby AnkaSoftware » Sat Jan 28, 2012 3:15 pm

Hi,
Am using FT 2 Demo version. While installing the indicator in FT get an error, the screenshot of same enclosed.

The indicator is built in VC++ 10.0 dll, as per the sample given in Examples directory and compiles cleanly without any errors/warnings.
Attachments
FT Error.JPG
FT Error.JPG (17.87 KiB) Viewed 40822 times

dackjaniels
Posts: 151
Joined: Tue Feb 24, 2009 1:03 pm

#2 Postby dackjaniels » Sun Jan 29, 2012 4:58 am

I suggest you post the indicator code, nobody can help you without it.

AnkaSoftware
Posts: 6
Joined: Sat Jan 28, 2012 2:54 pm

#3 Postby AnkaSoftware » Mon Jan 30, 2012 1:50 am

As the problem is with installation of dll not sure, posting of code will help. Anyways my indicator dll is attached.
Attachments
MOVE 3.0.dll
(131 KiB) Downloaded 1209 times

dackjaniels
Posts: 151
Joined: Tue Feb 24, 2009 1:03 pm

#4 Postby dackjaniels » Mon Jan 30, 2012 4:59 am

When I have seen this error in the past it's always been the result of badly constructed code. Code has no compilation errors but has errors relating to how FT uses it. FT recognizes this and refuses to install it. Thats why I suggested posting the code.

P.S. Check the number of indicator buffers declared in code is correct as an incorrect number is often the cause.

AnkaSoftware
Posts: 6
Joined: Sat Jan 28, 2012 2:54 pm

#5 Postby AnkaSoftware » Mon Jan 30, 2012 3:25 pm

Am using 8 Indicators. def and c file enclosed.

Def File

Code: Select all

LIBRARY      Move

EXPORTS Init            @1
       Calculate       @2
      ReplaceStr      @3
       IntrfProcsRec   @4
       OnParamsChange  @5         



C File

Code: Select all

#include <windows.h>
#include <IndicatorInterfaceUnit.h>

#define EMPTY_VALUE 0x7FFFFFFF
#define EMPTY -1
#define WHOLE_ARRAY 0


#define VK_J   74

#define releaseNameDef "!MOVE v 3.1 ForexTester (20111225.1700)"
#define copyRightDef "AwarenessForex.com © 2011"


int MoveIgnoreDistance;
double RetracementQualifier;


HWND WindowHandle;

TIndexBuffer Down1;
TIndexBuffer Down2;
TIndexBuffer Down3;
TIndexBuffer Down4;
TIndexBuffer Up1;
TIndexBuffer Up2;
TIndexBuffer Up3;
TIndexBuffer Up4;


extern "C" void __stdcall Init() {

   // Indicator Variables

   // define properties
   IndicatorShortName("Move 3.1 ForexTester");
   SetOutputWindow(ow_ChartWindow);

   // register options
   AddSeparator("Common");

   RegOption("EA_ID", ot_Integer, &EA_ID);
   EA_ID = "";

   RegOption("MoveComplete", ot_PChar, &MoveComplete);
   SetOptionRange("MoveComplete", 1, 100000);
   MoveComplete = 80;


   Down1 = CreateIndexBuffer();
   Down2 = CreateIndexBuffer();
   Down3 = CreateIndexBuffer();
   Down4 = CreateIndexBuffer();
   Up1 = CreateIndexBuffer();
   Up2 = CreateIndexBuffer();
   Up3 = CreateIndexBuffer();
   Up4 = CreateIndexBuffer();

   IndicatorBuffers(8);
   //SetEmptyValue(EMPTY_VALUE);

   // Initialize the indicators
   SetIndexBuffer(0, Down1);
   SetIndexStyle(0, ds_Line, psSolid, 1, clRed);
   SetIndexLabel(0, "Down1");

   SetIndexBuffer(1, Down2);
   SetIndexStyle(1, ds_Line, psSolid, 1, clRed);
   SetIndexLabel(1, "Down2");

   SetIndexBuffer(2, Down3);
   SetIndexStyle(2, ds_Histogram, psSolid, 1, clRed);
   SetIndexLabel(2, "Down3");

   SetIndexBuffer(3, Down4);
   SetIndexStyle(3, ds_Histogram, psSolid, 1, clRed);
   SetIndexLabel(3, "Down4");
   
   SetIndexBuffer(4, Up1);
   SetIndexStyle(4, ds_Line, psSolid, 1, clYellow);
   SetIndexLabel(4, "Up1");

   SetIndexBuffer(5, Up2);
   SetIndexStyle(5, ds_Line, psSolid, 1, clYellow);
   SetIndexLabel(5, "Up2");
   
   SetIndexBuffer(6, Up3);
   SetIndexStyle(6, ds_Histogram, psSolid, 1, clYellow);
   SetIndexLabel(6, "Up3");

   SetIndexBuffer(7, Up4);
   SetIndexStyle(7, ds_Histogram, psSolid, 1, clYellow);
   SetIndexLabel(7, "Up4");

   return;
}


extern "C" void __stdcall  OnParamsChange()
{
}


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
extern "C" void __stdcall Calculate(int index) {
}
[/code]

KelvinHand
Posts: 103
Joined: Sun Jan 02, 2011 6:05 pm

#6 Postby KelvinHand » Mon Jan 30, 2012 6:33 pm

These statements seen some mistake:

ED_ID is ot_Integer, but you assign EA_ID = ""

RegOption("EA_ID", ot_Integer, &EA_ID);
EA_ID = "";

MoveComplete should be ot_Interger, but you use ot_PChar

RegOption("MoveComplete", ot_PChar, &MoveComplete);
SetOptionRange("MoveComplete", 1, 100000);
MoveComplete = 80;

AnkaSoftware
Posts: 6
Joined: Sat Jan 28, 2012 2:54 pm

#7 Postby AnkaSoftware » Tue Jan 31, 2012 12:52 am

The original problem still exists after fixing the bugs reported in the previous post.

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

#8 Postby FT Support » Wed Feb 01, 2012 6:16 am

Please try to remove most part of the code from initialization procedure, does it help?
Does it work fine if you compile the example of indicator from Forex tester\Examples\Indicators\C++ folder?
Check our other product here:
http://www.forexcopier.com

User avatar
Tantalus
Posts: 302
Joined: Fri Mar 23, 2007 3:51 pm
Contact:

#9 Postby Tantalus » Wed Feb 01, 2012 10:53 am

In a case like this, my recommendation is to comment out all active code (lines that do not make up the 'skeleton' of the indicator) and compile to see if it will run. You will essentially be making an indicator that does nothing, but it should be able to 'run' successfully.

Then, start un-commenting lines of code one by one and recompiling and running until to come to a line which causes the crash. It sounds tedious, I know, but it's a sure way to find out exactly what FT is choking on in cases like this where the code compiles perfectly but gives run-time errors.
Tantalus Research - Developing 21st Century Trading Systems.

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

#10 Postby FT Support » Thu Feb 02, 2012 7:23 am

Tantalus wrote:In a case like this, my recommendation is to comment out all active code (lines that do not make up the 'skeleton' of the indicator) and compile to see if it will run. You will essentially be making an indicator that does nothing, but it should be able to 'run' successfully.

Then, start un-commenting lines of code one by one and recompiling and running until to come to a line which causes the crash. It sounds tedious, I know, but it's a sure way to find out exactly what FT is choking on in cases like this where the code compiles perfectly but gives run-time errors.


Thank you Tantalus, this is the best way to find an issue which causes indicator crash
Check our other product here:
http://www.forexcopier.com

Wessel
Posts: 63
Joined: Tue Oct 12, 2010 6:45 pm

#11 Postby Wessel » Fri Feb 10, 2012 8:56 am

AnkaSoftware,

To get indicators to work with C++, you need to install teh MSVC libs on the PC you are using FT on. This will most likely solve your problem.

Look at the MACDx that I've build in Visual C++:
http://www.forextester.com/forum/viewto ... light=macd

There is a readme that explains with libs you need to install to get indicators to work that where build with Visual C++


Wessel

AnkaSoftware
Posts: 6
Joined: Sat Jan 28, 2012 2:54 pm

#12 Postby AnkaSoftware » Thu Feb 16, 2012 2:13 pm

Hi All,
Thanks for the suggestions.

I have full version of VS 2010 installed and MSVCP100.dll is already installed.

I isolated the problem to calls to the following ForexTester Functions - Symbol(), Digits() and Point(). Replacing these function call and replacing them by hardcoded values, does not throw any errors while installing the indicator in ForexTester (refer to screen shots attached earlier in the thread).

Any workaround for this problem? Or I need to build a separate dll for each pair I want to test on?

User avatar
Tantalus
Posts: 302
Joined: Fri Mar 23, 2007 3:51 pm
Contact:

#13 Postby Tantalus » Thu Feb 16, 2012 2:49 pm

Again, it's impossible to know what might be the problem without seeing your code. The functions you mention are typical built-in API functions so if they are throwing exceptions I must assume it's because of the way they are being used. Without seeing the code itself there's no way we can help you to figure out what you've done wrong.

Just post the code files zipped up.. it would be easier to review that way than pasting the text into the message.
Tantalus Research - Developing 21st Century Trading Systems.

AnkaSoftware
Posts: 6
Joined: Sat Jan 28, 2012 2:54 pm

#14 Postby AnkaSoftware » Fri Feb 24, 2012 4:46 pm

Thanks for your reply.

I am using standard methods of accessing the string returned by function Symbol(). For each of the method I am running into same memory access error thrown by ForexTester (screenshot in the first mail of this thread).

Tried the following:
char* symbol;

with
symbol = Symbol();
ReplaceStr(symbol, Symbol());

char symbol[6];

with
memcpy(symbol, Symbol(), 6);
strcpy(symbol, Symbol());

etc

edoughig
Posts: 7
Joined: Wed May 15, 2013 4:12 pm

Status on this issue

#15 Postby edoughig » Wed May 15, 2013 4:16 pm

I am having the same issue with an access violation when trying to install my indicator written in c++. I have commented code and narrowed it down to this line:

multiply = pow(10.0, Digits());

Has there been any progress on this issue or any resolution?

Thanks!

KelvinHand
Posts: 103
Joined: Sun Jan 02, 2011 6:05 pm

Re: Status on this issue

#16 Postby KelvinHand » Wed May 15, 2013 6:28 pm

edoughig wrote:I am having the same issue with an access violation when trying to install my indicator written in c++. I have commented code and narrowed it down to this line:

multiply = pow(10.0, Digits());

Has there been any progress on this issue or any resolution?

Thanks!


The problem is not on the pow function.
The problem is on the Digits() function, you can test it out using
x =Digits()
during the initialization, the access violation still will throw out.

Even Delphi version also the same issue.

During Init(), likely the Digits() is not properly intialize yet.

To solve that, move it to Calculate() function.

edoughig
Posts: 7
Joined: Wed May 15, 2013 4:12 pm

#17 Postby edoughig » Thu May 16, 2013 8:11 am

Very cool. I figured it was the Digits() function as I had similar issues with Point and Symbol. I will try moving it to Calculate and check it out. Thanks for the help!

edoughig
Posts: 7
Joined: Wed May 15, 2013 4:12 pm

Re: Status on this issue

#18 Postby edoughig » Thu May 16, 2013 8:46 am

KelvinHand wrote:
edoughig wrote:I am having the same issue with an access violation when trying to install my indicator written in c++. I have commented code and narrowed it down to this line:

multiply = pow(10.0, Digits());

Has there been any progress on this issue or any resolution?

Thanks!


The problem is not on the pow function.
The problem is on the Digits() function, you can test it out using
x =Digits()
during the initialization, the access violation still will throw out.

Even Delphi version also the same issue.

During Init(), likely the Digits() is not properly intialize yet.

To solve that, move it to Calculate() function.


Sure enough, that was the fix. Thanks again for the help and quick response!


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 30 guests