Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (vicknick, 7th_zorro), 888 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 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