Gamestudio Links
Zorro Links
Newest Posts
Why Zorro supports up to 72 cores?
by 11honza11. 04/26/24 08:55
M1 Oversampling
by 11honza11. 04/26/24 08:32
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (VoroneTZ, Quad, EternallyCurious, 1 invisible), 828 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 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