Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Quad), 755 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
RollShort / RollLong Issue? #488090
01/11/24 10:53
01/11/24 10:53
Joined: Mar 2022
Posts: 17
Frankfurt am Main
B
BrainSailor Offline OP
Newbie
BrainSailor  Offline OP
Newbie
B

Joined: Mar 2022
Posts: 17
Frankfurt am Main
Hi,
I have a question maybe an issue with Zorro 2.56.

Oanda is sending yearly Rollover Fees. So my idea is to convert them to daily fees. In theory it should be very easy with a line like this:

RollShort = RollShort / 365.

When I have that in my strategy no rollover costs are calculated at all.

Transaction costs -0.60$ spr, 0.0033$ slp, -0.0000000$ rol

I did try the same with the Alice 1a script and I have the same behavior.
So I thought it is a kind of rounding issue. I set the Rollover Cost in the Assetlist to some insane value and still no calculation of the rollover cost.

What bothers me really is the following line:
RollShort = RollShort * 1.;
This is working as expected.
I am lost. Any help is appreciated.

This is the code where I do my testing with. I am using EUR/USD for the tests and the latest Oanda instrument values (downloaded via MT5 bridge)

// Trend Trading ///////////////////
#include <profile.c>

function run()
{
Verbose = 3;
set(LOGFILE); // log all trades

StartDate = 2013;
EndDate = 2023; // fixed simulation period

BarPeriod = 15;

RollShort = RollShort / 365.;
RollLong = RollLong / 365.;

vars Prices = series(price());
vars Trends = series(Laguerre(Prices,0.05));

Stop = 10*ATR(100);
MaxLong = MaxShort = -1;

if(valley(Trends))
enterLong();
else if(peak(Trends))
enterShort();
}

Re: RollShort / RollLong Issue? [Re: BrainSailor] #488093
01/12/24 06:53
01/12/24 06:53
Joined: Sep 2017
Posts: 82
T
TipmyPip Offline
Junior Member
TipmyPip  Offline
Junior Member
T

Joined: Sep 2017
Posts: 82
Let's debug your code,

We can first print the RollOver values to see what are the values if it is daily or yearly?

Code
// Trend Trading ///////////////////
#include <profile.c>

function run()
{
    Verbose = 3;
    set(LOGFILE); // log all trades

    StartDate = 2013;
    EndDate = 2023; // fixed simulation period

    BarPeriod = 15;

    // Debug: Print original rollover values
    printf("\nOriginal RollShort: %f, RollLong: %f", RollShort, RollLong);

    // Adjusting rollover values
    RollShort = RollShort / 365.;
    RollLong = RollLong / 365.;

    // Debug: Print adjusted rollover values
    printf("\nAdjusted RollShort: %f, RollLong: %f", RollShort, RollLong);

    vars Prices = series(price());
    vars Trends = series(Laguerre(Prices,0.05));

    Stop = 10*ATR(100);
    MaxLong = MaxShort = -1;

    if(valley(Trends))
        enterLong();
    else if(peak(Trends))
        enterShort();
}


ZorroTraderGPT - https://bit.ly/3Gbsm4S
Re: RollShort / RollLong Issue? [Re: BrainSailor] #488094
01/12/24 11:25
01/12/24 11:25
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
run() is called repeatedly. RollLong and RollShort are global values associated with your asset. The more you divide it by 365, the more it approaches zero. So your script basically set them to a negligible value.

Consider using a fixed value. You can configure it in your asset list and leave it alone in your script.

Re: RollShort / RollLong Issue? [Re: BrainSailor] #488095
01/12/24 11:55
01/12/24 11:55
Joined: Mar 2022
Posts: 17
Frankfurt am Main
B
BrainSailor Offline OP
Newbie
BrainSailor  Offline OP
Newbie
B

Joined: Mar 2022
Posts: 17
Frankfurt am Main
Thanks AndrewAMD! You are absolutely right! I just did not think about the fact that the statements are called repeatedly!

In my original strategy I have a asset loop like:

while(asset(loop(Assets)))

I thought the parameters are initialized again after each asset switch. My mistake. I did not want to modify the assetlist as this can be forgotten when you are updating the list.
A simple

if (is(FIRSTRUN))

is doing the job now.
Thanks again Andrew!

Re: RollShort / RollLong Issue? [Re: AndrewAMD] #488096
01/12/24 12:48
01/12/24 12:48
Joined: Sep 2017
Posts: 82
T
TipmyPip Offline
Junior Member
TipmyPip  Offline
Junior Member
T

Joined: Sep 2017
Posts: 82
Thank you Andrew, for paying attention to details :

Code
// Trend Trading ///////////////////
#include <profile.c>

function run()
{
    Verbose = 3;
    set(LOGFILE); // log all trades

    StartDate = 2013;
    EndDate = 2023; // fixed simulation period

    BarPeriod = 15;

    if(is(INITRUN)) {
        // Debug: Print original rollover values
        printf("\n[INIT] Original RollShort: %f, RollLong: %f", RollShort, RollLong);

        // Adjusting rollover values
        RollShort = RollShort / 365.;
        RollLong = RollLong / 365.;

        // Debug: Print adjusted rollover values
        printf("\n[INIT] Adjusted RollShort: %f, RollLong: %f", RollShort, RollLong);
    }

    vars Prices = series(price());
    vars Trends = series(Laguerre(Prices,0.05));

    Stop = 10*ATR(100);
    MaxLong = MaxShort = -1;

    if(valley(Trends))
        enterLong();
    else if(peak(Trends))
        enterShort();
}


ZorroTraderGPT - https://bit.ly/3Gbsm4S

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1