Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Share size rounding

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

    Share size rounding

    Good morning,

    I have some criteria to determine Share size when submitting an order:

    EnterLongStopLimit(Convert.ToInt32(100 / ATR1[0]), High[0] + (10 * TickSize), High[0], "L");

    At times on higher prices instruments my share size is Below 1 share. It seems as if my equation result is between 1 and .05 then the strategy rounds up to 1 share. However if the equation result is below .5 then the strategy defaults to 100 shares.

    Is there a way to make any results under 1 round up to 1 for share size? Or maybe even change the default to 1 share instead of 100, if this is even what is happening?

    Thank you very much for you help,
    Ryan

    #2
    Hello Tonkingrf1551,

    Thank you for your note.

    You could calculate that outside the EnterLongStopLimit() method call and do something like this to ensure at least 1 share:

    Code:
    double myShareSize;
    
    myShareSize = 100/ATR1[0];
    
    if (myShareSize < 1)
    {
    myShareSize = 1;
    }
    
    EnterLongStopLimit(Convert.ToInt32(myShareSize), High[0] + (10 * TickSize), High[0], "L");
    Please let us know if we may be of further assistance to you.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    45 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    31 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X