Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BackTest MACD

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

    BackTest MACD

    I would like to backtest going long or short when the MACD D Crosses Over or Under on a 0
    i want to know the diffrence between Walk Forward Optimization, Optimizer and BackTest and what is the role of the parameters (it's not clair for me) and how can i use it in my case, Thanks
    I use NinjaTrader 7.
    protected override void OnBarUpdate()
    {

    if(Historical){
    return ;
    }
    double value = MACD(fast, slow, smooth).Diff[0];
    if((value>0 && OpenOrder==null){
    {
    EnterLong(10, "O_MACDL");
    }

    if((value<0 && old_value>value) && OpenOrder!=null )
    {
    if(OpenOrder.OrderState.ToString()=="Filled")
    {

    ExitLong("C_MACDL,OpenOrder.Name);

    }
    }
    }

    #2
    Hello soma8,

    Thanks for your post.

    Please review the helpguide links below for an understanding of the differences and the use of.

    Backtest - A backtest allows you to analyze the historical performance of a strategy.
    Link to helpguide on running a backtest: http://ninjatrader.com/support/helpG...a_strategy.htm

    Optimize - Optimization is the process of testing a range of values through iterative backtests to determine the optimal input values over the historical test period based on your best result criterion.
    Link to helpguide on Optimize a strategy: http://ninjatrader.com/support/helpG...a_strategy.htm

    Walk forward - optimization is the process by which you optimize strategy input parameters on a historical segment of market data, then test the strategy forward in time on data following the optimization segment using the optimized input values. The central idea is that you evaluate strategy performance data on the test data, not the data used in the optimization. This process is then repeated by moving the optimization and test segments forward in time.
    Link to helpguide on Walkforward optimization: http://ninjatrader.com/support/helpG...e_a_strate.htm

    Note: As the backtest process uses only historical data, your first statement "if (Historical) {return;} would prohibit backtest functionality so you would need to comment that statement out for backtesting.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you,

      I commented "if (Historical) {return;}"
      Can you please explain how can i use the parameters for my code?

      Comment


        #4
        Hello soma8,

        Thanks for your reply.

        In a nutshell, for example, with reference to your MACD variables of fast, slow, smooth you can opitimize over a range that you can set. Please review the video: http://ninjatrader.com/support/movie...A-Strategy.htm

        I recommend that you go through all of the previous links before jumping into optimizing to help you understand backtesting first.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Shansen, 08-30-2019, 10:18 PM
        24 responses
        942 views
        0 likes
        Last Post spwizard  
        Started by Max238, Today, 01:28 AM
        0 responses
        9 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by rocketman7, Today, 01:00 AM
        0 responses
        4 views
        0 likes
        Last Post rocketman7  
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        28 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        33 views
        0 likes
        Last Post wzgy0920  
        Working...
        X