Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MarketPosition.Flat

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

    MarketPosition.Flat

    Do MarketPosition.Short, MarketPosition.Long and MarketPosition.Flat have to do with the entire account that is being used to trade, or is it completely local to that one specific strategy?

    In other words, if two separate strategies are running and you want them to be exclusive - that is, Strategy A can enter a trade as long as B isn't in one, and vice versa - can I use something like this?

    Code:
    if Position.MarketPosition == MarketPosition.Flat)
    	{ EnterShort(2);  
              SetProfitTarget(CalculationMode.Ticks, 8);
              SetStopLoss(CalculationMode.Ticks, 8);  }
    I assume it's either
    A: If this strategy has not called a trade (it's flat), then go;
    or
    B: If your overall account is flat, then go;

    Which one is it?

    (I'm faintly aware of the existence of some particularly complex coding methods that can allow all strategies to access, evaluate and modify global variables (but I know absolutely nothing about such things), and if the answer to the above is A, then I'll have to go down that route , but hopefully it'll be B and I won't have to.)

    Thanks in advance.

    #2
    Originally posted by hawks67 View Post
    Do MarketPosition.Short, MarketPosition.Long and MarketPosition.Flat have to do with the entire account that is being used to trade, or is it completely local to that one specific strategy?

    In other words, if two separate strategies are running and you want them to be exclusive - that is, Strategy A can enter a trade as long as B isn't in one, and vice versa - can I use something like this?

    Code:
    if Position.MarketPosition == MarketPosition.Flat)
    	{ EnterShort(2);  
              SetProfitTarget(CalculationMode.Ticks, 8);
              SetStopLoss(CalculationMode.Ticks, 8);  }
    I assume it's either
    A: If this strategy has not called a trade (it's flat), then go;
    or
    B: If your overall account is flat, then go;

    Which one is it?

    (I'm faintly aware of the existence of some particularly complex coding methods that can allow all strategies to access, evaluate and modify global variables (but I know absolutely nothing about such things), and if the answer to the above is A, then I'll have to go down that route , but hopefully it'll be B and I won't have to.)

    Thanks in advance.
    It is "A".

    Comment


      #3
      Figures. So does anybody have any suggestions for the use of global variables, to be shared across a couple of strategies? I really can't just use one strategy here, it's gotten so clogged and complex, that it takes minutes to even load...

      Comment


        #4
        Originally posted by hawks67 View Post
        Figures. So does anybody have any suggestions for the use of global variables, to be shared across a couple of strategies? I really can't just use one strategy here, it's gotten so clogged and complex, that it takes minutes to even load...
        I'm working on things at the moment that relate to this. Currently working on a solution for this to re-establish account position more accurately. I'm using account position to do it rather then strategy position.

        Caveat to this, using unmanaged orders there seems to be a bug in that if you set Position.MarketPosition, Position.Quantity & Positon.AvgPrice to a value your orders are submitted in trace log but are not actually executed.

        Here is some code that might help you get started.
        Support for the development of custom automated trading strategies using NinjaScript.


        If
        Code:
        if (acct.Positions == null)
        then your defiantly flat.
        Last edited by happypappy; 03-30-2015, 06:20 AM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Belfortbucks, Today, 09:29 PM
        0 responses
        6 views
        0 likes
        Last Post Belfortbucks  
        Started by zstheorist, Today, 07:52 PM
        0 responses
        7 views
        0 likes
        Last Post zstheorist  
        Started by pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        151 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Started by mattbsea, Today, 05:44 PM
        0 responses
        6 views
        0 likes
        Last Post mattbsea  
        Started by RideMe, 04-07-2024, 04:54 PM
        6 responses
        33 views
        0 likes
        Last Post RideMe
        by RideMe
         
        Working...
        X