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.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    77 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    45 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    168 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    101 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    170 views
    2 likes
    Last Post CaptainJack  
    Working...
    X