Trade does not always run in backtest

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38240 quote
    EBEB
    Participant
    Senior

    Hi,

    I am struggling with a code for some time. It seems to work for some cases, but strange enough not all of the times during the backtest.

    I am trying to code the following:

    c1 = Moving average 20 > Moving average 50

    c2 = Stochastic close [1] < 21 and stochastic close [0] >= 21

    c3 = abs(bollingerup close[0] – abs(bollowingerdown close[0])>1

    the combination of c1, c2 and c3 is reguired to buy a contract. Attached a screenshot of the graph with a example where I should expect a trade opening and a screenshot of the code.

    As a test I changed c1, c2 and c3 variables and each time the result shows different results, so apparently all conditions seems to work.

    Could please somebody  take a look and see what I am doing wrong? Why does it generate trades, but not for all the situations, when c1, c2 and c3 are valid?

    Thank you!

    attachment.docx
    #38251 quote
    EBEB
    Participant
    Senior
    c1 = (Average[20](close[0]) > Average[50](close[0]))
    c2 = (Stochastic[5,3](close[1]) < 21 and Stochastic[5,3](close[0])>= 21)
    c3= abs(BollingerUp[20](close[0]) - BollingerDown[20](close[0]))> 1
    
    IF (c1 and c2 and c3) THEN
    BUY 1 CONTRACT AT MARKET
    SET STOP LOSS 0.7
    SET TARGET PROFIT 1.0
    
    ENDIF
    #38259 quote
    NicolasNicolas
    Keymaster
    Legend

    You can GRAPH your 3 conditions on the chart while doing your backtest, this is how you should debug your problem:

    c1 = (Average[20](close[0]) > Average[50](close[0]))
    c2 = (Stochastic[5,3](close[1]) < 21 and Stochastic[5,3](close[0])>= 21)
    c3= abs(BollingerUp[20](close[0]) - BollingerDown[20](close[0]))> 1
    
    IF (c1 and c2 and c3) THEN
    BUY 1 CONTRACT AT MARKET
    SET STOP LOSS 0.7
    SET TARGET PROFIT 1.0
    ENDIF
    
    signal = c1 and c2 and c3
    
    graph signal

    You’ll be able to compare what you expect as a signal and the one your code is actually returning.

    EB thanked this post
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

Trade does not always run in backtest


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
EB @eb Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/13/2017
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...