Backtesting chooses entries and exits at random

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #111576 quote
    Analyst
    Participant
    New

    Hi Everyone

    I am quite new to ProRealTime. I have made a number of short programs, but am puzzled by my latest program which gives entries and exits seemingly at random. I have created the program with ‘simplified creation’ and then modified it slightly (same result without any modification as well).

    It is very simple. When two moving averages (21 and 50 period) are both moving up I want to create a buy order. When the 21 starts to move down I want to close the position. I am running the code on the US 500 Cash 5 min market. The code even enters a buy when both moving avergaes are moving down. I am very confused.

    Last point, if one creates a Hull moving average with the simplified creation, the code defaults to simple moving average. There does not seem to be a programming option for the Hull at all. I have seen other people say similar on the forums but no definitive answer to date.

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    indicator1 = Average[21](close)
    c1 = (indicator1 >= indicator1[1])//21 period average is sloping positive
    indicator2 = Average[50](close)
    c2 = (indicator2 >= indicator2[1])//50 period average is sloping positive
    
    IF c1 AND c2 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator3 = Average[21](close)
    c3 = (indicator3 < indicator3[1])//close when 21 period average is sloping negative
    
    IF c3 THEN
    SELL AT MARKET
    ENDIF
    #111588 quote
    GraHal
    Participant
    Master

    What timeframe are you running your code on?

    I ask because if a low TF (1 min, 5 min) then it may be difficult to spot the difference of say 1, 2 or a few pips on the MA’s??

    Give an example of a random entry / exit date & time and I’ll try and reproduce on my Platform.

    #111593 quote
    Analyst
    Participant
    New

    Hi GraHal

    I am using this on the 5 min chart. See attachment for trades over the last few hours. Time is CET +1.

    At 22:15 there is an entry an 1 candle later an exit. Both MA’s are moving downwards so there should not be any entry.

    Thank you

    prt-system.jpg prt-system.jpg
    #111596 quote
    Vonasi
    Moderator
    Master

    Analyst – Welcome to the forums.

    Your topic has been moved to the ProOrder forums as it is a strategy related topic rather than a general discussion. Please try to post in the correct forum with future topics. 🙂

    #111597 quote
    Vonasi
    Moderator
    Master

    What instrument are you testing on? It is not mentioned in your first post or shown in your screen shot. We cannot recreate what is happening without all the info!

    Also are you sure that the MA’s on your chart are the same as in your code? Just trying to eliminate the usual basic mistakes before delving deeper.

    Using GRAPHONPRICE to show the MA values directly from the strategy is usually a good way to avoid confusion.

    GraHal thanked this post
    #111608 quote
    Analyst
    Participant
    New

    I am doing this on the US 500 Cash (see first post). The attachment is for this market.

    #111620 quote
    GraHal
    Participant
    Master

    There you go … using GRAPH and Cursor details (as Vonasi suggested) … shows that in fact Ind1 and Ind2 are rising as per your entry code.

    Vonasi and Analyst thanked this post
    22.10.jpg 22.10.jpg 22.15.jpg 22.15.jpg 2220.jpg 2220.jpg
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Backtesting chooses entries and exits at random


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Analyst @analyst Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by GraHal
6 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/29/2019
Status: Active
Attachments: 4 files
Logo Logo
Loading...