As in the previous posts, I start by making sure that the indicator is printing values that I expect.
1) The code for the below picture is:
Code: Select all
inputs: pairslen(5);
var: spread(0), pairs(0);
//Spread calculation
spread = close data1 - close data2;
//Pairs calculation
pairs = RSI(spread, pairslen);
//Plots
plot1(pairs, "pairs", blue);
2) Then, because I want to apply a strategy on data2 (in this case ES), I make a new workspace with data2 now becoming data1, and then reloading the previous data1 as data2, and the previous data2 as data3.
The code I used for this workspace is:
Code: Select all
inputs: pairslen(5);
var: spread(0), pairs(0);
//Spread calculation
spread = close data2 - close data3;
//Pairs calculation
pairs = RSI(spread, pairslen);
//Plots
plot1(pairs, "pairs", blue);
3)After confirming that both workspaces are printing the same values for the respective studies, I now try to apply the below code on the first workspace:
Code: Select all
inputs: pairslen(5), overbought(20), oversold(60);
var: spread(0), pairs(0);
//Spread calculation
spread = close data1 - close data2;
//Pairs calculation
pairs = RSI(spread, pairslen);
//Strategy
//Long Entry + Exit Logic
if pairs crosses above overbought then buy this bar on close;
if pairs crosses above oversold then sell this bar on close;
//Short Entry + Exit Logic
if pairs crosses below oversold then sellshort this bar on close;
if pairs crosses below overbought then buytocover this bar on close;
The results for this code are displayed in this image:
4) Now, here's where the issue that stems from the question that started this whole thread arises (or at least I think this is the same issue). When I try to apply similar code to the second workspace, I now get different results (consistent with results that would happen if I didn't change the base study drop down box).
The code that I used for the second workspace is the same as the previous, except spread is now, spread = close data2 - close data3.
Code: Select all
inputs: pairslen(5), overbought(20), oversold(60);
var: spread(0), pairs(0);
//Spread calculation
spread = close data2 - close data3;
//Pairs calculation
pairs = RSI(spread, pairslen);
//Strategy
//Long Entry + Exit Logic
if pairs crosses above overbought then buy this bar on close;
if pairs crosses above oversold then sell this bar on close;
//Short Entry + Exit Logic
if pairs crosses below oversold then sellshort this bar on close;
if pairs crosses below overbought then buytocover this bar on close;
5) Finally, to confirm that the positions aren't aligning, I set the signal to allow for multiple positions.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
The above is the workflow I used to try to explain the issue that I think is related to my original question/problem.
I believe that now my question is; how can I change the signal/strategy in a similar way that I did with the indicator/study? Is there a button or field similar to the previous post, but specifically for signals? Or, do I need to force N/A values in the code? If so, how would I do that?