Posted By: Smon
Using price series without actually using series - 09/16/21 19:22
I often ran into problems with wrong series usage. I'm working on a script, which needs an indicator which is calculated from a price series only when a trade is entered. This gave me the idea, to just completely skip any series usage. The solution I came up with is this:
Notice that I implemented an option to chose between different price options.
Code
var* NoSeries(int period, int mode, ...) { int i; var* Series = zalloc(period*sizeof(var)); for(i=0; i<period; i++) { if(mode == 0) Series[i] = price(i); if(mode == 1) Series[i] = priceOpen(i); if(mode == 2) Series[i] = priceHigh(i); if(mode == 3) Series[i] = priceLow(i); if(mode == 4) Series[i] = priceClose(i); } return Series; } function run() { LookBack = 100; BarPeriod = 60; asset("EUR/USD"); //if(Init) mySeries = zalloc(100*sizeof(var)); var ZorroEMA = EMA(series(price()), 30); var* test = NoSeries(70); var myEMA = EMA(test, 30); printf("\n%.5f, Zorro:%.5f", myEMA, ZorroEMA); }
Notice that I implemented an option to chose between different price options.