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 argusthome, 03-08-2026, 10:06 AM
    0 responses
    77 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    45 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    27 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    32 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    63 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X