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 argusthome, 03-08-2026, 10:06 AM
    0 responses
    72 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    43 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    25 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    28 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    59 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X