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 DannyP96, 05-18-2026, 02:38 PM
    1 response
    23 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    115 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    225 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    408 views
    0 likes
    Last Post CaptainJack  
    Working...
    X