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 Belfortbucks, Today, 09:29 PM
    0 responses
    6 views
    0 likes
    Last Post Belfortbucks  
    Started by zstheorist, Today, 07:52 PM
    0 responses
    7 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    151 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Started by mattbsea, Today, 05:44 PM
    0 responses
    6 views
    0 likes
    Last Post mattbsea  
    Started by RideMe, 04-07-2024, 04:54 PM
    6 responses
    33 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Working...
    X