Maximum Contracts

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #96841 quote
    Mike Ros
    Participant
    New

    Hello,

    when i have defparam on true, how can i during a backtest set a maxium contracts that can be open?

    In the real money mode you can set the maxium contracts at the beginning, but that is not possible in the backtest mode.

     

    thanks for support

    #96842 quote
    Vonasi
    Moderator
    Master

    You can try something like this:

    MaximumContracts = 50
    
    TooManyContracts = abs(countofposition) >= MaximumContracts
    
    If not TooManyContracts and (your conditions) then
    Buy 1 contract at market
    endif

    Not tested.

    #96843 quote
    robertogozzi
    Moderator
    Master

    You can use:

    So you can test, say, that you don’t have more than 3 contracts open:

    IF MyConditions AND COUNTOFLONGSHARES < 3 THEN   //accumulate contracts up to 3
       BUY 1 CONTRACT AT MAERKET
    ENDIF
    #96844 quote
    robertogozzi
    Moderator
    Master

    You were so fast Vonasi, I was still typing while you were posting!

    #96845 quote
    Mike Ros
    Participant
    New

    it works, many thanks

    #96846 quote
    Nicolas
    Keymaster
    Master

    I am too late 😆

    #96847 quote
    Vonasi
    Moderator
    Master

    I am too late

    You snooze you lose! I even had time to edit the title to get rid of the ‘shouty’ capitals and misspelling before you got here – you are being slowed down due to eating too many Easter eggs I think!

    #96854 quote
    GraHal
    Participant
    Master

    hahahaha … good job you 3 fast guns are here! 🙂

    #96855 quote
    Vonasi
    Moderator
    Master

    hahahaha … good job you 3 fast guns are here! 🙂

    As Sheriff of the Code Snippets Library I thought you was gonna say that you corralled it into there!

    #96858 quote
    GraHal
    Participant
    Master

    Yep … all rounded up and locked away in here

    Snippet Link Library 🙂

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

Maximum Contracts


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Mike Ros @mike_ros Participant
Summary

This topic contains 9 replies,
has 5 voices, and was last updated by GraHal
6 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/20/2019
Status: Active
Attachments: No files
Logo Logo
Loading...