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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    110 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    156 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    74 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    125 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    79 views
    0 likes
    Last Post PaulMohn  
    Working...
    X