Automated strategy (with EMA and RSI crossovers) not running at all

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #87539 quote
    crusaderzcrusaderz
    Participant
    New

    Hi,

     

    This is my first post ever and I am a total noob on PRT/PRC so hopefully you’ll forgive me any faux pass.

     

    I have spent last couple hours trying to build an automated strategy suing assisted creation in PRT (demo account).

    I am trying to open longs when:

    • current price is above 20 period EMA,
    • 5 EMA crosses over 20 EMA
    • recent 5 period RSI is above previous 5 RSI
    • 5 RSI is above 14 RSI
    • current price is above previous price

    and

     

    I am trying to open shorts when:

    • current price is below 20 period EMA,
    • 5 EMA crosses under 20 EMA
    • recent 5 period RSI is below previous 5 RSI
    • 5 RSI is below 14 RSI
    • current price is below previous price

    I’ts pretty much reverse.

     

    Closing of longs and shorts happens when some of the above conditions cease to exist.

     

    When I am trying to run the strategy (Gsys) backtesting the results, the window loads and it seems like it’s running, equity curve window opens, but there are no results. It’s basically “N/A” everywhere.

    As if nothing has been triggered.

    it’s the same when I try to run the same strategy on live data (in demo) – in normal trading.

     

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    // The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the "FLATBEFORE" time.
    DEFPARAM FLATBEFORE = 063000
    // Cancel all pending orders and close all positions at the "FLATAFTER" time
    DEFPARAM FLATAFTER = 211500
    
    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 064000
    timeEnterBefore = time >= noEntryBeforeTime
    
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 203000
    timeEnterAfter = time < noEntryAfterTime
    
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    // Conditions to enter long positions
    c1 = (close > close[1])
    indicator1 = ExponentialAverage[5](close)
    c2 = (close CROSSES OVER indicator1)
    indicator2 = RSI[5](RSI[14](close))
    indicator3 = RSI[14](close)
    c3 = (indicator2 CROSSES OVER indicator3)
    indicator4 = RSI[5](RSI[14](close))
    indicator5 = RSI[5](RSI[14](close))
    c4 = (indicator4 > indicator5[1])
    indicator6 = ExponentialAverage[5](close)
    indicator7 = ExponentialAverage[20](close)
    c5 = (indicator6 CROSSES OVER indicator7)
    indicator8 = Average[100](close)
    c6 = (close > indicator8[1])
    indicator9 = SAR[0.02,0.02,0.2]
    c7 = (indicator9[2] > close[2])
    indicator10 = SAR[0.02,0.02,0.2]
    c8 = (indicator10[1] < close[1])
    indicator11 = SAR[0.02,0.02,0.2]
    c9 = (indicator11 < close)
    
    IF (c1 AND c2 AND c3 AND c4 AND c5 AND c6 AND c7 AND c8 AND c9) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
    BUY 25 SHARES AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    c10 = (close[1] < close[2])
    indicator12 = RSI[5](RSI[14](close))
    indicator13 = RSI[5](RSI[14](close))
    c11 = (indicator12 < indicator13[1])
    indicator14 = RSI[5](RSI[14](close))
    indicator15 = RSI[14](close)
    c12 = (indicator14[1] CROSSES UNDER indicator15[1])
    indicator16 = ExponentialAverage[5](close)
    indicator17 = ExponentialAverage[5](close)
    c13 = (indicator16[1] < indicator17[2])
    c14 = (close < close[1])
    
    IF c10 AND c11 AND c12 AND c13 AND c14 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    c15 = (close < close[1])
    indicator18 = ExponentialAverage[20](close)
    c16 = (close CROSSES UNDER indicator18)
    indicator19 = ExponentialAverage[5](close)
    indicator20 = ExponentialAverage[20](close)
    c17 = (indicator19[1] CROSSES UNDER indicator20[1])
    indicator21 = RSI[5](RSI[14](close))
    indicator22 = RSI[14](close)
    c18 = (indicator21[1] CROSSES UNDER indicator22[1])
    indicator23 = RSI[5](RSI[14](close))
    indicator24 = RSI[5](RSI[14](close))
    c19 = (indicator23 < indicator24[1])
    
    IF (c15 AND c16 AND c17 AND c18 AND c19) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
    SELLSHORT 25 SHARES AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator25 = RSI[5](RSI[14](close))
    indicator26 = RSI[14](close)
    c20 = (indicator25 CROSSES OVER indicator26)
    indicator27 = RSI[5](RSI[14](close))
    indicator28 = RSI[5](RSI[14](close))
    c21 = (indicator27 > indicator28[1])
    c22 = (close > close[1])
    indicator29 = ExponentialAverage[20](close)
    c23 = (close CROSSES OVER indicator29)
    
    IF c20 AND c21 AND c22 AND c23 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pLOSS 20 pTRAILING 20
    SET TARGET pPROFIT 40
    
    Gsys-long.png Gsys-long.png Gsys-Short.png Gsys-Short.png G-sys.png G-sys.png Backtesting-report.png Backtesting-report.png
    #87545 quote
    GraHalGraHal
    Participant
    Legend

    It’s due to the numerous Crosses over and under.  I’ve just had your code executing trades by replacing crosses over by > and crosses under by <.

    I would leave at least one crosses over and one crosses under.

    It is not often that 3 x crosses over or 3 x crosses under will occur in one bar?

    Crus.jpg Crus.jpg
    #87550 quote
    NicolasNicolas
    Keymaster
    Legend

    GraHal is right, you are trying to catch simultaneous crossover/under of 3 different periods RSI on the same bar, it will almost never happen.

Viewing 3 posts - 1 through 3 (of 3 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

Automated strategy (with EMA and RSI crossovers) not running at all


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
crusaderz @crusaderz Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/20/2018
Status: Active
Attachments: 5 files
ProRealCode ProRealCode
Loading...