Hi everyone, I wish to create a probacktest to buy on a bullish signal given on the daily timeframe if it is delivered subsequently to a bullish signal given on the weekly timeframe. I would lie to add to the position if further buy signals are given on the daily so that I compound the entries. A full or partial exit would be if a bearish signal is delivered on the daily timeframe.
Not interested in entering short on and markets so the probacktest is only for long positions.
I thank you in anticipation of any help given.
This is the indicator created with the following variables added:
Variables:
MyUpperLevel Integer 70
MyLowerLevel Integer 30
myPeriod Integer 14
// current RSI
myRSI = RSI[myPeriod](close)
// variables we will store between bars
ONCE myLastHighPrice = 0
ONCE myLastLowPrice = 1000
ONCE myLastRSIPeakVal = 1000
ONCE myLastRSITroughVal = 0
// set the output default values
myRSIBullCol = -1
myRSIBearCol = -1
myRSIBullDiv = 1
myRSIBearDiv = -1
// check for peak
// *
// * *
// 2 1 0
IF (myRSI < myRSI[1]) AND (myRSI[2] < myRSI[1]) THEN
IF myRSI[1] >= myUpperLevel THEN
// great we have a peak above our level lets see if its lower than the prior peak
IF myRSI[1] < myLastRSIPeakVal THEN
//ok were lower than the last peak lets check if price was moving up
IF High > myLastHighPrice THEN
// we have a bearish divergence change the bar colour
myRSIBearCol = 1
ENDIF
ENDIF
// we need to remember this peak
myLastRSIPeakVal = myRSI[1]
// update the last high price
myLasthighPrice = High
ENDIF
ENDIF
// check for trough
// 2 1 0
// * *
// *
IF (myRSI > myRSI[1]) AND (myRSI[2] > myRSI[1]) THEN
IF myRSI[1] <= myLowerLevel THEN
// great we have a peak below our level lets see if its higher than the prior peak
IF myRSI[1] > myLastRSITroughVal THEN
//ok were lower than the last peak lets check if price was moving up
IF Low < myLastLowPrice THEN
// we have a bearish divergence change the bar colour
myRSIBullCol = 1
ENDIF
ENDIF
// we need to remember this trough
myLastRSITroughVal = myRSI[1]
// update the last low
myLastLowPrice = Low
ENDIF
ENDIF
// finally output the signals
RETURN myRSIBearDiv COLOURED BY myRSIBearCol AS “Bearish Divergence Signal”, myRSIBullDiv COLOURED BY myRSIBullCol AS “Bullish Divergence Signal”