Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position.MarketPosition Clarification

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

    #16
    Do i need to change marketposition for a different boolean variable?
    I put these additional exit conditions in the onbarupdate method and it won't compile:


    ***********************************


    if(C1ose[0] < Low[1] && Position.MarketPosition == MarketPosition.Long)
    {
    ExitLong(DefaultQuantity,"BULL TRIGGER");
    }
    if(Close[0] > High[1] && Position.MarketPosition == MarketPosition.Short)
    {
    ExitShort(DefaultQuantity,"BEAR TRIGGER");
    }


    ***********************************

    Comment


      #17
      Hello gordongekko,

      Thank you for your response.

      Please provide the compile error descriptions when you report these.

      In your code you provided you appear to have a typo where Close is listed as C1ose. Perhaps this is the error.

      Please let me know if you have any questions.

      Comment


        #18
        It was an error about not being able to convert a string to an int so i removed the string portion which is probably not needed for that anyway but I'm not sure.

        This code compiled but i have not tested it yet:



        if(Close[0] < Low[1] && Position.MarketPosition == MarketPosition.Long)
        {
        ExitLong(DefaultQuantity);
        }
        if(Close[0] > High[1] && Position.MarketPosition == MarketPosition.Short)
        {
        ExitShort(DefaultQuantity);
        }

        ERROR CODE:

        The best overloaded method match for 'NinjaTrader.NinjaScript.StrategyBase.ExitLong(str ing, string)' has some invalid arguments CS1502 Argument 1: cannot convert from 'int' to 'string' CS1503 The best overloaded method match for 'NinjaTrader.NinjaScript.StrategyBase.ExitShort(st ring, string)' has some invalid arguments CS1502 Argument 1: cannot convert from 'int' to 'string' CS1503

        when using this version:


        if(Close[0] < Low[1] && Position.MarketPosition == MarketPosition.Long)
        {
        ExitLong(DefaultQuantity, @"BULL TRIGGER");
        }
        if(Close[0] > High[1] && Position.MarketPosition == MarketPosition.Short)
        {
        ExitShort(DefaultQuantity, @"BEAR TRIGGER");
        }
        Last edited by gordongekko; 02-02-2018, 02:30 PM.

        Comment


          #19
          Hello gordongekko,

          Thank you for your response.

          When using the string and int quantity you need to include two strings; one for the entry signal name and one for the signal name of the exit.

          For example:
          Code:
          ExitLong(DefaultQuantity, [B]"EXIT SIGNAL NAME"[/B], @"BULL TRIGGER");
          Please let me know if you have any questions.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          58 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
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X