|
Re: Multicurrency Currency Strength
[Re: Grant]
#486619
09/10/22 16:30
09/10/22 16:30
|
Joined: Sep 2022
Posts: 13
JJ95
OP
Newbie
|
OP
Newbie
Joined: Sep 2022
Posts: 13
|
Hello,
Thank you so much for your reply! The links were very insightful.
I did notice in the links stating to have a look over the source code if needed. As I was looking over it, I noticed the following:
#define MAXCURRENCIES 32 var CStren[MAXCURRENCIES],CStrenSum[MAXCURRENCIES]; int CNum[MAXCURRENCIES]; char CNames[MAXCURRENCIES*4]; int NumCurrencies = 0;
Max Currencies is defined at 32.
My question is:
Why is it 32 (why did they choose this number specifically)?
In my case for instance, I am interested in trading the following currencies EUR, USD, AUD, CHF, NZD, GBP, JPY (which makes up around 28 currency pair). Am I suppose to change that number?
Once again, thank you so much for your reply earlier, it was very helpful!
|
|
|
Re: Multicurrency Currency Strength
[Re: JJ95]
#486623
09/10/22 17:16
09/10/22 17:16
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
I guess (but I don't know for sure) that 32 was chosen due to the 32-bit architecture of Zorro, although they made a transition to 64-bit lately. edit: see Andrew's answer above. Anyhow, 28 pairs is no problem. Just throw them in a loop. See https://zorro-project.com/manual/en/loop.htm for code examples.
Last edited by Grant; 09/10/22 17:18.
|
|
|
Re: Multicurrency Currency Strength
[Re: JJ95]
#486629
09/11/22 21:46
09/11/22 21:46
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
|
|
|
Re: Multicurrency Currency Strength
[Re: Grant]
#486631
09/12/22 15:14
09/12/22 15:14
|
Joined: Sep 2022
Posts: 13
JJ95
OP
Newbie
|
OP
Newbie
Joined: Sep 2022
Posts: 13
|
Hello, I have a small question to ask: Below is a simple code I wrote:
CODE:
function main() { for(int i=0; i<10; i++){ printf("%d\n", i); } }
When I run the code above, I get: "Error in line 4: syntax error". I cannot find this syntax error
However, when I run the code below, I do not get an error:
function main() { int i; for(i=0; i<10; i++){ printf("%d\n", i); } }
To my knowledge both codes are the same. I am studying the ccyReset() in the indicator source code file and they have it written as the first code written above. Can you please explain to me where is my syntax error?
Last edited by JJ95; 09/12/22 15:14. Reason: Spelling Mistake
|
|
|
Re: Multicurrency Currency Strength
[Re: AndrewAMD]
#486633
09/12/22 15:33
09/12/22 15:33
|
Joined: Sep 2022
Posts: 13
JJ95
OP
Newbie
|
OP
Newbie
Joined: Sep 2022
Posts: 13
|
Hello, Thank you so much for your earliest reply. Just out of curiosity, in the manual ( https://zorro-project.com/manual/en/tutorial_var.htm), it mentions that we can switch from Lite-C to C++. Quote: "Zorro gives you the choice to develop strategy scripts either in lite-C, a 'lightweight' version of the C programming language, or in 'full grown' C++" Do you know how to switch?
|
|
|
Re: Multicurrency Currency Strength
[Re: JJ95]
#486634
09/12/22 15:43
09/12/22 15:43
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
|
|
|
Re: Multicurrency Currency Strength
[Re: JJ95]
#486677
09/16/22 16:06
09/16/22 16:06
|
Joined: Sep 2022
Posts: 13
JJ95
OP
Newbie
|
OP
Newbie
Joined: Sep 2022
Posts: 13
|
Hello, Understood. I am trying to better understand C through learning the indicators source codes and applying them in my scripts. I grabbed a little of tips as I progress. Regarding the assigning an index to a currency name. I can almost see the loop and the logic, yet it remains slightly unclear. Code:
#define MAXCURRENCIES 32
var CStren[MAXCURRENCIES],CStrenSum[MAXCURRENCIES];
int CNum[MAXCURRENCIES];
char CNames[MAXCURRENCIES*4];
int NumCurrencies = 0;
// assign an index to a currency name
int ccyIdx(char* name)
{
char Ccy[4];
memcpy(Ccy,name,4);
Ccy[3] = 0;
for(int n=0; n<MAXCURRENCIES; n++) {
if(!CNames[n*4]) { // not yet stored
strcpy(CNames+n*4,Ccy);
NumCurrencies++;
return n;
}
if(strstr(CNames+n*4,Ccy))
return n;
}
return 0;
}
I do not understand the !CNames[n*4] part. The ! stands for not. I cannot see or understand the logic. How do we know if it is stored or not. The way I am reading it at first is, if (CNames[0] is not, then copy the string from Ccy to CNames with a 0 etc) But what is the logic and where is it written. If the first element in the CName array is not what exactly? Thank you so much for the help
|
|
|
Re: Multicurrency Currency Strength
[Re: JJ95]
#486692
09/18/22 17:08
09/18/22 17:08
|
Joined: Aug 2022
Posts: 65
alun
Junior Member
|
Junior Member
Joined: Aug 2022
Posts: 65
|
Think of this value in memory (0 is literal zero not the character for 0)
CNames = "EUR0USD0GBP00000"
n = 3 i = 3*4 = 12
CNames[12] == 0 <- true !CNames[12] is !0 which is true as well
Last edited by alun; 09/18/22 17:10.
|
|
|
Re: Multicurrency Currency Strength
[Re: JJ95]
#486727
09/22/22 17:22
09/22/22 17:22
|
Joined: Sep 2022
Posts: 13
JJ95
OP
Newbie
|
OP
Newbie
Joined: Sep 2022
Posts: 13
|
I see what you are saying. I would like to ask a question reagarding the ccyIdx function found in the indicator source code: char CNames[128]; // MAXCURRENCIES * 4 int NumCurrencies = 0; char* CURRENCY_NAME = "EUR";
ccyIdx(CURRENCY_NAME )
If we placed the function in a live example: Inside the parenthesis, we are expecting to pass only 1 currency name. If we pass a currency such as EUR, the function will add EUR0 to CNames, then add 1 to NumCurrencies. If we wanted to add another currency, we will have to call the function again and pass another currency. Am I correct? Thank you so much for your earliest replies
|
|
|
Re: Multicurrency Currency Strength
[Re: JJ95]
#486728
09/22/22 18:10
09/22/22 18:10
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
Let me refer you to the documentation: https://zorro-project.com/manual/en/ccy.htmNotice that ccyIdx() is not documented. This is intentional. The script writer is not supposed to access it, since it is a helper function designed for the documented functions to use from Zorro's backend. Really, the source code for ccyIdx is for your reference only. It's already compiled. Scroll down to the bottom of the page to see an excellent example of how to use the currency strength functions from the script-side. It loops through your forex assets (pairs like "EUR/USD"), and it generates strength values for all currencies (like "USD" or "EUR"). Then it selects a strongest and weakest pair based on those values. Then it goes long on the strongest pair and short on the weakest pair, given a minimum strength threshold value is crossed.
|
|
|
Re: Multicurrency Currency Strength
[Re: JJ95]
#486735
09/26/22 14:52
09/26/22 14:52
|
Joined: Sep 2022
Posts: 13
JJ95
OP
Newbie
|
OP
Newbie
Joined: Sep 2022
Posts: 13
|
Hello, I need a small explanation regarding adding strength to currency and subtracting it from counter currency.
void ccySet(var Strength)
{
if(!isForex(g->asset)) return;
int n = ccyIdx(g->asset->sName);
CStrenSum[n] += Strength;
CNum[n]++;
CStren[n] = CStrenSum[n]/CNum[n];
g->asset->vStrength = CStren[n];
n = ccyIdx(g->asset->sName+4); // counter currency
CStrenSum[n] -= Strength;
CNum[n]++;
CStren[n] = CStrenSum[n]/CNum[n];
g->asset->vStrength -= CStren[n];
}
Regarding the function isForex(). I am assuming it is checking if what is inside the parenthesis is a forex or not. However, I was unable to find it in the trading manual. Can I please receive an explanation about it or reference to it (link) that explains it's process? Also, I would like to ask about the arrow (->) and how it works in Zorro. For instance, g->asset. To my knowledge we use arrow with pointers, correct? So, g is a pointer to a struct. But that has not been defined, correct? So, how is it operating then? Thank you for your responses
|
|
|
|