Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddOn to Exit Position

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

    AddOn to Exit Position

    Hi,

    I would like to create an AddOn to exit a Long position when for example the open of today is greater than 2 days ago for unmanaged approach.

    I was thinking something like this in the AddOn:

    public static Order SubmitProfit(int selectedBarsInProgress, OrderAction orderAction, OrderType orderType, int quantity, double TakeProfit, string oco, string signalName) {

    double openPrice = Open.GetValueAt(CurrentBar);

    double openPrice2DaysAgo = Open.GetValueAt(CurrentBar - 2);

    if (openPrice >= openPrice2DaysAgo)
    {
    SubmitOrderUnmanaged(selectedBarsInProgress, orderAction, orderType, quantity, limitPrice, 0, oco, signalName);
    }​

    }​

    Could you please give me some hints about the parameters/object I need to pass to the AddOn to make it working?

    Thank you.



    #2
    Hello Peppo,

    From an addon (that is not an indicator or strategy) data is retrieved with a BarsRequest, orders are submitted with <Account>.CreateOrder() and <Account>.Submit().

    Below are links to the help guide.


    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      thank you for your reply.​

      I had a look to the documentation and it seems quite elaborate to accomplish that.

      I would like to simply have a function/method that I can recall into my strategies.

      Is it possible to achieve that with a class? Do you suggest any other solution?

      Thank you.

      Comment


        #4
        Hello Peppo,

        It's something that you have to write out in the code if thats what you want the code to do.

        Unfortunately, there isn't another way to request data or send orders in an addon.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        53 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X