create a pro backtest using a created indicator
Forums › ProRealTime English forum › ProOrder support › create a pro backtest using a created indicator
- This topic has 9 replies, 2 voices, and was last updated 2 years ago by
robertogozzi.
-
-
03/05/2022 at 8:13 AM #189374
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 = 1ENDIF
ENDIF// we need to remember this peak
myLastRSIPeakVal = myRSI[1]
// update the last high price
myLasthighPrice = HighENDIF
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 = 1ENDIF
ENDIF// we need to remember this trough
myLastRSITroughVal = myRSI[1]
// update the last low
myLastLowPrice = LowENDIF
ENDIF// finally output the signals
RETURN myRSIBearDiv COLOURED BY myRSIBearCol AS “Bearish Divergence Signal”, myRSIBullDiv COLOURED BY myRSIBullCol AS “Bullish Divergence Signal”03/08/2022 at 3:45 PM #189617Your indicator returns nothing.
Is it working on your charts? If yes, please post the ITF file.
03/08/2022 at 10:02 PM #18965903/08/2022 at 11:00 PM #189660It’s the file containing the indicator when exported from ProBuilder (part of the ProRealTime platform that manages indicators).
03/09/2022 at 12:03 PM #18967603/11/2022 at 12:08 PM #189794I modified your code, to make it return valid data. You can download and import the attached 123v2 file.
I attach the trading system file, too.
That said, well… very few signals are returned on both TFs.
This is the code (to be run on a Daily chart):
1234567891011121314151617DEFPARAM CumulateOrders = true//Timeframe(Weekly,default)//UpdateOnClose)//myPriorBullishDivergenceSignalW = myBullishDivergenceSignalWmyBearishDivergenceSignalW, myBullishDivergenceSignalW = CALL "123v2"[70, 30, 14]//Timeframe(Daily,default)myBearishDivergenceSignalD, myBullishDivergenceSignalD = CALL "123v2"[70, 30, 14]//IF myBullishDivergenceSignalW AND myBullishDivergenceSignalD THENBUY 1 CONTRACT AT MarketENDIFIF LongOnMarket AND myBearishDivergenceSignalD THENSELL AT MarketENDIF//graph myBullishDivergenceSignalW coloured(255,0,0,255)//graph myBullishDivergenceSignalD11/04/2022 at 8:35 PM #203560Hi guys
Using the following indicator is it possible to add a line of code which would restrict the use of bars to the most recent 15?
// 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 = 0
myRSIBearCol = 0
myRSIBullDiv = 0
myRSIBearDiv = 0// 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
myRSIBearDiv = -1
myRSIBullDiv = 0
ENDIF
ENDIF// we need to remember this peak
myLastRSIPeakVal = myRSI[1]
// update the last high price
myLasthighPrice = HighENDIF
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
myRSIBearDiv = 0
myRSIBullDiv = 1
ENDIF
ENDIF// we need to remember this trough
myLastRSITroughVal = myRSI[1]
// update the last low
myLastLowPrice = LowENDIF
ENDIF// finally output the signals
//RETURN myRSIBearDiv COLOURED BY myRSIBearCol AS “Bearish Divergence Signal”, myRSIBullDiv COLOURED BY myRSIBullCol AS “Bullish Divergence Signal”
RETURN myRSIBearDiv AS “Bearish Divergence Signal”, myRSIBullDiv AS “Bullish Divergence Signal”11/05/2022 at 12:26 PM #203588Please attach the ITF file or post the missing variables and their value.
11/05/2022 at 3:47 PM #20359711/16/2022 at 1:09 PM #204253Actually myPeriod restricts the use to the most recent 14 (or any other value you may want to set).
-
AuthorPosts
Find exclusive trading pro-tools on