Using True – cumulating positions

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #97650 quote
    Alun
    Participant
    Average

    When using True to activate cumulative positions, is there a simple way to limit the number of positions to a maximum?

    #97651 quote
    robertogozzi
    Moderator
    Master

    COUNTOFPOSITION returns the number of open positions.

    COUNTOFLONGSHARES returns the number of open Long positions.

    COUNTOFSHORTSHARES returns the number of open Short positions.

    Example:

    MaxPositionsAllowed = 5
    If MyConditions And CountOfPosition < MaxPositionsAllowed Then
       Buy 1 contract at market
    Endif
    #97661 quote
    Vonasi
    Moderator
    Master

    Don’t forget that COUNTOFPOSITION is a negative value if you are short on the market and a positive value if you are long. You can use:

    abs(countofposition)

    to return only a positive value. So Roberto’s code needs to be like the following to work with  short position quantities.

    MaxPositionsAllowed = 5
    If MyConditions And abs(CountOfPosition) < MaxPositionsAllowed Then
       Sellshort 1 contract at market
    Endif
    robertogozzi thanked this post
    #97670 quote
    Alun
    Participant
    Average

    This looks very good – many thanks Roberto and Vonasi!!

    #97671 quote
    GraHal
    Participant
    Master

    Copied to here

    Snippet Link Library

    Another successful collaboration on the Snippet Log! 🙂

    robertogozzi thanked this post
    #136055 quote
    GraHal
    Participant
    Master

    z = n*3/2

    And is n*3/2 allowed as a lot size for the Instrument you are trading?

    If it were me I would concentrate on making a profit by getting the strategy correct for Long entry / exit and Short entry / exit and use Lot size = 1 for simplicity?

    After you are making consistent profit every week for months … then tweak lot size etc??

    #136058 quote
    robertogozzi
    Moderator
    Master

    Sorry @GraHal, I deleted all of his posts here because he had started another topic in the French forum.

    You may want to post your reply, in French, there https://www.prorealcode.com/topic/taille-de-position-en-fonction-de-lhoraire-de-trading/.

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

Using True – cumulating positions


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Alun @alun Participant
Summary

This topic contains 6 replies,
has 4 voices, and was last updated by robertogozzi
5 years, 8 months ago.

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