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 jxs_xrj, 01-12-2020, 09:49 AM
        5 responses
        3,289 views
        1 like
        Last Post jgualdronc  
        Started by Touch-Ups, Today, 10:36 AM
        0 responses
        5 views
        0 likes
        Last Post Touch-Ups  
        Started by geddyisodin, 04-25-2024, 05:20 AM
        8 responses
        61 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Option Whisperer, Today, 09:55 AM
        0 responses
        5 views
        0 likes
        Last Post Option Whisperer  
        Started by halgo_boulder, 04-20-2024, 08:44 AM
        2 responses
        24 views
        0 likes
        Last Post halgo_boulder  
        Working...
        X