@orionsbelt,
To answer your question around signal vs. plot. plot is a reserved word for QScript which plots. (Take a look at the QScript help on it for examples.) The word signal is just something that Earik chose to act as a variable to use to track if we should be short or long. (He could have called it frankfurters if he wanted.)
signal1 and signal2 would be run on every 5-min bar. You can think about it this way, when each bar closes, signal1 and signal2 would be computed:
signal1: 1, 1,1,-1,-1,1,1,-1,etc
signal2: 1,-1,1,-1, 1,1,1,-1,etc
signal (which is just signal1+signal2): 2,0,2,-2,0,2,2,-2,etc
Which leads into your next question. You alluded to making a new function based on AMA.
The idea is that signal contains just a buy sell. So instead of returning the
contents of the moving average, you should either return +1 or -1. In other words:
Code: Select all
#returns the AMA of "price"
input: price,length,f1,f2,f3;
if (length>0)
{
avg=0;
for (i=0 to length-1 by 1)
avg+=price[i];
avg/=length;
}
else
avg=price;
if (avg> 0) {
signal=1;
}
if (avg< 0) {
signal=-1;
}
return signal;
Edit: Note, I did not really investigate what you were doing. So I have no idea if this would work or not.