create a pro backtest using a created indicator

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #189374 quote
    LivJoJadeLivJoJade
    Participant
    Junior

    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”

    #189617 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Your indicator returns nothing.

    Is it working on your charts? If yes, please post the ITF file.

    #189659 quote
    LivJoJadeLivJoJade
    Participant
    Junior

    Please excuse my ignorance, a itf file is?

    #189660 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    It’s the file containing the indicator when exported from ProBuilder (part of the ProRealTime platform that manages indicators).

    #189676 quote
    LivJoJadeLivJoJade
    Participant
    Junior

    good morning, please find attached one itf file.

    Many thanks for your help.

    123.itf
    #189794 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    I 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):

    DEFPARAM CumulateOrders = true
    //
    Timeframe(Weekly,default)//UpdateOnClose)
    //myPriorBullishDivergenceSignalW = myBullishDivergenceSignalW
    myBearishDivergenceSignalW, myBullishDivergenceSignalW = CALL "123v2"[70, 30, 14]
    //
    Timeframe(Daily,default)
    myBearishDivergenceSignalD, myBullishDivergenceSignalD = CALL "123v2"[70, 30, 14]
    //
    IF myBullishDivergenceSignalW AND myBullishDivergenceSignalD THEN
       BUY 1 CONTRACT AT Market
    ENDIF
    IF LongOnMarket AND myBearishDivergenceSignalD THEN
       SELL AT Market
    ENDIF
    //graph myBullishDivergenceSignalW coloured(255,0,0,255)
    //graph myBullishDivergenceSignalD
    123v2.itf MySystem-2.itf
    #203560 quote
    LivJoJadeLivJoJade
    Participant
    Junior

    Hi 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 = 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
    myRSIBearDiv = 0
    myRSIBullDiv = 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”
    RETURN myRSIBearDiv AS “Bearish Divergence Signal”, myRSIBullDiv AS “Bullish Divergence Signal”

    #203588 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Please attach the ITF file or post the missing variables and their value.

    #203597 quote
    LivJoJadeLivJoJade
    Participant
    Junior

    Hi Roberto

    Please find attached 1 itf file, in addition the variables are…

    myPeriod = 14

    myUpperLevel = 70

    myLowerLevel = 30

    Many thanks for your help.

    123v2.itf
    #204253 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Actually myPeriod  restricts the use to the most recent 14 (or any other value you may want to set).

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

create a pro backtest using a created indicator


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
LivJoJade @livjojade Participant
Summary

This topic contains 9 replies,
has 2 voices, and was last updated by robertogozzirobertogozzi
3 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/05/2022
Status: Active
Attachments: 4 files
ProRealCode ProRealCode
Loading...