Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Chart trader customization

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

    Chart trader customization

    Is it possible to intercept a buy/sell order click on chart trader and then do some validation on account before letting it place order. The intent is to ensure that over trading is not allowed and once account crosses n position or loss , no further order entry is allowed.

    i have already looked around in the forum and hasnt found a solution yet.

    #2
    Hello [email protected],

    Manual trades will affect the account.

    Using the Addon approach, you can add a method handler to the <account>.ExecutionUpdate method.

    Below is a link to the help guide.
    https://ninjatrader.com/support/help...tionupdate.htm

    However, you would not be able to prevent the order from being placed.

    Instead, you can write the addon to have a button that when clicked will decide to place the order if conditions are correct.
    Below is a link to an example addon that places orders.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      thanks Chelsea, this has been helpful, i actuall used the "Add on Framework" example to build my own chart trader.. was able to incorporate validation before placing orders. Two new things i am now stuck at:
      1. Attaching to the chart window; a individual chart can have its own TradeManager add on just like default ChartTrader. Need to be able to attach to the chart it should be on top of chart or side by side to the chart(ust like default chart trader is positioned).
      2. Need some guidance on placing limit order ; need some help on how to get last bid or last ask price. not sure how to access last bid/ask in the order place scenario from add on.
      entryOrder = accountSelector.SelectedAccount.CreateOrder(Instru ment, OrderAction.Buy, OrderType.Limit, tifSelector.SelectedTif, qudSelector.Value, <GetLastBid>, 0, string.Empty, "Manish-CT-"+btnBuyMarket.Content.ToString(), null);

      Comment


        #4
        Hello [email protected],

        Please take a look at the ChartCustomSidePanelExample_NT8 linked below.
        Hello All, Moving forward this will be maintained in the help guide reference samples and no longer maintained on the forum. Creating Chart WPF (UI) Modifications from an Indicator - https://ninjatrader.com/support/help...ui)-modifi.htm (https://ninjatrader.com/support/helpGuides/nt8/creating-chart-wpf-(ui)-modifi.htm) I've


        As well as an example that places orders through the Addon approach.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you Chelsea for that snippet, is there any way to add account selector ( below the button 2) in the ChartCustomSidePanelExample_NT8 script. I tried getting a reference from account selector from charttrade and tried adding that as in the next row but nothing appeared


          NinjaTrader.Gui.Tools.AccountSelector accountSelector = Window.GetWindow(ChartControl.Parent).FindFirst("C hartTraderControlAccountSelector") as NinjaTrader.Gui.Tools.AccountSelector;
          System.Windows.Controls.Grid.SetRow(accountSelecto r, 2);
          System.Windows.Controls.Grid.SetColumn(accountSele ctor, 0);
          buttonGrid.Children.Add(accountSelector);

          Comment


            #6
            i think i might have figured it out.. am using xmal to define my structure and then loading it at run time. appreciate your help in this.

            Comment


              #7
              Hi manishzain,
              "I actuall used the "Add on Framework" example to build my own chart trader.. was able to incorporate validation before placing orders."

              This is pretty amazing actually! I have been struggling with this for a long timer. This will help a lot of people with discipline issues. One can build various checks.. say for example.. if 3 losers in a row, then no more trading in that day OR if Daily Loss Limit reached OR maybe a timeout from placing new orders of 1 hour. Calculate overall risk(sometime one loses perspective) etc etc

              If you can Please share in the sharing section.. if not possible a code snippet would be helpful too. Thanks

              Comment


                #8
                Hello [email protected],

                Yes, an account selector can be added.

                Below is a link to an example.


                I don't have examples of the custom logic you are wanting for order placement and you will need to create this custom logic.

                I do have an example of a daily loss limit strategy you may find helpful.
                Hello, I've updated the DailyLossLimit and DailyLosLimitMultiTrade examples that were posted on the forum for NinjaTrader 7 for NinjaTrader 8. These are often requested and I felt they are good examples to have for NT8. DailyLossLimitExample_NT7 - http://ninjatrader.com/support/forum...241#post451241 (http://ninjatrader
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  thanks Chelses, i used a different way to get Account selector, i will review the example you quoted; This is how it looks as of now with live trading, was able to incorporate validation framework before submitting the order; also creating an add on to help track & handle any manual orders.

                  One more thing i'm struggling with is how do i make this new chart trader window stick to other open "chart tab/window" for the same instrument?
                  The other challenge i have is to find out orders with OCO (strategy) and cancel those when one of the order is canceled/filled. (i think . i will figure that out, just need some research)

                  learned so much for your help on this, learnt a lot about ninjascript in last one week; This add on is something i wanted from a long time.

                  Comment


                    #10
                    Originally posted by SuperDriveGuy View Post
                    Hi manishzain,
                    "I actuall used the "Add on Framework" example to build my own chart trader.. was able to incorporate validation before placing orders."

                    This is pretty amazing actually! I have been struggling with this for a long timer. This will help a lot of people with discipline issues. One can build various checks.. say for example.. if 3 losers in a row, then no more trading in that day OR if Daily Loss Limit reached OR maybe a timeout from placing new orders of 1 hour. Calculate overall risk(sometime one loses perspective) etc etc

                    If you can Please share in the sharing section.. if not possible a code snippet would be helpful too. Thanks
                    https://ninjatraderecosystem.com/user-app-share/
                    i am not a profession programmer however i will share some snippet of validation framework once i am done. I used to use some paid add on for this however it was buggy & had performance issues therefore wasn't really effective. i actually did built in all the validations you mentioned besides overall NUT, max pos size, max loss per trade, scale in allowed. and protect profit once you reach your daily goal by adjusting max daily loss to n% of total realized profit for the day.

                    Comment


                      #11
                      Hello [email protected],

                      I am not aware of any way to stick one window to another.

                      Instead, you can modify the chart itself. Any selectors and objects like buttons can be added to a chart by modifying the charts WPF.

                      OCO is a string that is a parameter with the order method. If the OCO strings are the same, the two orders are grouped.
                      The ProfitChaseStopTrailAddonExample I have provided a link to uses OCO strings.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        thanks Chelsea, if there any way to enable Chart trader by script and then hide it immediately. i realized that for my trades to be shown on chart i need to have chart trader enabled ? thanks,

                        Comment


                          #13
                          Hello [email protected],

                          I've not tried this but maybe you can set this from ChartControl.ChartTraderVisibility.

                          From the help guide:
                          "ChartTraderVisibility An enum indicating the visibility status of Chart Trader. Possible values are Collapsed, Visible, and VisibleCollapsed"
                          https://ninjatrader.com/support/help...properties.htm

                          But also:
                          "Warning: These are UI properties which are designed to be set by a user. Attempting to modify these values through a custom script is NOT guaranteed to take effect."

                          If you find it doesn't work, let me know and I'll put in a feature request for you for the development to put under consideration.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Manishzain [email protected] Were you able to get your orders shown on the chart? I have built a similar custom side panel to yours using Chelsea's "CustomChartSidePanelExample" as a guide, so it's an indicator, not an AddOn. My chart is showing me the trade markers, but it won't show me the location of any orders placed by my ATM strategy. (ie The target and stop loss orders aren't displayed on the screen).

                            Comment


                              #15
                              Somehow I was I setting the account property of the chart trader at the wrong time... idk. This is what worked for me in the end:

                              protected void CreateWPFControls()
                              {
                              chartWindow = System.Windows.Window.GetWindow(ChartControl.Paren t) as Chart;
                              chartGrid = chartWindow.MainTabControl.Parent as System.Windows.Controls.Grid;
                              chartTrader = chartWindow.FindFirst("ChartWindowChartTraderContr ol") as Gui.Chart.ChartTrader;

                              ...
                              ...
                              build out buttons/account selctor/etc
                              ...
                              // When the account selector's selection changes, call a custom function
                              accountSelector.SelectionChanged += (o, args) => { updateNickAccount(o, args); };

                              // I could set the visibility here but couldn't set the account. Maybe the selector had no value yet.
                              chartWindow.ChartTrader.ChartTraderVisibility = ChartTraderVisibility.VisibleCollapsed;

                              }

                              private void updateNickAccount(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
                              {
                              ...
                              // when I set it here, it worked
                              chartWindow.ChartTrader.Account = accountSelector.SelectedAccount;
                              ...

                              }

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by helpwanted, Today, 03:06 AM
                              1 response
                              11 views
                              0 likes
                              Last Post sarafuenonly123  
                              Started by Brevo, Today, 01:45 AM
                              0 responses
                              9 views
                              0 likes
                              Last Post Brevo
                              by Brevo
                               
                              Started by aussugardefender, Today, 01:07 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post aussugardefender  
                              Started by pvincent, 06-23-2022, 12:53 PM
                              14 responses
                              242 views
                              0 likes
                              Last Post Nyman
                              by Nyman
                               
                              Started by TraderG23, 12-08-2023, 07:56 AM
                              9 responses
                              387 views
                              1 like
                              Last Post Gavini
                              by Gavini
                               
                              Working...
                              X