Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Struggling with MarketPosition... need another nudge...

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

    Struggling with MarketPosition... need another nudge...

    Hi All!!

    So I'm tooling along on the new strategy. Got a lot done so far (thanks again to all your fantastic input)... however... I'm still having a bit of a challenge getting my head around certain concepts... such as MarketPosition, and when I'm supposed to use this method and why. I find examples in the user's help guide, but I don't find the "logic and reasoning" behind why these methods would be applied.

    In my strategy, I'm using the wizard as you may already know...

    In the conditions pane, there are two different sets of entry conditions for each trade direction (long or short).

    Basically it goes like this:

    Code:
    Set 1:
    if indicatorA cross above n
    Variable0 == 1
    
    Set 2:
    if Variable0 = 1
    && IndictorB cross above n2
    && IndicatorC > X
    EnterLong
    Variable0 == 0
    
    Set 3: // Not relying on the variable for this entry.
    if indicatorB cross above n2
    && IndicatorC < X
    EnterLong
    On the short side, I'm doing the same thing only reversed, using Variable1. There are two entry sets for each direction, plus a variable for each (which only applies to the first entry condition for each direction).

    For exits... I have it set up to exit when an indicator crosses below X.
    i.e. "if indicator line crosses below X, ExitLong." I'm not including any signal names because I want the strategy only to enter these trades if Set 2 didn't find any qualifying trade setups. Then, Set 3 takes over and grabs any trades which didn't quite qualify for Set 2's conditions.

    I've got a stoploss set to 10 in the "profit & stoploss" panel.

    I'm having a heck of a time getting this strategy to place orders in sim connected to a live CQG feed.

    I think it may be related to MarketPosition. I'm not currently using this in the conditions area because I don't fully understand what it is for. In some of the examples posted by NinjaTrader support, I see this used, in others, I just see "EnterLong" without any reference to MarketPosition.

    I've "played around" with it, setting "== flat" or "==long" or "!== Long," etc., just to see what difference it makes... and I'm lost.

    For my strategy setup, when I load the strategy, I leave "calculate on bar close" to true.
    I have "Sync account position" set to "True."
    And, I have my "Tools > Options > Strategies > NijnaScript" tab set to "Wait until flat before executing live."

    In a strategy with multiple entry conditions, I suspect I should be using the MarketPosition method in some way. I'm just not sure why, and I'm certainly not sure exactly how.

    Could someone please give me a wee nudge in the right direction?

    Almost there... just a few more tweaks!

    -V

    #2
    Hello V,

    Thank you for your post.

    Let's say you want to make sure your position is closed before taking another position, you would use Position.MarketPosition == MarketPosition.Flat. The same thing would be done if you have conditions that can reverse an existing position but you do not wish to reverse until you position is closed by your Exit() method or the Set() methods.

    In general, Position.MarketPosition would only be used when you need it. If you do not have a need for this then do not use it. Information on Position.MarketPosition can be found at the following link: http://www.ninjatrader.com/support/h...etposition.htm

    Please let me know if you have any questions.

    Comment


      #3
      Big THANK YOU!!!

      Hi PatrickH,

      Huge thanks for that quick reply.

      You've given me an "ah-ha" moment for which I'm grateful.

      I thought the Position.MarketPosition method was somehow related to the strategy itself (some necessary mechanism in order for it to function properly under certain conditions, i.e. multiple entry condition sets in the same direction, etc.) I see now that it is actually something that is used as part of the "trade logic" when required, and just like "CrossAbove" is a "check," of the state of market conditions or indicator locations, so, too, is the Position.MarketPosition method. Used only when the specific trade logic requires it.

      Wow!!! I hope your reply does as much for others as it has done for me. It really helped to clarify something that has been franky a bit of a worry.

      Thank you again! I'm really glad you guys are here... looks like I'd better take a closer look at NinjaTrader Brokers (shhhh... don't tell AMP I said that).

      -V

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by sjsj2732, Yesterday, 04:31 AM
      0 responses
      33 views
      0 likes
      Last Post sjsj2732  
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      286 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      285 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      133 views
      1 like
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      91 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Working...
      X