Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problems with position sizing with Automated strategy

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

    Problems with position sizing with Automated strategy

    Hello,

    I am experiencing difficulties regarding position sizing in my code. What I would like to do is to enter positions based on my current account balance instead of entering a position with a default of 10k.

    So far I have tried using the GetAccountValue function. when i go to compile the code, everything is fine. However when i go to backtest, it is opening one dollar positions.

    here is the buying criterion section of my code:

    Code:
    if ((HAupperwick/HAbody)>1.2&&HAlowerwick<HAbody/20)// buying criterion
                {
                    EnterLong((int)GetAccountValue(AccountItem.BuyingPower), "");
    				EntryPrice=GetCurrentBid();
    				SetTrailStop(CalculationMode.Ticks, SL);
                }
    i have attached the entire code as well for further scrutiny.
    Attached Files

    #2
    fruitfly, GetAccountValue would not be working for backtesting use, it would be realtime / live property only - you would see a value of 0 returned on historical bars.



    You can either custom calculate a qty to use, or base this of the ByAccountSize setting we have, where the qty would be calculated by NT based on your set AccountSize -

    Comment

    Latest Posts

    Collapse

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