Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order Quantity Error

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

    Order Quantity Error

    Hi,
    I'm attempting to set the order Quantity relative to whatever my cash value is at the moment. ( Essentially Cash value divided by the current asking price, rounded to a whole number would be the number of shares I'd like to execute on each long)

    In Initialize() I have AccountSize = 40000

    then for OnBarUpdate() at the end of my code I have my conditions and the line to long the stock as seen below:
    EnterLong("",math.round(GetAccountValue(AccountIte m.CashValue)/Ask[0]), "");

    When I run the script it just orders 1 share every time, so its clearly not working...
    Could someone assist me, I'm not sure if my logic is correct. I might be going about this all wrong.

    Cheers,
    Mike

    #2
    Originally posted by mwait View Post
    Hi,
    I'm attempting to set the order Quantity relative to whatever my cash value is at the moment. ( Essentially Cash value divided by the current asking price, rounded to a whole number would be the number of shares I'd like to execute on each long)

    In Initialize() I have AccountSize = 40000

    then for OnBarUpdate() at the end of my code I have my conditions and the line to long the stock as seen below:
    EnterLong("",math.round(GetAccountValue(AccountIte m.CashValue)/Ask[0]), "");

    When I run the script it just orders 1 share every time, so its clearly not working...
    Could someone assist me, I'm not sure if my logic is correct. I might be going about this all wrong.

    Cheers,
    Mike
    Before your EnterLong - let's see what's actually being computed.

    Code:
    Print (" GetAccountValue(AccountIte m.CashValue)=" + GetAccountValue(AccountIte m.CashValue) );
    Print ( "Ask[0]=" + Ask[0] );
    Print ( "The division=" + (GetAccountValue(AccountIte m.CashValue)/Ask[0]))  );
    Print ( "The rounding=" + math.round(GetAccountValue(AccountIte m.CashValue)/Ask[0]))  );
    Whatever your issue is, it should be clear now.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,611 views
    0 likes
    Last Post aligator  
    Started by jaybedreamin, Today, 05:56 PM
    0 responses
    9 views
    0 likes
    Last Post jaybedreamin  
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    19 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    6 views
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    22 views
    0 likes
    Last Post Javierw.ok  
    Working...
    X