Combining Custom indicator + PPS in a backtest?

M

mynameisdavid67

New member
If this along with the PPS buy signal are true within 3-5 bars, on either a one or five minute time frame. Buy. If price opens and closes below the 9 SMA, sell. Only to take long positions.

Code:
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageTypeMACD = AverageType.EXPONENTIAL;

def Diff = MACD(fastLength, slowLength, MACDLength, averageTypeMACD).Diff;

input length = 7;
input price = close;
input averageType = AverageType.WILDERS;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);

def twoBarPivotMACD = Diff > Diff[1] and Diff[1] > Diff[2] and Diff[2] < Diff[3] and Diff[3] < Diff[4];

def overSoldRSI = RSI <= 30;

plot TrendReversal = twoBarPivotMACD and Highest(overSoldRSI[1], 2) > 0;
 
Last edited by a moderator:

Similar threads

Top