Posted By: BobbyT
Lookback error? (noob alert) - 07/03/17 17:42
I have written the below ultra-simple strategy to get familiar with zorro (never mind the commented lines lines they are there for me to play with and have no impact on the issue at hand).
When I run this script it seems that both the RSI period and LookBack period are doing whatever they please and ignore their set values. Here is the output from the zorro terminal.
I don't get it. It's likely a real noob oversight but I have gone over the code a number of times and compared it to the workshop examples and for the life of me can't put my finger on what's wrong here. Any help would be greatly appreciated.
Cheers,
BobbyT
Code:
function CheckRSI() { TimeFrame = 1; //multiplier for BarPeriod, set BarPeriod = 1 then set TimeFrame = x for different timeframes of the same function vars Close = series(priceClose()); //sets up a price series based on the current asset/TimeFrame (used for indi) //vars RSIsignal = series(RSI(Close, optimize(14,2,34,2))); vars RSIsignal = series(RSI(Close, 14)); //create the indicator series (period can be optimised later) //var RSIthreshHigh = optimize(75,55,100,5); var RSIthreshHigh = 75; //set an upper threshold (can be optimised later) //var RSIthreshLow = optimize(25,0,45,5); var RSIthreshLow = 25; //set an lower threshold (can be optimised later) //trade decision if(crossOver(RSIsignal, RSIthreshLow)) reverseShort(1); //close short trades and open a long position if(crossUnder(RSIsignal, RSIthreshHigh)) reverseLong(1); //close long trades and open a short position } //~equivalent to MQL4 OnTick() function run() { //set(PARAMETERS); // generate and use optimized parameters BarPeriod = 60; LookBack = 34; //set to the worst case scenario, RSI period is 14 so this is easy for now StartDate = 2010; EndDate = 2015; //NumWFOCycles = 10; // activate WFO //carry out trade decisions/operations CheckRSI(); //plot the results set(LOGFILE); //PlotWidth = 600; //PlotHeight1 = 300; plot("Signal",series(RSI(series(priceClose()), 14)),NEW,RED); plot("Threshold1",75,0,BLACK); plot("Threshold2",25,0,BLACK); set(PLOTNOW); }
When I run this script it seems that both the RSI period and LookBack period are doing whatever they please and ignore their set values. Here is the output from the zorro terminal.
Code:
basketWorkup compiling.......... Lookback set to 55 bars Test: basketWorkup AUD/CAD 2010..2015 Error 014: Function RSI Timeperiod 54 > LookBack 34! Error 014: Function RSI Timeperiod 54 > LookBack 34! Error 030 - Check lookback, settings, asset order Chart...Error 047: No bars to plot! ok
I don't get it. It's likely a real noob oversight but I have gone over the code a number of times and compared it to the workshop examples and for the life of me can't put my finger on what's wrong here. Any help would be greatly appreciated.
Cheers,
BobbyT