Setting Maximum Contracts in ProBackTest

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #150919 quote
    SAMPANETTASAMPANETTA
    Participant
    New

    Hey Crew,

    I am currently running the following hourly charts however on the ProBackTest it enters into a new contract every hour even if it is already in a position.

    I want to limit the strategy to being maximum 1 contract long or short at any given time and not continue to accumulate contracts.

    My current code is below. Does anyone know how to help with this?

    Cheers, Sam

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    indicator1 = Average[120](close)
    c1 = (close >= indicator1)
    
    IF c1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator2 = Average[120](close)
    c2 = (close <= indicator2)
    
    IF c2 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pTRAILING 30
    #150929 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Always use the ā€˜Insert PRT Code’ button when putting code in your posts to make it easier for others to read. Thank you šŸ™‚

    As to your code, it’s impossible that “it enters into a new contract every hour even if it is already in a position“. To accomplish that you should replace line 2 by:

    DEFPARAM CumulateOrders = True

    So, did you already backtest it? How could you spot more than 1 position at a time?

    append this line to your code to monitor the number of positions accumulated:

    graph abs(CountOfPosition)
Viewing 2 posts - 1 through 2 (of 2 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

Setting Maximum Contracts in ProBackTest


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
SAMPANETTA @sampanetta Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
5 years, 10 months ago.

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