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 -

    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rocketman7, Today, 01:00 AM
    0 responses
    1 view
    0 likes
    Last Post rocketman7  
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    27 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    32 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 04-23-2024, 09:53 PM
    2 responses
    74 views
    0 likes
    Last Post wzgy0920  
    Started by Kensonprib, 04-28-2021, 10:11 AM
    5 responses
    193 views
    0 likes
    Last Post Hasadafa  
    Working...
    X