Using True – cumulating positions

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #97650 quote
    AlunAlun
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    VonasiVonasi
    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
    AlunAlun
    Participant
    Average

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

    #97671 quote
    GraHalGraHal
    Participant
    Master

    Copied to here Snippet Link Library

    Another successful collaboration on the Snippet Log! 🙂

    robertogozzi thanked this post
    #136055 quote
    GraHalGraHal
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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.
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

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 robertogozzirobertogozzi
6 years, 3 months ago.

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