Strategy not placing trades in backtest

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #139029 quote
    steynpj
    Participant
    Average

    Not placing any trades in back testing.
    Y: long sMA
    C1 and C2 : sma turning up
    C3 and C4 : sma turning down
    X : numerical value if difference between current sma and sma 40 periods ago

    DEFPARAM FLATBEFORE = 060000
    // Cancel all pending orders and close all positions at the "FLATAFTER" time
    DEFPARAM FLATAFTER = 220000
    
    X = (average[Y,0] - average[Y,40])
    
    // Conditions to enter long positions
    indicator1 = Average[A]
    indicator2 = Average[A]
    c1 = (indicator1 > indicator2[1])
    indicator3 = Average[A]
    indicator4 = Average[A]
    c2 = (indicator3[1] < indicator4[2])
    
    IF c1 AND c2 AND X > C THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator5 = Average[A]
    indicator6 = Average[A]
    c3 = (indicator5 < indicator6[1])
    indicator7 = Average[A]
    indicator8 = Average[A]
    c4 = (indicator7[1] > indicator8[2])
    
    IF c3 AND c4 AND X < -C THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pLOSS D
    SET TARGET pPROFIT E

    Thank you

    #139032 quote
    robertogozzi
    Moderator
    Master

    What is C?

    #139033 quote
    steynpj
    Participant
    Average

    C = condition

    #139035 quote
    GraHal
    Participant
    Master

    Have you tried many Markets and many TF’s?

    #139038 quote
    robertogozzi
    Moderator
    Master

    If C=condition (say Close > close[1]) how can X be > or < ?

    #139087 quote
    Vonasi
    Moderator
    Master

    steynpj – Please give your topics more meaningful titles otherwise we end up with a forum full of ‘Help needed’ topics! I have changed your topic title. Also do not post your question/comments within the PRT code box. Only put actual code in the code insertion box. I have edited your post to tidy everything up.

    #139092 quote
    steynpj
    Participant
    Average

    My mistake.

    The capital “C”, is a variable in back testing, any numerical value.

    #139112 quote
    Dow Jones
    Participant
    Veteran

    For this line, X = (average[Y,0] average[Y,40])

    The first parameter is the average type, second parameter is the period. I’m not sure if it is expected for period 0?

    #139120 quote
    robertogozzi
    Moderator
    Master

    It’s the other way round with AVERAGE. The first parameter is the PERIODS, the second one, optional, is the average type.

    40 is not supported. Read official documentation for allowed types.

    #139122 quote
    robertogozzi
    Moderator
    Master

    Line 5 should read:

    X = (average[Y,0] - average[Y,0][40])
    steynpj thanked this post
    #139164 quote
    Nicolas
    Keymaster
    Master
    • Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’.

    Don’t worry I will change it for you! I’m so happy to do it! 🙂

    #139169 quote
    Dow Jones
    Participant
    Veteran

    Thank you, @robertogozzi for the clarification, my mistake, shame on me. Btw, just my 2 cents, I think could be easier if author just do the GRAPH on several variables to understand where is the problem. As the code is not complete and some typo, then we keep guessing.

    #139171 quote
    steynpj
    Participant
    Average

    Thank you, correct

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

Strategy not placing trades in backtest


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
steynpj @steynpj Participant
Summary

This topic contains 12 replies,
has 6 voices, and was last updated by steynpj
5 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/11/2020
Status: Active
Attachments: No files
Logo Logo
Loading...