Since you did not claim to have made any attempt to work this out on your own I will assume you don’t care to know how this works. But if you do, just let me know if the comments area below and I will explain how this code works.
You have one input, xDays. There are four scan signals at the very bottom of the code. As per usual, you will select which signal to run by moving the “#” symbol in front of the ‘plot scan’ statements.
input xDays = 2;
def ppsBuy = PPS().BuySignal;
def ppsSell = PPS().SellSignal;
def buy = !IsNaN(ppsBuy);
def sell = !IsNaN(ppsSell);
def pmcDiff = PMC().Diff;
def pmcMA = PMC().DiffMA;
def lightBlue = pmcDiff > 0 and pmcDiff > pmcMA;
def darkBlue = pmcDiff > 0 and pmcDiff < pmcMA;
def red = pmcDiff < 0 and pmcDiff < pmcMA;
def magenta = pmcDiff < 0 and pmcDiff > pmcMA;
def confirmDaysBullish = (Sum(lightBlue, xDays) + Sum(magenta, xDays)) >= xDays;
def confirmDaysBearish = (Sum(red, xDays) + Sum(darkBlue, xDays)) >= xDays;
def confirmedBuy = buy and confirmDaysBullish;
def confirmedSell = sell and confirmDaysBearish;
def buyWithReversal = magenta[1] and lightBlue and Highest(buy, xDays) > 0;
def sellWithReversal = lightBlue[1] and red and Highest(sell, xDays) > 0;
# use this to scan for PPS buy signals that follow bullish PMC
plot scan = confirmedBuy;
# use this to scan for PPS sell signals that follow bearish PMC
#plot scan = confirmedSell;
# use this to scan for bullish PMC reversals that follow a PPS buy
#plot scan = buyWithReversal;
# use this to scan for bearish PMC reversals that follow a PPS sell
#plot scan = sellWithReversal;
Hello Pete, Installing this as a watchlist column seems to be working for a friend but the same script on my computer produces results that are 90% NaN and a few zero’s.
1. should the script be used as is for a watchlist column as we’ve tried to do?
2. your thoughts on why we would get different results using the (checked and crosschecked) identical script?
Thanks!
Doug
I tested this in a watchlist column on mine and I get all NaN with a few zeros. I tried different time frames, different signals. Then I tried using OnDemand. None of those variables changed the behavior.
I can tell you from experience I have seen this before. It happens when one or more lines in the code is assigning a value or Double.NaN to a signal or a signal’s components. The correction is to modify the code to remove the Double.NaN assignment and opt for a True/False assignment in it’s place. However this is a licensed study and we have no way of modifying the source code.
You can see that in the very first lines of code I have to check if the signal coming from PPS code is NaN:
def buy = !IsNaN(ppsBuy);
def sell = !IsNaN(ppsSell);
This is not the cause of the problem, but rather a symptom. This was required because that’s the way the signals are being delivered from the PPS study itself.
Why is it working on someone else’s computer? I suspect it is not. I would suspect any values on that other computer are incorrect. Not saying they are. Just saying I would not trust them until they are verified as being correct.