Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Break Even & Average Price calculation

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

  • NinjaTrader_ChelseaB
    replied
    Hello Bruce,

    From an indicator you will need to use the Addon approach. SubmitOrderUnmanaged is no longer going to work as this is a NinjaScript Strategy method.

    Below is a link to an example.
    https://ninjatrader.com/support/foru...082#post536082

    As well as a link to the help guide.
    https://ninjatrader.com/support/help...reateorder.htm
    https://ninjatrader.com/support/help...-us/submit.htm

    The Addon approach to get an account that Jim has provided works with any script type.

    Leave a comment:


  • BGWTEX
    replied
    Thanks Jim,

    "The other line finds the Account named "Sim101" and assigns it to the account object." Seems like a long way around to find what we already know . . . thanks for the explanation.

    I'm considering changing my Strategy into an indicator, what advantages would I lose ? I'd gain Account access, which is a big advantage to me. I'm already using "SubmitOrderUnmanaged( ", so I'm thinking there won't be too much to change.

    Thanks,

    Bruce

    Leave a comment:


  • NinjaTrader_Jim
    replied
    Hello Bruce,

    The account collection gets locked so we can read the collection without creating a threading error.

    The other line finds the Account named "Sim101" and assigns it to the account object.

    Please let us know if we can be of further assistance.

    Leave a comment:


  • BGWTEX
    replied
    Thanks Jim, that's exactly what I needed. Even the Chart Trader quantity increases are included in the executions, great !
    Could you explain these 2 lines ?
    lock (Account.All)
    account = Account.All.FirstOrDefault(a => a.Name == "Sim101");

    Thanks again,

    Bruce

    Leave a comment:


  • NinjaTrader_Jim
    replied
    Hello Bruce,

    Thanks for your question.

    Strategies are only able to manage their own virtual positions out-of-box. They are not aware of manual orders or positions. The Strategy OnOrderUpdate and OnExecutionUpdate methods in a strategy work for that strategy alone. If you would like to monitor account level order and execution updates, you can subscribe to the account OrderUpdate and ExecutionUpdate events. I have attached an example NinjaScript that subscribes these events.

    Please let us know if you have any questions.
    Attached Files

    Leave a comment:


  • BGWTEX
    replied
    PS:

    This is for live trading, not Back Testing.

    BGW

    Leave a comment:


  • BGWTEX
    started a topic Break Even & Average Price calculation

    Break Even & Average Price calculation

    Greetings,

    The NT Break Even & Average Price, in a Strategy and on Chart Trader do not seem to be able to give me what I need.
    The problems being:
    Entry & Exit orders are not matched (in NT's Break Even & Average Price). It appears only FIFO & LIFO methods are available, which is not my situation.
    Manual quantity changes (using Chart Trader) to Strategy Orders are not available in the Strategy, so I can't calculate Average Price in the Strategy.

    So, my questions are:
    Is my understanding of NT correct ?
    How can I access Order/Execution information, from both Chart Trader and Strategy Orders, to calculate Break Even & Average Price, in a non LIFO/FIFO situation ?
    Is it possible using an Add On ?
    I tried subscribing to order updates, in a Strategy, and using
    " private void OnOrderUpdate(object sender, OrderEventArgs e)
    {
    }"
    Then entering an order with Chart Trader, resulting in "Unhandled exception: Object reference ...".

    Thanks,

    Bruce

Latest Posts

Collapse

Topics Statistics Last Post
Started by DiverG20, Today, 10:23 AM
0 responses
4 views
0 likes
Last Post DiverG20  
Started by caacapital, Today, 10:10 AM
0 responses
3 views
0 likes
Last Post caacapital  
Started by SuneSorgenfrei, Today, 09:29 AM
0 responses
6 views
0 likes
Last Post SuneSorgenfrei  
Started by dodoei, Today, 07:24 AM
0 responses
8 views
0 likes
Last Post dodoei
by dodoei
 
Started by thecashguys, Today, 06:13 AM
0 responses
10 views
0 likes
Last Post thecashguys  
Working...
X