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