Released Strategies API for Microsoft Visual C++

How to create strategies and indicators
Message
Author
User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

Released Strategies API for Microsoft Visual C++

#1 Postby Terranin » Sun Mar 25, 2007 3:22 pm

Now Strategies API available not only for Borland Delphi but for Microsoft Visual C++ also. Below you can find attached API files with examples and documentation.
Attachments
StrategiesHelp.zip
Documentation
(82.29 KiB) Downloaded 1477 times
api+example.zip
API files with strategy example
(30.18 KiB) Downloaded 1461 times
Hasta la vista
Mike

pion
Posts: 1
Joined: Mon Mar 19, 2007 5:40 pm

#2 Postby pion » Wed Mar 28, 2007 7:51 pm

Hi Terranin,
what is the latest C++ API header file: IndicatorInterfaceUnit.h? I found some version inside: http://forextester.ru/forum/download.php?id=19
have you released formal Indicator API??

Thanks

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

#3 Postby Terranin » Wed Mar 28, 2007 8:47 pm

pion wrote:Hi Terranin,
what is the latest C++ API header file: IndicatorInterfaceUnit.h? I found some version inside: http://forextester.ru/forum/download.php?id=19
have you released formal Indicator API??

Thanks


No, it was an old effort to translate indicators' API. It is not ready yet.
Hasta la vista

Mike

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

#4 Postby Tantalus » Fri Mar 30, 2007 3:55 pm

Can this API be used to create plain indicators, too? I know a little C, so I think it might be easier for me than learning Delphi, which is based on Pascal.

If so, where might I find instructions and examples for writing indicators in C?

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

#5 Postby Terranin » Fri Mar 30, 2007 4:26 pm

Tantalus wrote:Can this API be used to create plain indicators, too? I know a little C, so I think it might be easier for me than learning Delphi, which is based on Pascal.

If so, where might I find instructions and examples for writing indicators in C?


Indicators' C++ API will be available soon.
Hasta la vista

Mike

patronus
Posts: 8
Joined: Tue Apr 15, 2008 4:31 pm
Location: Sacramento CA

Indicator Code Supplied is in Delphi!

#6 Postby patronus » Tue Apr 15, 2008 4:39 pm

Will similar code be released in C++ for these indicators? Do you have any sample C++ indicators I could use to model mine? I'm specifically looking to create a Momentum-ZL which is a relatively small change to the basic Momentum indicator.

Any help would be appreciated.

Thanks...

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

Re: Indicator Code Supplied is in Delphi!

#7 Postby Terranin » Tue Apr 15, 2008 5:41 pm

patronus wrote:Will similar code be released in C++ for these indicators? Do you have any sample C++ indicators I could use to model mine? I'm specifically looking to create a Momentum-ZL which is a relatively small change to the basic Momentum indicator.

Any help would be appreciated.

Thanks...


There is already API available for C++, you can find it after installation in ForexTester\Examples\ folder. There is one strategy example and one indicator (Ishimoku) example.
Hasta la vista

Mike

FinGeR
Posts: 72
Joined: Wed Apr 23, 2008 12:24 pm

#8 Postby FinGeR » Mon Aug 04, 2008 2:39 pm

--

User avatar
frank_horrigan
Posts: 7
Joined: Sat Jan 16, 2010 7:59 am
Location: Pribram, Czech Rep.

Sample of C API strategy

#9 Postby frank_horrigan » Sat Jan 16, 2010 8:13 am

Hello Mike and others,
can you anyone provide me some simple strategy written by C++ API, which I can use to learn how to write my own ideas :) When I viewed the headers, function prototypes and definitions (StrategyInterfaceUnit) it apperar as very similar to MQL, with that I wrote (and live running) some strategies. But, the MQL and Metatrader has limitations which is bad for me (no Multipair trades on one EA), total absention of constants and structures (when I need function return more than one variable, what I can do? (other than wrote some structure and this return?).

So, if you have some usable and "learnable how it works" strategy, can you email (or PM) me its code?? (I using in entry decision CCI, Envelopes and EMA, if the code would contains how use this, i will be great)

Last question: Can I mount the DLL to metatrader's EA and run it at live account? If is possibe, how to do? (I'm going to definitively leave the MQL, if it is possible, this will be great way) :)
The Market can stay irrational longer than you can stay solvent

User avatar
frank_horrigan
Posts: 7
Joined: Sat Jan 16, 2010 7:59 am
Location: Pribram, Czech Rep.

Re: Indicator Code Supplied is in Delphi!

#10 Postby frank_horrigan » Sat Jan 16, 2010 8:30 am

Terranin wrote:
There is already API available for C++, you can find it after installation in ForexTester\Examples\ folder. There is one strategy example and one indicator (Ishimoku) example.


In quoted directory I have not anything usable, only headers which contains definitions and prototypes, an one .CPP file which tells some about object create/set/modify/delete routines. If I had example, I'll not ask you for it, of course :) Indicator example (ichomuko kinko hyo I have, but this is useless for me ;) )
The Market can stay irrational longer than you can stay solvent

User avatar
frank_horrigan
Posts: 7
Joined: Sat Jan 16, 2010 7:59 am
Location: Pribram, Czech Rep.

#11 Postby frank_horrigan » Sat Jan 16, 2010 1:28 pm

So, I had success with coding "extern" variables and similar stuff, as explained in the "programming lessons" In addition, I was understood how to use send/modify/delete orders, is wrote in similar analogy as MQL. But, and with it I cannot solve: How I can use the Time functions? (is sufficient "relative", so as in MQL Hour(), Minute() and Second() - I drive enter to position in the "entry if" as if( condition && condition &&.......&& Minute() ==0 && BARS != Bars) where assigment BARS=Bars is called when OrderSend(...) returns non-zero integer (ticket num) -so entry condition remains on Minute() ==0 - how I can write it by FT C++ API??
Another question: How I may use built-in indicators, as is CCI, RSI, MA, Stoch, and so on?? In MQL analogy, they I call as iCCI(Currency, TF, Period, UsedPriceToCalculation, shift). Any ideas and/or solutions?
The Market can stay irrational longer than you can stay solvent

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

#12 Postby Terranin » Sat Jan 16, 2010 2:16 pm

frank_horrigan wrote:So, I had success with coding "extern" variables and similar stuff, as explained in the "programming lessons" In addition, I was understood how to use send/modify/delete orders, is wrote in similar analogy as MQL. But, and with it I cannot solve: How I can use the Time functions? (is sufficient "relative", so as in MQL Hour(), Minute() and Second() - I drive enter to position in the "entry if" as if( condition && condition &&.......&& Minute() ==0 && BARS != Bars) where assigment BARS=Bars is called when OrderSend(...) returns non-zero integer (ticket num) -so entry condition remains on Minute() ==0 - how I can write it by FT C++ API??
Another question: How I may use built-in indicators, as is CCI, RSI, MA, Stoch, and so on?? In MQL analogy, they I call as iCCI(Currency, TF, Period, UsedPriceToCalculation, shift). Any ideas and/or solutions?


Check this topic how to work with time http://www.forextester.com/forum/viewtopic.php?t=1000&highlight=unix

with that functions you can convert time to C++ format and then use standard C++ functions to get seconds/minutes/hours from this time.

To use any indicator that you can see in Forex Tester you need to create it first in ResetStrategy procedure and get handle of it (this will put it on the chart). Then you can use this handle to get values. See Strategies help file -> Access to indicators, functions CreateIndicator and GetIndicatorValue.

Parameters that you send to the CreateIndicator should be absolutely the same as you can see in its properties dialog window and in the same order (excluding buffer styles). So, for Moving Average it will be next call for example:

ma_handle := CreateIndicator('USDJPY', 60, 'MovingAverage', '64;0;0;Simple (SMA);Close');

// parameters are separated with ;

then you can use this handle

curr := GetIndicatorValue(ma_handle, 0, 0);
prev := GetIndicatorValue(ma_handle, 1, 0);

second parameter is number of bar, third parameter is number of buffer (if you have more then one in this indicator, for example bollinger bands has 3 buffers for 3 lines)
Hasta la vista

Mike

User avatar
frank_horrigan
Posts: 7
Joined: Sat Jan 16, 2010 7:59 am
Location: Pribram, Czech Rep.

#13 Postby frank_horrigan » Sun Jan 17, 2010 12:37 pm

Terranin wrote:
So, for Moving Average it will be next call for example:

ma_handle := CreateIndicator('USDJPY', 60, 'MovingAverage', '64;0;0;Simple (SMA);Close');



Thanks for advise, Mike, everything what I need now runs (or I have a way how write it :) But, your sample code as qouted above is mystificating, the good writing is as follows

Code: Select all

char EMABuff[1000];
sprintf(EMABuff, "%d;%d;%s;%s", EMAPeriod, 0, StrMAType(ma_EMA), StrPriceType(pt_Close));
iEMA = CreateIndicator(Pair, TF, "MovingAverage",EMABuff);


But all is ok, now I can write everything which I can understand how it works. Thanks again :)
The Market can stay irrational longer than you can stay solvent

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

#14 Postby Terranin » Sun Jan 17, 2010 1:00 pm

frank_horrigan wrote:
Terranin wrote:
So, for Moving Average it will be next call for example:

ma_handle := CreateIndicator('USDJPY', 60, 'MovingAverage', '64;0;0;Simple (SMA);Close');



Thanks for advise, Mike, everything what I need now runs (or I have a way how write it :) But, your sample code as qouted above is mystificating, the good writing is as follows

Code: Select all

char EMABuff[1000];
sprintf(EMABuff, "%d;%d;%s;%s", EMAPeriod, 0, StrMAType(ma_EMA), StrPriceType(pt_Close));
iEMA = CreateIndicator(Pair, TF, "MovingAverage",EMABuff);


But all is ok, now I can write everything which I can understand how it works. Thanks again :)


Yes, I tried to make it simple to understand. But note, MA has 1 more parameter now (help was not updated about that). So you need to write

Code: Select all

char EMABuff[1000];
sprintf(EMABuff, "%d;%d;%d;%s;%s", EMAPeriod, 0, 0, StrMAType(ma_EMA), StrPriceType(pt_Close));
iEMA = CreateIndicator(Pair, TF, "MovingAverage",EMABuff);


because new parameter was added for VShift. That's why you should check parameters of indicator in dialog window first. There is a trick, if you pass invalid parameters indicator will be still created but with default parameters and you will get a record in Journal about that. It can raise some problems later, if you strategy creates indicators - instead of reusing existing indicator on each start it will create new one, and you will get lots of indicators that will slow your testing.
Hasta la vista

Mike

User avatar
frank_horrigan
Posts: 7
Joined: Sat Jan 16, 2010 7:59 am
Location: Pribram, Czech Rep.

#15 Postby frank_horrigan » Mon Jan 18, 2010 5:51 pm

Terranin wrote:because new parameter was added for VShift


Ok, I will get it for my mind, but it runs me without this additional parameter. Do I some mistake? (I had some problems with OrderCloseTime() and order handling variable, it is reason for I didnt reply soon - solved (I expected that if order is triggered and live, OrderCloseTime() returns zero, as in MT, but it isnt true, and I need to find other way [ I plan use the DLL as EA for MT, orderstotal() is non-effective for mine] VShift I undestrand asi vertical offset, similar to what is using envelopes, is it true? (I have very old version of FT, build 9) But, it is great tool for testing, I like it more and more :) If could be as replacement for MT, i would like to change it for this :)
The Market can stay irrational longer than you can stay solvent

User avatar
frank_horrigan
Posts: 7
Joined: Sat Jan 16, 2010 7:59 am
Location: Pribram, Czech Rep.

#16 Postby frank_horrigan » Mon Jan 18, 2010 5:57 pm

Terranin wrote: instead of reusing existing indicator on each start it will create new one, and you will get lots of indicators that will slow your testing.


Yes, my next question: Is any way to force the existing indicators, when I stop testing, destruct themselves WHEN i start NEW test (not when I stop the test) - sorry for my repeated representations of MT and MQL, but I don't know anything else ATS developing language - the MT creates new testing window always when new test was stopped and begin new one, which one instance of indicators
The Market can stay irrational longer than you can stay solvent


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 18 guests