Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to check Account Market Position for specific instrument?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to check Account Market Position for specific instrument?

    Hi,

    I know that if I run the same strategy on say, 4 different ES charts (ie. 2-min, 5-min, 30-min, 60-min), but I want to open a position in any of those charts only when I am flat in my account, I would use PositionAccount.MarketPosition == MarketPosition.Flat before entering a position. That way, there would be no possibility of me accidentally going short ES on one chart while being long in another (and thus ending up flat altogether).

    However, what if I want to add 4 more charts with this same strategy but on a different instrument? Let's say oil (CL). Now, I would want to know, before opening a position, whether I was flat IN THAT PARTICULAR INSTRUMENT. How would I go about doing this? What would be the line of code that would query my ACCOUNT market position for a specific instrument?

    Thank you in advance! This forum is great!


    #2
    Hi Mike0405, thanks for your post.

    The PositionsAccount object will keep track of this. Its an array and will hold info on all of the instruments you have a position in:




    e.g.
    Code:
    for(int i = 0; i < PositionsAccount.Length; i++)
                    Print(PositionsAccount[i].MarketPosition);
    You can also edit the strategy so that it works upon two instruments at once, this might be more straight forward. Heres a guide on multi time frame and instrument scripts:



    Please let me know if I can assist any further.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    56 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    133 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X