Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Position.String()

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

    Position.String()

    Always use historical && realtime to check to enter or not within onbarupdate()
    Position.MarketPosition == MarketPosition.Flat

    BUT gotta be a string somewhere I can use with that?
    like:
    Position.MarketPosition.sEntry1L == MarketPosition.Long

    I am asking too much?

    Jon

    ps: So I get this far
    Position.MarketPosition.ToString("sENTRY5L") == MarketPosition.Flat

    and get a compile error, but to me it looks similar to the examples in the help files .. error is '==' cannot be applied to operands of type 'string' and 'NT.Cbi.MarketPosition'
    Last edited by Trader.Jon; 03-22-2011, 10:47 PM.

    #2
    Hi Jon, this will be the overall strategy position - it looks like you try to work with the current partial position your specific entry signal would have? For this you would work with the IOrder objects offering a finer control - http://www.ninjatrader.com/support/h...nt7/iorder.htm
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand,

      Thanks, but still confused and trying ... IF I want to check to see if a SPECIFIC entry is till working (from a group of entrys made at the same time as an example) to qualify if I will make an additional entry in the strategy

      Code:
       
      [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]protected[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]override[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]void[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] OnPositionUpdate(IPosition position)[/FONT]
      [FONT=Arial]{ [/FONT]
      [FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] (position.MarketPosition.ToString([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"sENTRY5L"[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]) == MarketPosition.Long)[/FONT]
      [FONT=Arial]{[/FONT]
      [FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]// reset bool variable[/COLOR][/FONT]
      [/COLOR][/FONT][FONT=Arial]iVerifyFilled5L= [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]true[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial];[/FONT]
      [FONT=Arial]}[/FONT]
      [FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]//[/COLOR][/FONT]
      [/COLOR][/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial] (position.MarketPosition.ToString([/FONT][FONT=Arial][COLOR=#800000][FONT=Arial][COLOR=#800000]"sENTRY5L"[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial]) == MarketPosition.Flat)[/FONT]
      [FONT=Arial]{[/FONT]
      [FONT=Arial][COLOR=#008000][FONT=Arial][COLOR=#008000]// reset bool variable[/COLOR][/FONT]
      [/COLOR][/FONT][FONT=Arial]iVerifyFilled5L= [/FONT][FONT=Arial][COLOR=#0000ff][FONT=Arial][COLOR=#0000ff]false[/COLOR][/FONT][/COLOR][/FONT][FONT=Arial];[/FONT]
      [FONT=Arial]}[/FONT]
      [FONT=Arial]}[/FONT]
      and should I use a simple bool or a boolseries to hold that qualifying information (I am guessing just a simple bool and then turn it off) as in above 'guess', And I now still have same error
      error is '==' cannot be applied to operands of type 'string' and 'NT.Cbi.MarketPosition'

      Thanks,
      Jon
      Last edited by Trader.Jon; 03-23-2011, 07:32 AM.

      Comment


        #4
        Hi Jon, the above guess will unfortunately not work for this purpose, ToString just converts the returned value to a string, it does not allow you to specific to check a market position for a specific entry signal, the position property is just the overall strategy position. Yes, you could also use a bool flag to check which entry signal has triggered or should be available for retriggering.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by giulyko00, Today, 11:01 AM
        0 responses
        1 view
        0 likes
        Last Post giulyko00  
        Started by martin70, 05-17-2024, 04:06 AM
        7 responses
        29 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by Uregon, Today, 10:53 AM
        0 responses
        2 views
        0 likes
        Last Post Uregon
        by Uregon
         
        Started by ETFVoyageur, Today, 10:34 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by sdauteuil, 09-23-2021, 10:16 AM
        10 responses
        1,263 views
        0 likes
        Last Post NinjaTrader_RyanS  
        Working...
        X