Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Toggle between DefaultQuantity and Position.Quantity

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

    Toggle between DefaultQuantity and Position.Quantity

    Is there a way to script in an input into a Strategy to allow for the toggle/selection between DefaultQuantity and Position.Quantity when rendering an order?

    I attempted the following via a bool but obviously have something wrong:

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    B_Quantity_Exit_Postition = false;
    D_ExitQuantity = @"DefautQuantity";
    }
    }

    ______________________________


    protected override void OnBarUpdate()
    {
    if (B_Quantity_Exit_Postition == true)
    {
    D_ExitQuantity = @"Position.Quantity";
    }

    ExitLongLimit(Convert.ToInt32(D_ExitQuantity ), High[0], "", "");
    }

    Thanks for any direction

    #2
    Hello larkmail,

    The variable D_ExitQuantity would need to be changed to an int variable. After doing that you would need to use the properties rather than making a string out of them. Right now you have "@"Position.Quantity" which would equate to literally a string saying "Position.Quantity" and not a number.



    Here are the changes after using an int:
    Code:
    [B]D_ExitQuantity [/B]= DefautQuantity;
    For the position:

    Code:
    D_ExitQuantity = Position.Quantity;
    And later you would remove the convert:

    Code:
    ExitLongLimit([B]D_ExitQuantity [/B], High[0], "", "");

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by mjairg, 07-20-2023, 11:57 PM
    3 responses
    213 views
    1 like
    Last Post PaulMohn  
    Started by TheWhiteDragon, 01-21-2019, 12:44 PM
    4 responses
    544 views
    0 likes
    Last Post PaulMohn  
    Started by GLFX005, Today, 03:23 AM
    0 responses
    3 views
    0 likes
    Last Post GLFX005
    by GLFX005
     
    Started by XXtrader, Yesterday, 11:30 PM
    2 responses
    12 views
    0 likes
    Last Post XXtrader  
    Started by Waxavi, Today, 02:10 AM
    0 responses
    7 views
    0 likes
    Last Post Waxavi
    by Waxavi
     
    Working...
    X