Gamestudio Links
Zorro Links
Newest Posts
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, VoroneTZ, 1 invisible), 1,578 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
First Tick in bar #480573
06/17/20 04:36
06/17/20 04:36
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Hi,

do you know how detect the incoming tick is the first tick of a new bar?

something like:

if (is(firstTickofBar))....


Thanks

Re: First Tick in bar [Re: Grat] #480574
06/17/20 04:51
06/17/20 04:51
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
safe variant:
Code
bool lFirstTick=false;
int nOldBar=-1;
function tick(){
    if (lFirstTick)
        printf("\nBar %i of %i last is %i",Bar,NumBars,EndBar);
    lFirstTick=false;
}

function run()
{
    BarPeriod = 1;
    LookBack = 1;
    if (is(INITRUN))
    {
        set(TICKS);
        lFirstTick=false;
        nOldBar=Bar;
    }

    if (Bar > nOldBar){
        nOldBar=Bar;
        lFirstTick=true;
    }
}


Re: First Tick in bar [Re: Grat] #480575
06/17/20 04:53
06/17/20 04:53
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
better - zorro call fce run once bar
Code

bool lFirstTick=false;
function tick(){
    if (lFirstTick)
        printf("\nBar %i of %i last is %i",Bar,NumBars,EndBar);
    lFirstTick=false;
}

function run()
{
    BarPeriod = 1;
    LookBack = 1;
    if (is(INITRUN))
    {
        set(TICKS);
        lFirstTick=false;
    }

    lFirstTick=true;
}

Re: First Tick in bar [Re: Grat] #480576
06/17/20 04:57
06/17/20 04:57
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
this excecute first 3 ticks

Code
bool lFirstTick=false;
int nTry=0;
function tick(){
    if (lFirstTick && nTry > 0){
        printf("\nBar %i of %i last is %i/%i",Bar,NumBars,EndBar,nTry);
        nTry--;
    }
    if (nTry <=0)
        lFirstTick=false;
}

function run()
{
    BarPeriod = 1;
    LookBack = 1;
    if (is(INITRUN))
    {
        set(TICKS);
        lFirstTick=false;
    }

    lFirstTick=true;
    nTry=3;
}


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1