Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"enterlong" syntax question

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

    "enterlong" syntax question

    Hi,

    I was wondering if anyone can double-check this line of syntax - it doesn't seem to be giving me the intended output:

    EnterLong((int) 20/(.1*(Median[0])), "");

    My intention for it to signify that:

    the quantity of shares for a long entry =
    (whole number of) 20 divided by the median price of the last day multiplied by .1

    Thanks

    #2
    Quantum, you will want to break up the calculations into separate parts to help identify where the error might be coming from. You can use the Print() method to send data to the output window (Tools -> Output Window) to see what the results of your calculations are. You could do something like this:
    Code:
    double qty = 20 / (0.1 * Median[0]); // calculate quantity with double precision
    int qty_round = (int) Math.Round(qty); // round double and cast as int... note that standard c# will round midpoints to nearest even number: 4.5 -> 4
    Print("the calculated qty is:\t" + qty.ToString() + "\tand rounded qty is:\t" + qty_round.ToString());
    
    EnterLong(qty_round, "my long entry");
    Please let me know if I can be of further assistance.
    AustinNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    578 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    554 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X