Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Questions

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

    Strategy Questions


    Hi Support team,

    I am getting ready to test a strategy I built using Strategy Builder and have had some doubts reviewing NT8 platform today. Not really about using the Strategy Builder, but mostly on entering Spread as a setting ( Forex) and how trade data is presented in NT8 using DEMO, REPLAY and LIVE MARKET.

    Please let me know if you can help me by taking a look at the questions numbered below ( for easier viewing, I always try to make a bullet list):


    Q1- Is there any way to include the FXCM Spread at the backtesting for Forex? Reading previous post about the matter, it seems FXCM does not charge Commission for Forex , Just the Spread is charged… Is this Correct?

    Q2- If FXCM does not charge Commissions, then I don’t need to bother loading any of the Commission templates from Control Center> Tools> Commissions, as they will not be used for Forex either way?

    Q3 - DEMO mode or REPLAY feed ( or Real Market mode) - Please confirm Spread is automatic from FXCM and no settings are required locally for these mode of operation.

    Q4- Using Forward Testing in DEMO mode or REPLAY feed ( or Real Market mode), How can I see a Consolidated PnL (Cummulative and Individual PnL), after certain period running a strategy ( or after a period running the strategy in Real market)? I am referring to reports similar to what NT8 backtesting offers.

    For instance, at Control Center, I am not seeing each "Trade PnL" available at Orders or Execution tabs…? I looked around for Settings that would show the trade $ details, but the Properties Tab does not have these options. I must be missing where these parameters are configured, since this is vital data...The only tab which brings cumulative PnL is the Account tab, which is the running PnL; but in this case, what is the time frame for Account PnL ? Daily only ? Is it configurable somewhere?

    Note - at NT8 backtesting, the Trades display option brings all information about each trade.

    Q5- Is there a setting to close all positions based in MAX DRAWDOW?

    Q6- Is there a setting to close all positions based on EQUITY STOP - reaching a LOWER limit? Percent or Units ( Not STOP LOSS, but EQUITY STOP)

    Q7- Is there a setting to close all positions based on BALANCE LIMIT - reaching an UPPER limit? In Units or $? (Meaning, stop for the day before the tide turns).

    Q8- Is there a NT8 strategy setting to prevent enter a trade if the SPREAD is beyond a threshold?

    Q9- Is there a NT8 strategy setting to prevent enter a trade if the SLIPPAGE is beyond a threshold?


    Thanks much,
    G
    Last edited by bouncetherubble; 10-20-2019, 07:41 PM.

    #2
    Hello bouncetherubble,

    Thank you for your note.

    For backtesting, users generally handle the spread one of three ways: applying slippage, applying a set commission of the average instrument spread, or programming their strategy specifically to use bid and ask data (assuming you have that data available). Unfortunately, I do not have information regarding FXCM's brokerage charges. Commissions templates are not set up for any particular account by default and you'd need to check with FXCM to see what if any commissions they charge and if you should apply any particular template.

    When using live data, whether you're using your live account or a sim account, or using Market replay data, spread calculations use the bid-ask series and are calculated from that.

    To see information similar to what's shown after a backtest when running a strategy on live data or market replay, right click on the chart and select Strategy Performance > StrategyName. You'll get essentially the same info you get when backtesting.

    For questions 6 through 9, these are all items that could be calculated within a strategy and used to control entry and exits programmatically; however, there is not a setting you can set in the UI for a strategy that would stop it based on any of these items.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi Kate,

      Thanks for for your feedback! Please let me break down this paragraph: " For backtesting, users generally handle the spread one of three ways: applying slippage, applying a set commission of the average instrument spread, or programming their strategy specifically to use bid and ask data (assuming you have that data available). Unfortunately, I do not have information regarding FXCM's brokerage charges. Commissions templates are not set up for any particular account by default and you'd need to check with FXCM to see what if any commissions they charge and if you should apply any particular template."

      a) Applying Slippage -
      Q- Do you mean if I set Slippage =1 at the Strategy, that would have a similar effect than applying a Spread of 1 PIP? I thought Slippage would be handled as a " don't care" variable in backtesting ...
      Q- Does this method work good enough to give results approximate to a " virtual" Spread configuration? But in this case, Should I apply a Slippage that sums presumed (Slippage + Spread)? (i.e) - Slippage (1) + Spread(1.3 round trip) = 2.3 at the Slippage field for backtesting?

      Note - I tested with Slippage in 1.3 and it does change Net Profit drastically!

      b)
      Applying a set commission - that option would be the tables loaded by default at Control Center> Commission? But Forex does have any instrument listed there so it would seem NT8 does not allow to apply Commissions to Forex. In addition, and I have read in on of the previous post with similar subjects, that FXCM would not charge Commission, just Spread.
      Q- Upon confirming that with FXCM, that would probably eliminate this option as a Setting for Forex backtesting, do you agree?

      c)
      Programming their strategy specifically to use bid and ask data (assuming you have that data available):

      Q- How can I access a data set that includes Bid and Ask? That would much probably be more precise than using Slippage set as Spread... I was counting that would be included at the standard backtesting data made available for NT8...?

      About " Live data and Strategy Performance > StrategyName" -Thanks VM ! Very useful to know that! I will leave it running and check for those parameters.

      About "
      6 through 9"- these items seem something that can have been developed once and sold hundreds of times, since it never changes.
      Q- Would you know of a vendor that can offer this functionality off -the-shelf to be added to any NT8 Strategy built with the Strategy Builder?



      Many Thanks indeed
      George


      Comment


        #4
        Hi Kate

        About " Live data and Strategy Performance > StrategyName" - I took this picture of Strategy Performance " Real Time" data option

        Q- Can you confirm Entry and Exit price points as shown already include the Broker Spread?

        This is FXCM demo account, but I assume the logic is the same for all brokers and account types, RGR? As you can see at the detail, the Profit or Loss is exactly dictated by the (Entry - Exit) prices. I am looking for confirmation using "forward- testing DEMO in Real Time" that I have a profitable strategy,


        Click image for larger version

Name:	Strategy performance detail.png
Views:	442
Size:	673.6 KB
ID:	1075342


        Attached Files

        Comment


          #5
          Hello bouncetherubble,

          Thank you for your replies.

          Slippage is going to apply to market orders, and assuming your strategy gets in and out with market orders, adding a slippage value would be a way to discount returns and thus simulate spread. However, as of now, NinjaTrader restricts fills to within a current bar. For example if you had a stop which was triggered at a price which was also the low of a 15 minute bar, NinjaTrader would not fill this order outside the bar, thus slippage would be ignored. No slippage would be applied if you were submitted a order to a secondary tick series when backtesting, another limitation of the current backtesting logic.

          If your strategy uses other kinds of orders, then you'd want to create your own commission template. You can do this from Orders > Commissions.

          Use the following steps to set commission levels for forex instruments:
          1. Determine the average spread for the instrument in question (spreads vary by instrument, time, and brokerage account)
          2. Use the average spread to set the minimum commission at the instrument level
          3. (Note, users may need to change this value over time, as average spreads change for each forex pair)
          Backtests in the Strategy Analyzer will inherit the Commission Template assigned to the Sim101 account.

          I've included some publicly available resources for working with and applying Commissions Templates.

          Working with Commissions Templates - https://ninjatrader.com/support/help...commissi_2.htm

          Applying Commissions Templates - https://ninjatrader.com/support/help...commissi_3.htm

          The Strategy Builder can use GetCurrentBid and GetCurrentAsk to get the current bid/ask price which you can use for order submissions. These return the Close price with historical data since bid/ask would not be available then.

          GetCurrentBid - https://ninjatrader.com/support/help...currentbid.htm

          Backtesting uses the OHLC data points of a bar to simulate order fills, it does not use bid/ask/volume to simulate order fills like we can using the Sim101 account against realtime data or the Playback account when connected to Playback with Market Replay data.

          Discrepancies between realtime and backtest - https://ninjatrader.com/support/help...ime_vs_bac.htm

          If you would like to have these orders filled at these levels for backtesting then you can submit these orders to a single tick bid or ask series. This requires unlocking the code and taking an approach like the example below.

          Backtesting with intrabar granularity - https://ninjatrader.com/support/help...ipt_strate.htm

          Using Historical Bid/Ask Series - https://ninjatrader.com/support/help..._ask_serie.htm

          To sum things up, in backtesting, the bid price will always be used for executions. However, in live trading with forex instruments, all sell orders will be executed at Bid prices, while all buy orders will be executed at Ask prices. When looking at live data on a chart, the last price shown on a bar will always be the Bid price, but all pending Buy orders will actually be executed at the Ask price when the plotted Bid price hits the order. So, to wrap it up, yes, on live, the PnL calculations do take the spread into account, but unless you add commissions or slippage to simulate spread or specifically program your strategy to submit your orders to a single tick ask or bid series, it will not be taken into account when backtesting.

          Lastly, while there may be third party vendors that supply such add-ons, I'm unaware of any in particular, nor can I recommend any particular third party vendor for compliance reasons. I'd encourage you to do a quick internet search for those particular items as you may find a third party with these available.

          Please let me know if I can be of further assistance.
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            Hi Kate,

            About this : " When using live data, whether you're using your live account or a sim account, or using Market replay data, spread calculations use the bid-ask series and are calculated from that. To see information similar to what's shown after a backtest when running a strategy on live data or market replay, right click on the chart and select Strategy Performance > StrategyName. You'll get essentially the same info you get when backtesting."

            It struck me that, in a chart , Data Series> Days to Load, has precedence over the number of days that will appear as the boundary of the "Strategy Performance> Historical" consolidated results. I tested it, and when the number of Days to Load data is changed, the starting date of the historical report "Strategy Performance> Historical" also changes.

            Q1- Does that mean the Historical data loaded using chart Data Series contains the broker Bid/Ask data (Spread)? If so, if the target is to collect historical accurate data of a strategy in the recent past, Is it correct to say it would be more accurate (1) to retrieve data from starting a Forward DEMO testing directly over a chart loaded with (ie) the last 21 days, and in the sequence, Open the "Strategy Performance option and look at the Historical data, than to (2) Start a Strategy Analyzer from the Command Center, since (1) has Spread data from broker and (2) does not have Spread data?

            Q2- Is that what you meant above by "programming their strategy specifically to use bid and ask data (assuming you have that data available)" ?


            Thanks much,
            G



            PS ( Edited) - I wrote the post above, before realizing you have answered my penultimate post. Thanks very much for your detailed answers! Much appreciated indeed! In any case, I think my post immediately above still stands as potentially true. Reason: specially while taking into account your detailed explanations, it would seem even more strange that NT8 would mix the two report scenarios at the same Analysis display, meaning Historical analysis based on bid data and Real Time analysis based on Bid/Ask (Spread) coming out mixed if you choose the option Real Time & Historical from the Strategy Performance Menu ...

            I am crossing my fingers that Historical option at Strategy Performance while running the strategy In Real Market or DEMO mode will also contain broker Bid/Ask data for the time frame loaded via the option Data Series> Days to Load at the chart. Can you comment on that?

            Thanks,
            G
            Last edited by bouncetherubble; 10-22-2019, 04:08 PM.

            Comment


              #7
              Hello bouncetherubble,

              Thank you for your reply.

              The Real Time & Historical option will be a combination of the two - historical will be on bid, and live will be based on bid/ask depending on buy or sell. You would need to specifically program your strategy to handle Historical data, either by adding a historical bid and historical ask series if you have the data for that, OR by using Tick Replay. Here's an example of a recent indicator I created that calculates the current spread, but also plots the spread at the close of each historical bar. To use it, you'll need to turn on tick replay.

              If you open this up, you'll see how the code in OnBarUpdate is split into two - one chunk processes our historical data that we access via Tick Replay in the OnMarketData event, but on live we're no longer needing the Tick Replay data, so once we're processing the live data we can use the GetCurrentBid() and GetCurrentAsk() instead. You could definitely incorporate this into a strategy that you would then backtest using the Strategy Analyzer.

              Please let us know if we may be of further assistance to you.

              Attached Files
              Kate W.NinjaTrader Customer Service

              Comment


                #8
                Hi Kate,

                Thanks VM indeed for Sharing! If I can make this work on my end , my concern with the load of brokerSpread in Backtesting will be over, I hope. In spite of my concern, I was looking at your Indicator results and surprisingly FXCM stands for what they advertise at https://www.fxcm.com/, the EURUSD spread is around 0.1 PIP all through the day, not sure if all entry level customers have access to this Spread.

                Anyway, Can you give me an example how can I incorporate the Forex Spread indicator data to a Strategy to be able to use the Bid/Ask data for backtesting? I know this must be through the options opening at Input and Variables, but not sure what Options to navigate. In addition, Is there anyway to also make it work for the results made available via ( Chart right click) Strategy Performance> Historical? Or only through the Strategy Builder+ Backtesting method?



                Click image for larger version

Name:	strategy.png
Views:	483
Size:	80.9 KB
ID:	1075494

                Thanks much indeed
                G
                Attached Files

                Comment


                  #9
                  Hello bouncetherubble,

                  Thank you for your reply.

                  You would not be able to accomplish something similar using the Strategy Builder. If you're wanting to use the Strategy Builder, you would need to use the slippage or commission methods to simulate the spread. This logic would require manual coding.

                  While you could adapt the code from the indicator I provided, I think you may find it simpler a 1 tick ask and 1 tick bid series to the script, and use the BarsInProgress index of the ask series for buy orders and BarsInProgress index of the bid series for sell orders.

                  Below is a link to a reference sample that demonstrates adding series.
                  https://ninjatrader.com/support/help...ipt_strate.htm

                  Using Historical Bid-Ask series: https://ninjatrader.com/support/help..._ask_serie.htm

                  The most useful thing in the indicator would be showing how to process the historical data separately from the real time data, as you'll need similar handling in on bar update. When your script is calculating historical data, you'll want to ensure any buy orders are placed to the ask, sells to the bid, and that in realtime processing the orders are routed to the primary real time data series.

                  Should you require assistance in manually coding this strategy, I'd be happy to have one of our Business Development team reach out with information regarding NinjaScript Consultants who would be happy to assist you with your code or create the strategy for you.

                  Please let us know if we may be of further assistance to you.
                  Kate W.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Kate,

                    Apologies, I missed your reply at Thursday morning.

                    I think I need to accept your suggestion about a Consulting. However I’d expect the outcome of the consulting ( the code) to be applicable, via Strategy Analyzer Menu, as an add-on, to any future Strategy that is built or runs at the NT8 Strategy Analyzer , since it would be looking at Historical intrabar data (using the approach you shared at your last post). Is this what the outcome of the paid Consulting? It would be impossible to pay for a custom code to be built each time a new strategy needs to be tested...

                    If this is feasible , such development must already exist, as an off-the-shelf tool for NT8, since this is a key problem that has already been discussed in a number of posts in the Forum, such as in these very long and incredibly complex posts below by ChelseaB.

                    Q1- It would be really awesome to have access to a NT8 partner that already has the tool developed.



                    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.



                    What I learnt Our previous exchanges and from these posts above from ChelseaB is that:

                    1) Backtesting using Strategy Analyzer:
                    • behaves ideally, does not compute Slippage unless included as parameter ( and etc)
                    • runs on separate historical data records
                    • does not have intrabar granularity by default , hence, cannot run on actual Ask/Bid data
                    • some backtesting method may run on intrabar data via script development or maybe via some off-the-shelf tool by a NT8 partner ( TBV).

                    At this point, I’d expect Strategy Analyzer would not change any results when the settings below were modified , but I got 4 different results from the same strategy running of EURUSD Range4 Chart. As you can see below, the most profitable scenario happened at ( Case 2) , with Tick replay ON and Strategy setting "Calculate On Each Tick" , which is probably the correct way to backtest Historical data ...?
                    (a) Chart> Data Series> Tick Replay> ON/OFF )
                    (b) Strategies>SetUp> Calculate> On Each Tick/On Bar Close


                    Q2- Is it recommendable to always run all backtesting strategies with Tick replay ON and Strategy setting "Calculate On Each Tick"?

                    Q3- It appears these settings affect only the indicator instant updates and do not make a difference for simulating trades at the correct Ask/Bid price points correct? Anyway, using these settings have a huge effect on the strategy results, although, still not possible to know how much of the results are actually true.




                    Case 1 - 4Range_No Tick Replay_Strategy Settup Calculate on_EACH TICK

                    Click image for larger version

Name:	4Range_No Tick Replay_Strategy Settup Calculate on_EACH TICK_2019_10_27_18_38_51_Strategy_Performance_AMAMAMINE_EURUSD.png
Views:	500
Size:	50.9 KB
ID:	1075833



                    Case2 - 4Range_WITH Tick Replay_Strategy Setup Calculate on_EACH TICK

                    Click image for larger version

Name:	4Range_WITH Tick Replay_Strategy Setup Calculate on_EACH TICK_2019_10_27_18_38_51_Strategy_Performance_AMAMAMINE_EURUSD.png
Views:	407
Size:	51.6 KB
ID:	1075834



                    Case3 - 4Range_NO Tick Replay_Strategy Setup Calculate ON_BAR CLOSE

                    Click image for larger version

Name:	4Range_NO Tick Replay_Strategy Setup Calculate ON_BAR CLOSE_2019_10_27_18_38_51_Strategy_Performance_AMAMAMINE_EURUSD.png
Views:	379
Size:	49.5 KB
ID:	1075835





                    Case4 - 4Range_WITH Tick Replay_Strategy Setup Calculate on_BAR CLOSE

                    Click image for larger version

Name:	4Range_WITH Tick Replay_Strategy Setup Calculate on_BAR CLOSE_2019_10_27_18_38_51_Strategy_Performance_AMAMAMINE_EURUSD.png
Views:	405
Size:	49.6 KB
ID:	1075836





                    2) Analysis via Market Replay - data recorded cannot be used by Strategy Analyzer!

                    Hence:
                    • Market Replay conveys Real Market behavior with recorded Slippage and Intrabar granularity
                    • Market Replay has intrabar granularity , but it cannot be used by the Strategy Analyzer!


                    Q4- Why Market Replay as being "recorded data", cannot simply be Fast-Forwarded when requested by the user and achieve the best of both worlds? Speed and Fast backtesting results from fast forwarded connection and accuracy of the recorded market? That would address the lack of intrabar granularity analysis at Strategy Analyzer. Only difference would be backtesting Summary would appear as real time data and not as Historical.



                    3) Real Market ( Real Money & SIM101) – Self- Explanatory




                    Thanks Much indeed,
                    G



                    Comment


                      #11
                      Hello bouncetherubble,

                      Thank you for your reply.

                      We cannot make specific recommendations for third party vendors, nor would I be able to tell you exactly what they may be able to create for you. However, I will have a member of our business development team reach out with options for third party NInjaScript Consultants.

                      It would not be recommended to run all backtests OnEachTick and with TickReplay enabled. Some strategies are not set up to be run this way. Also, running a strategy OnEachTick or with Tick Replay enabled can have a large performance impact, so choosing to run backtests in this way may be somewhat dependent on what your individual PC can handle. Tick Replay would not affect when a trade is entered, that's correct.

                      You can certainly achieve similar results to a backtest in the Strategy Analyzer using Market Replay data and the Playback connection. You can speed up the Market Replay to Max and then view the Strategy outcome at the end by right clicking the Chart and selecting Strategy Performance.

                      Please let us know if we may be of further assistance to you.
                      Kate W.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi Kate

                        Ok Thanks much for all information provided!

                        About Playback connection, I realized while using a strategy based on Heiken Ashi , that Market Replay dial button selected won't allow the Strategy to "stick"as selected at the Control Center checkbox. It will accept the selection and then de-select it on itself... After trying al possible combinations, I moved to Playback Historical dial button, and it was possible to run the Heiken Ashi strategy in this mode.

                        Any particular reason for that to happen with Heiken Ashi in Playback mode?

                        Man thanks indeed,
                        G

                        Comment


                          #13
                          Hello bouncetherubble,

                          Thank you for your reply.

                          When a strategy immediately disables itself when you enable it, this is generally due to an error in processing causing the strategy to stop itself immediately. When you try to use the strategy with Market Replay data, do you receive an error in the Log tab of the Control Center? If so, what is the text of the error?

                          Thanks in advance; I look forward to resolving this for you.
                          Kate W.NinjaTrader Customer Service

                          Comment


                            #14
                            Hi Kate,

                            I was to investigate the Market Replay problem, but the whole Playback mode is now compromised after what it appears to be one of those Windows10 overnight patches. Earlier today NT8 was buggy and I cleaned the database and the DB folder but a little later NT8 crashed, and I realized I had to reset the machine. When the laptop booted, there were some different Windows related login options (the PIN dashboard was unavailable and there was some new Windows Hello login messages).

                            Anyway, NT8 back to normal, except Playback mode still troubled.When NT starts, no problem; Playback mode will launch normally, and it can be used normally if you just hit the PLAY button, but any attempt to swing back the slider ( Rewind in time) will freeze NT8. If NT8 is restarted, then again normal, the PLAY can be use. Second time around I tried to change from Historical (Seems Historical loads by default) to Market Replay and again NT8 has frozen ... I am here writing this for 10 minutes and the Playback windows is still grayed and NT8 is frozen, so it is not a matter of waiting some process to end. Apologies to mix subjects, but to answer the question at your previous post, I need to fix this before.

                            Do you think renaming the Config.xml under C:>Documents>NinjaTrader8 and restarting NT8 would solve that problem?

                            Many Thanks,
                            G

                            Comment


                              #15
                              Hi Kate

                              In addition, Does the Speed that the Playback mode is run ( at Market Replay or Historical), does that affect the results? Running 1000x faster or MAX, maybe can create data collisions or collisions between the laptop processing and data , etc ... ?

                              Is there a recommended maximum speed to run Playback , safely?

                              Thanks much,
                              G

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by yertle, Today, 08:38 AM
                              6 responses
                              24 views
                              0 likes
                              Last Post ryjoga
                              by ryjoga
                               
                              Started by algospoke, Yesterday, 06:40 PM
                              2 responses
                              24 views
                              0 likes
                              Last Post algospoke  
                              Started by ghoul, Today, 06:02 PM
                              3 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              46 views
                              0 likes
                              Last Post jeronymite  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              7 responses
                              23 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X