Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (MadJack, AndrewAMD, Quad), 540 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
avg spread every tick #481181
08/11/20 08:09
08/11/20 08:09
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,

I need calculate AVG spread - every tick. I trying this:

Code
#include <profile.c>
vars Data10 = series(0,30);
//------------------------ 
void tick(){
    
    var s= Spread;
    Data10=series(s,30);
    var aAvg=Median(Data10,30);
    print(TO_INFO,"%f",s);

}

// --------------------------- Main-----------------------------
function run()
{
    LookBack = 0;
    print(TO_WINDOW,"%f",Spread);
}



but I get this erro:

Error 041: series/loops defined outside run!
Error 111: Crash in tick: tick() at bar 1


Do you any idea, how make this?

Thanks

Re: avg spread every tick [Re: Grat] #481182
08/11/20 09:53
08/11/20 09:53
Joined: May 2020
Posts: 27
Germany
M
Morris Offline
Newbie
Morris  Offline
Newbie
M

Joined: May 2020
Posts: 27
Germany
Well, like the error message says: You should not define a series outside of run(). The idea of a series is that it is shifted automatically with every run() -- but that is not what you want here. So you want to declare your series with a negative length and manually shift your series with every tick().

This works:
Code
#include <profile.c>
vars Data10;
//------------------------ 
void tick() {
    var s = Spread;
    shift(Data10, s, 30);
    var aAvg = Median(Data10, 30);
    print(TO_INFO,"Avg=%f", aAvg);
}

// --------------------------- Main-----------------------------
function run() {
    Data10 = series(0, -30);
    LookBack = 0;
    print(TO_WINDOW,"\nSpread=%f", Spread);
}

Re: avg spread every tick [Re: Grat] #481183
08/11/20 10:34
08/11/20 10:34
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
Super, thank's


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1