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

ETF trading and help

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

    #16
    Hey, sorry, my last text came out smug. I didn't mean it to sound like that.

    I wanted to add a question- When I use a simulated or real account, if your account is tied up in a trade, but the second bot tries to buy. Does it fail to trade that instance?

    Comment


      #17
      Hello Tirosovan,

      Thanks for your notes.

      Do you see any error messages in the Log tab of the Control Center? If so, what exactly does the error report?

      Have you added debugging prints to the strategy to understand exactly how your logic in the script is evaluating?

      If the expected trade(s) are not appearing, this would indicate that the condition to place the order is not evaluating as true or the order is being ignored for other reasons.

      To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

      In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar.

      Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

      Also, enable TraceOrders which will let you know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

      Below is a link to a forum post that demonstrates how to use prints to understand behavior.


      ​Ensure that you are restarting NinjaTrader daily for best performance as noted in the help guide page linked below. If you restart NinjaTrader and connect to your data feed connection, do you see the charts populating with real-time data?

      Performance Tips: https://ninjatrader.com/support/help...ance_tips2.htm

      It is not recommended to run multiple strategies on the same instrument and same account. This would cause the strategies to interfere with one another. For example, if you have two strategies running on the same instrument and same account and the first strategy places a buy long trade you would be in a 1 Long position. If the second strategy were to submit a short trade, this would sell the buy trade and you would be left in a flat position.

      If the strategies are running on separate instruments but on the same account, the strategies would not interfere with one another since each strategy is running on a different instrument.

      See this forum thread for more information about running multiple strategies on the same instrument and account: https://ninjatrader.com/support/foru...tures-contract
      Brandon H.NinjaTrader Customer Service

      Comment


        #18
        I see only this in Log for today. (Strategy 'Bot/321336704': Exit on session close handling started). Category: (Strategy)

        I'm guessing it's just closing the session 360 seconds from day close in my settings.

        Ive added the logs to my actions under the buy and exit conditions.

        Trace-orders was already checked.

        We will see what happens tomorrow.


        Comment


          #19
          Ok, so i didn't have live feed on or simulation on. Only my Kinetick. Does this make a difference?

          Comment


            #20
            Hello Tirosovan,

            Thanks for your notes.

            This message indicates that the Exit On Session Close behavior was triggered from the strategy at the close of the session.

            Prints should be added one line above the condition that prints out all the values being used for those conditions to see how they are evaluating.

            For example:

            Print("Close[0]: " + Close[0] + " > Open: " + Open[0]);
            if (Close[0] > Open[0])
            {
            EnterLong();
            }


            This will allow you to see exactly how the values of the conditions are behaving and what comparison is used for the condition to see if it is true or not.

            Further, when you enable the strategy is the strategy appearing as yellow or green in the Strategies tab of the Control Center?

            If it displays as green then the strategy is ready to place trades as soon as a condition to place a trade becomes true.

            If the strategy is yellow this means that the strategy calculated a historical (virtual) position. It also means that you have "Wait until flat" selected for the 'Start behavior' option in the strategy parameters.

            This means that once the strategy has finished processing the historical data and has transitioned to real-time, it will wait until there is a real-time order submission that will cause the strategy to become flat. This also includes changing from a long position to a short position or vice versa as the position would pass through flat.

            This also applies to secondary instruments if there are added series to the script. All positions must be flat before real-time orders will begin.

            See the help guide documentation below for more information.

            Strategy vs. Account Position — https://ninjatrader.com/support/help..._account_p.htm

            Start Behaviors — https://ninjatrader.com/support/help..._positions.htm

            Additional information could be found in this forum thread - https://ninjatrader.com/support/foru...ion#post811541


            If you want the strategy to submit orders to the live account, you would need to be connected to your live data feed connection and enable the strategy on the live account. Otherwise, if you are wanting the strategy to submit orders to the Sim101 account, you could connect to your live data feed, Kinetick data feed, or the "Simulated Data Feed" connections and enable the strategy on the Sim101 account.
            Brandon H.NinjaTrader Customer Service

            Comment


              #21
              I cant seem to find print in conditions only in actions, or I simply cant find it.

              I came home to my computer restarted. I log in and notice that when I reactivate the bots, one has bought at the end of the day and the strategy analyzer will not display today's data 03/13/2024 (Makes no sense to me) I'm wondering if the computer restart update effected something. I tried restarting my computer, restarting the ninja trader platform, removed all orders, and restarted the strategies on my charts. Still the problem remains. There is a working order currently, not sure why its a limit order either.

              I attached some images for reference.

              The back testing was working nice up to this point.​

              Comment


                #22
                Hello Tirosovan,

                Thanks for your notes.

                In the screenshot you shared it shows the strategy submitted an entry order that filled. Since the entry was filled it submitted a Limit order and Stop Market order. These are likely the profit target and stop loss for the entry.

                If you are using the Strategy Builder to create your strategy the Print action could be found in the Misc folder > Print.

                Below is a link to a forum post that demonstrates how to use prints to understand behavior. This forum thread also contains a demonstration video detailing how to add prints to a Strategy Builder strategy.



                As for the Strategy Analyzer, please open a New > Strategy Analyzer window and test running a backtest on the SampleMACrossover strategy that comes with NinjaTrader with the End Date property set to 03/13/2024.

                Do you see results appearing in the Strategy Analyzer window when testing this?

                Further, keep in mind there can be discrepancies when comparing Strategy Analyzer backtest results to realtime results.

                This help guide page details those discrepancies: https://ninjatrader.com/support/help...ime_vs_bac.htm

                More information could be found on this forum thread: https://ninjatrader.com/support/forum/forum/ninjatrader-8/strategy-development/100192-comparing-real-time-historical-and-replay-performance?t=102504
                Brandon H.NinjaTrader Customer Service

                Comment


                  #23
                  Hey BrandonH. I appreciate all the help thus far.

                  I managed to add prints on my sell and buy actions labeled (buy) (sell). Please see image for reference. It looks like conditions are met many times but no long position was found in that instance. Furthermore, it looks like too many orders are being handled at once creating a lack of funds? Am i seeing that correctly.
                  I believe this is from having the by tick setting active instead of by candle close setting active. I want to handle by candle close anyway.

                  The strategy analyzer on a new window with the SampleMAcrossover is not showing anything on that date. At this point maybe it doesn't matter, Its just an inconvenience.

                  I'm using HeikenAshi candles for my back-test and upcoming live paper trade. I noticed in your discrepancies help section that all back-test data is only in at the end of each candle close. (If my settings are at bar close, are the real life results somewhat close to back-test results?) If not, what else would I need to do to replicate that back-test as closely as possible for HeikenAshi?

                  Comment


                    #24
                    Hey BrandonH. I appreciate all the help thus far.

                    I managed to add prints on my sell and buy actions labeled (buy) (sell). Please see image for reference. It looks like conditions are met many times but no long position was found in that instance. Furthermore, it looks like too many orders are being handled at once creating a lack of funds? Am i seeing that correctly.
                    I believe this is from having the by tick setting active instead of by candle close setting active. I want to handle by candle close anyway.

                    The strategy analyzer on a new window with the SampleMAcrossover is not showing anything on that date. At this point maybe it doesn't matter, Its just an inconvenience.

                    I'm using HeikenAshi candles for my back-test and upcoming live paper trade. I noticed in your discrepancies help section that all back-test data is only in at the end of each candle close. (If my settings are at bar close, are the real life results somewhat close to back-test results?) If not, what else would I need to do to replicate that back-test as closely as possible for HeikenAshi?

                    Comment


                      #25
                      I had a side question. I run 2 bots for 2 etf stocks. I was wondering, if one bot buys at the entry signal, then the other tries to do the same. lets say i have all funds tied up in one trade already. what happens with the second trade. Does it just not go through?

                      Comment


                        #26
                        Hello Tirosovan,

                        Thank you for your patience.

                        My name is Emily and I am responding on behalf of Brandon, who is not in the office today. I suspect you are seeing discrepancies due to testing on Heiken Ashi bars. You are correct that backtests in the Strategy Analyzer are processed on bar close, though there is also a section about "Backtesting Renko bars and HeikenAshi bars" at the bottom of the page. Heiken Ashi bars set the OHLC values to the Heiken Ashi moving average values and not actual price values. Instead, you could try testing your strategy in the Playback connection:


                        Or you could consider programming the strategy to obtain the Heiken Ashi values from an indicator rather than the barsType. That way the data series selected for a backtest can provide actual price data while the indicator can provide the Heiken Ashi average values needed in your logic.

                        This Heiken Ashi indicator is publicly available on our NinjaTrader Ecosystem website:
                        Here is a basic guideline of how to import NinjaScript add-ons in NinjaTrader 8:

                        Note — To import NinjaScripts you will need the original .zip file.

                        To Import:
                        1. Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
                        2. From the Control Center window select the menu Tools > Import > NinjaScript Add-on...
                        3. Select the downloaded .zip file
                        4. NinjaTrader will then confirm if the import has been successful.

                        Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'

                        Once installed, you may add the indicator to a chart by:
                        • Right-click your chart > Indicators... > Select the Indicator from the 'Available' list on the left > Add > OK

                        Here is a short video demonstration of the import process:As for your next question, "I had a side question. I run 2 bots for 2 etf stocks. I was wondering, if one bot buys at the entry signal, then the other tries to do the same. lets say i have all funds tied up in one trade already. what happens with the second trade. Does it just not go through?"

                        It is not advised to run two strategies on the same instrument and account at the same time. More information about this may be found here:


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

                        The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
                        Emily C.NinjaTrader Customer Service

                        Comment


                          #27
                          Excellent! thank you for this info.

                          So when i run the Heiken Ashi in back-test I don't need to modify anything on the back-testing side, because I'm trying to replicate the results in live to those back-testing values? I'm trying to copy my beck-testing results as closely as I can. I was able to see my first live trading day. It looked like my live trading time frame may be slightly off from the order placement. I applied the indicator as you asked to the charts that will be trading. (have yet to see if that changes anything) I noticed I cannot add this to the back-testing side. As stated above I'm not sure it even needs it.

                          Also, I noticed live trading made a trade that would otherwise not have triggered. In this case a trade was made in the very beginning of the day. I notice on back-testing, the first candle of my charts Never trade due to (Bars required to trade) (1) This however is not the case in live?

                          I also noticed that the Back-test made sells at the bottom of the candle instead of the top. This greatly inflates my back-test results to the positive side. What could I do to replicate the back-test, is it possible? Maybe the indicator will help fix these issues. I digress, I would like to further understand the relationship of the Heiken Ashi indicator applied to the charts.

                          Comment


                            #28
                            I wanted to add one thing. I notice that in live the sells and buys happen at different times than back-test. Is it due to the back-test setting (Price based on LAST) compared to calculate (ON bar close) in live?

                            Comment


                              #29
                              Hello Tirosovan,

                              Thanks for your notes.

                              To clarify are you running your script using the Heiken Ashi indicator that Emily mentioned in post # 26?

                              Similarly to custom Renko bars which use a "fake" open price, HeikenAshi bars alter the OHLC values of the data series to use the HeikenAshi moving average values. Since these are not real prices, the Heiken Ashi indicator would need to be used to get the Heiken Ashi average values or you would need to test your script using the Playback connection.

                              If you are using the Heiken Ashi indicator, you would need to modify your script to get the price values from the Heiken Ashi indicator instead of the Heiken Ashi BarsType. By doing so the data series selected for a backtest can provide actual price data while the indicator can provide the Heiken Ashi average values needed in your logic.

                              Otherwise, the Playback connection could be used with Market Replay data to test your strategy. If you choose this option, the strategy would not need to be modified.

                              A strategy running real-time (live brokerage account, live market simulation, Playback connection etc...) will produce different results than the performance results generated during a backtest.

                              Please review the help guide document on the differences on real-time vs backtest (historical).


                              To improve the accuracy of a backtest, you may use Tick Replay along with an added 1-tick series to have logic processed intra-bar and have orders filled intrabar.

                              Tick Replay would be used to have the logic process OnEachTick or OnPriceChange with historical data, but this does not allow for intra-bar order fills. You would need to add a single tick data series and submit orders to that single tick data series for a strategy that uses Tick Replay.

                              High Order Fill Resolution allows for intra-bar order fills with historical processing, but is not compatible with Tick Replay.

                              Please reference the SampleIntrabarBacktest example and the following Help Guide links for more information.

                              SampleIntrabarBacktest 'Backtesting NinjaScript Strategies with an intrabar granularity': https://ninjatrader.com/support/help...ipt_strate.htm

                              TickReplay: https://ninjatrader.com/support/help...ick_replay.htm

                              Developing for Tick Replay: https://ninjatrader.com/support/helpGuides/nt8/developing_for__tick_replay.htm?zoom_highlightsub= developing+for+tick+replay

                              Additional information may be found in this NinjaTrader Forum post —
                              Citizens of the NinjaTrader Community, A common question we hear from clients is 'why are results from backtest different from real-time or from market replay?'. Live orders are filled on an exchange with a trading partner on an agreed upon price based on market dynamics. Backtest orders are not using these market dynamics.


                              Brandon H.NinjaTrader Customer Service

                              Comment


                                #30
                                Hello, I have another question.

                                What connections do I need active in order for my trading strategy to run all day while I'm at work? Its a little confusing, as sometimes i get it to work and other times not. I enable both strategies the night before. I have (LIVE) (my Kinetick) and (simulated trading) all active when i leave in the morning. But when i get home, no trade activity was taken.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by marcus2300, 05-10-2024, 10:21 AM
                                8 responses
                                27 views
                                0 likes
                                Last Post marcus2300  
                                Started by ETFVoyageur, Today, 05:50 AM
                                2 responses
                                16 views
                                0 likes
                                Last Post ETFVoyageur  
                                Started by thumper57, 05-11-2024, 04:30 PM
                                10 responses
                                33 views
                                0 likes
                                Last Post NinjaTrader_BrandonH  
                                Started by Ludwik, Today, 03:52 AM
                                1 response
                                19 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Started by ETFVoyageur, 05-11-2024, 12:52 AM
                                4 responses
                                41 views
                                0 likes
                                Last Post NinjaTrader_BrandonH  
                                Working...
                                X