Gamestudio Links
Zorro Links
Newest Posts
EXITRUN for TRADE
by jcl. 06/24/21 10:09
BarOffset for per-bar oversampling
by Sempervirens. 06/24/21 02:39
Players Health
by rayp. 06/23/21 19:04
Acknex-Configuration
by 3run. 06/21/21 16:39
What are you working on?
by rayp. 06/17/21 23:00
AUM Magazine
Latest Screens
Hecknex World
Scheherazade's Journey
Paradox Vector
The Space Between
Who's Online Now
7 registered members (x34v, AndrewAMD, Sempervirens, 3run, Quad, 2 invisible), 439 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
damasceno, peterr991, fx2201, adaptivetrader, froglog
18656 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: 389
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 389
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: 389
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 389
Czech Republic
Super, thank's


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1