Help all

Posted By: Tuguldur717

Help all - 02/20/18 08:00

Hellow all i do not understand this code. After execution "i" took 129 value. I think "i" must take value of 24. What happening to me can you explain it?

var i=0;
function run(){
Barperiod=60;
StartDate=20170201;
EndDate=20170202;
i=i+1;
printf("Result=%.f",i);
}
Posted By: Brax

Re: Help all - 02/20/18 12:17

Use this:

Code:
static var i = 0;

function run()
{
    LookBack = 0;
    BarPeriod = 60;
    StartDate = 20170201;
    EndDate = 20170201;

    i++;
    if(is(EXITRUN))
        printf("Result=%.f", i);
}



The key is "LookBack = 0;", when unspecified Zorro assumes a default value and it always execute before the lookback bars before processing the rest.
Posted By: Tuguldur717

Re: Help all - 02/20/18 12:39

WOOOW wonderful it works perfect. thank you again brax. Hahahaha
Posted By: Tuguldur717

Re: Help all - 02/20/18 12:46

Brax could i ask about zorro code further? If you do not hesitate how can i contact you directly?
Posted By: Brax

Re: Help all - 02/20/18 21:31

I don't mind helping others if i have the time and knowledge, but i'd rather prefer to keep using the forum as usual.

I suggest you reading the manual completely and learn the basics about programming and algo trading. Many of your questions are simple and can be found there.

Just try to make your questions precise and in one post per time, i am sure this way more people will be able to help you.

Hope you understand.
© 2024 lite-C Forums