I'm confused about Currency and Timeframe statements...

How to create strategies and indicators
Message
Author
User avatar
Tantalus
Posts: 302
Joined: Fri Mar 23, 2007 3:51 pm
Contact:

I'm confused about Currency and Timeframe statements...

#1 Postby Tantalus » Thu Oct 25, 2007 5:57 pm

Hi, Mike.

I have been practicing writing strategies using the Delphi samples included with the program, but I'm confused about the purpose of making currency and timeframe external variables... doesn't a strategy just use the currency and timeframe of the chart it's attached to?

I see that these values are tied into other statements, particularly the SetCurrencyAndTimeframe statement, but I don't understand what this does or if it's necessary. When I try to take these statements out (ie, not specify a currency or timeframe through external variables), my strategy won't run. I also noticed that the template code generated by the StrategyBuilder program you provided on this forum does not include these statements.

The problem I'm having is that the Strategy Optimizer won't allow me to optimize my strategy to any other currency pair than the one that is listed as the default, despit the fact that I've generated tick data for other currencies.

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

Re: I'm confused about Currency and Timeframe statements...

#2 Postby Terranin » Thu Oct 25, 2007 7:38 pm

Tantalus wrote:Hi, Mike.

I have been practicing writing strategies using the Delphi samples included with the program, but I'm confused about the purpose of making currency and timeframe external variables... doesn't a strategy just use the currency and timeframe of the chart it's attached to?

I see that these values are tied into other statements, particularly the SetCurrencyAndTimeframe statement, but I don't understand what this does or if it's necessary. When I try to take these statements out (ie, not specify a currency or timeframe through external variables), my strategy won't run. I also noticed that the template code generated by the StrategyBuilder program you provided on this forum does not include these statements.

The problem I'm having is that the Strategy Optimizer won't allow me to optimize my strategy to any other currency pair than the one that is listed as the default, despit the fact that I've generated tick data for other currencies.


Unlike in MetaTrader the strategy is not linked to any currency and timeframe and can work with all of them at the same time. So if you want to work with one currency you should define which one with variable and then you can choose with options. Or you can set it in strategy with calling SetCurrencyAndTimeframe('USDJPY', PERIOD_M15) do what you need and then switch to another currency calling again SetCurrencyAndTimeframe.

Example:

SetCurrencyAndTimeFrame('USDJPY', PERIOD_M15);
// working with USDJPY on period M15
...
SetCurrencyAndTimeFrame('USDJPY', PERIOD_M1);
// working with USDJPY on period M1
...
SetCurrencyAndTimeFrame('AUDUSD', PERIOD_H1);
// working with AUDUSD on period H1
...

you can do as many calls of SetCurrencyAndTimeFrame in a single strategy as you want. But if you did not do any then currency and timeframe is not defined at all. Also you can have more than one currency variable in parameters if you want to be flexible and your strategy works with more than one currency.

Sometimes strategy optimizer after generating ticks does not know about new currencies created and does not show them in the list. Then restart the program.
Hasta la vista
Mike


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 6 guests