Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,173 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Instrument specific indicators? #428420
08/27/13 10:00
08/27/13 10:00
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
Hi, I am new to Zorro and find it to be very impressive! I create strategies for trading currencies, using 8 major pairs.

I create my own indicator, called "SSI", which I is constructed from all currency pairs and is not generic: the pairs to use and formula for each have to be hard coded. So far, I am unsure how to create indicators that require specific currency pairs or how to call them, as Zorro appears to create generic indicators.

1) How do I create an indicator that uses each of 8 currency pairs, but is individual to each of these pairs?
For example, in Python I have been using:

dict={"EUR/USD", "EUR/CHF", etc}
for currency in dict:
dataframe["SSI_"+str(currency)] = my calculation based on currency

Then, later I loop through the currency dictionary and inspect the value of SSI in the main trading portion.

2) If one could do this, how would one refer to the specific currency of interest with respect to the indicator? Meaning, if I have a EUR/USD strategy, how could I insist on using "SSI_EUR/USD" as in the Python example? It would be fine to have individual strategies created for each of the 8 pairs, but I am unclear how to refer to the appropriate variable.

Thanks for any help you can provide. I am quite sure this is possible, and for my strategies there are other variables that are generic that have to be optimized per currency pair, so solving this is a necessary first step.

Best, /CL

Re: Instrument specific indicators? [Re: CL1] #428421
08/27/13 10:14
08/27/13 10:14
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Welcome to Zorro. The simplest way is to check the currency inside the indicator. For instance:

Code:
if(Asset == "EUR/USD") {
  ...
} else if(Asset == "EUR/CHF") {
  ...
} etc.


Re: Instrument specific indicators? [Re: jcl] #428424
08/27/13 10:41
08/27/13 10:41
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
Hi jcl,

Thanks for the quick reply! That answers my second question. To make each individual SSI indicator (ie. "SSI_EUR/CHF"), how do I refer to the other 7 pairs in indicator.c?

In short, can one pass 8 sets of prices to indicators.c?

Thanks,
/CL

Re: Instrument specific indicators? [Re: CL1] #428429
08/27/13 11:06
08/27/13 11:06
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Better do not add it to indicators.c. This is a standard include file, so at the next Zorro update your changes will be gone. Use your own include file for your indicators, or just put them into your main script.

For passing many different asset prices to an indicator, use the "loop" function. It is explained in workshop 5.


Re: Instrument specific indicators? [Re: jcl] #429104
09/09/13 06:46
09/09/13 06:46
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
Hi, thanks but this doesn't give the desired effect. A toy example where I want to return a series that is the average price of EUR/USD and GBP/USD:

var ind1(var* Data) {
var temp_EURUSD;
var temp_GBPUSD;
if(Asset == "EUR/USD") {
temp_EURUSD=Data[0];
} else if(Asset == "GBP/USD") {
temp_GBPUSD=Data[0];
}
return (temp_EURUSD+temp_GBPUSD)/2; }

function run() {
set(PLOTPRICE+PLOTNOW);
PlotBars = 10000;
var* Price = series(price());

while(asset(loop("EUR/USD","GBP/USD"))) {
vars s1=series(ind1(Price));
plot("s1",s1[0],NEW,BLUE); }
}

Here I get a plot of the second currency chosen (GBP/USD) and this currency divided by 2 in the plot. So the second currency is not passed, presumably because each currency in the loop is executed individually?

How can I get this kind of indicator to work? Thanks!

Re: Instrument specific indicators? [Re: CL1] #429133
09/09/13 12:04
09/09/13 12:04
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes. You must declare the variables static, otherwise they have no content at the begin of the function.

static var temp_EURUSD;
static var temp_GBPUSD;

Re: Instrument specific indicators? [Re: jcl] #429137
09/09/13 12:31
09/09/13 12:31
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
I made the change.

Now I get the price graph of the last pair in the function (GBP/USD), and the function output plot gives the price of the last pair in the "while" loop. Since it is not the average, or half of the price of the last pair, can one conclude that each loop in the function takes only a single pair at a time (and thus plots the last pair in the "while" loop)?

Maybe I am missing something?

Re: Instrument specific indicators? [Re: CL1] #429151
09/09/13 13:19
09/09/13 13:19
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes, the price is also set up at a wrong place - you must first call asset before you can get its price. Anything asset-dependent must be inside the loop and not outside.

Re: Instrument specific indicators? [Re: jcl] #429152
09/09/13 13:30
09/09/13 13:30
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
Now it works!

Thanks!!

Re: Instrument specific indicators? [Re: CL1] #429994
09/21/13 21:03
09/21/13 21:03
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
Hi, 2 questions related to this:

1) How does one plot the equity curves, etc. for ALL trades across all pairs? Now it seems like the pair indicated in the Zorro GUI determines which price plot, equity, etc. are displayed. It would be much more useful to have a plot of overall equity.

2) My pairs have an variable that will differ in optimized value between them. Instead of running an optimization many times with one pair being optimized, is it possible to have multiple variables (for each pair) and optimize all at the same time? In short, can 10 variables be optimized simultaneously, if they are all independent? Zorro documentation points to optimizing one after another, which would take substantially longer.

Thanks

Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1