Position size limit per strategy

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

    Hi there,

    Sorry if this is a repeated question.

     

    i am trying to find a code to limit the number of opened positions under one strategy. For example:

    Timeframe(4hours, updateonclose)

    a = close/1.01

    Timeframe(default)

    b = close

    if b < c then

    buy 2 contracts at the Market

     

    if i were to use the above on the 1 min chart on a daily basis, how to limit the number of opened positions to 2 per day if the criteria is met.

     

    thanks

    #188735 quote
    robertogozzi
    Moderator
    Master

    There you go (not tested):

    Timeframe(default)
    ONCE Tally = 0
    IF IntraDayBarIndex = 0 THEN
       Tally = 0
    endif
    //
    Timeframe(4hours, updateonclose)
    a = close/1.01
    //
    Timeframe(default)
    b = close
    if b < c and (Tally < 2) then
       buy 2 contracts at the Market
       Tally = Tally + 1
    endif
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Position size limit per strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
abuanza @abuanza Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
3 years, 12 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/23/2022
Status: Active
Attachments: No files
Logo Logo
Loading...