Bitcoin Forum
May 26, 2024, 03:05:52 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Economy / Speculation / Re: Goomboo's Journal on: April 21, 2014, 06:12:06 PM
  • Deleted the short trades and it seems now normal (profitable, at least)
  • I'm not sure how to specify that it should compound returns. Is there any option to change the strategy?
  • I'm not sure I understand the "mark-to-market PNL chart" point
  • Finally, yeah, there was a >100% lose in a short trade, I'm posting the trade if anyone is interested.

I'm still trying to get better history data but at least I got the strategy running. Thank you for the answer, I'm really learning a lot with this.
2  Economy / Speculation / Re: Goomboo's Journal on: April 21, 2014, 11:52:38 AM
Hi Goomboo, I've just discovered your post and really appreciate that you share your knowledge. I've downloaded Ninjatrader to backtest the strategy and test some other ones, but I'm not getting the expected results. Maybe you or anyone can let me see where I'm wrong.

First of all, I'm having problems getting the required format to import the data, but I found some historical data here that I am using.

Next, I created a new strategy, using the EMA 10/21 strategy. I am pasting the strategy script, maybe the mistake is there.
Code:
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class EMAcrossover2 : Strategy
    {
        #region Variables
        // Wizard generated variables
        private int short_EMA = 10; // Default setting for Short_EMA
        private int long_EMA = 21; // Default setting for Long_EMA
        // User defined variables (add any user defined variables below)
        #endregion

        /// <summary>
        /// This method is used to configure the strategy and is called once before any strategy method is called.
        /// </summary>
        protected override void Initialize()
        {

            CalculateOnBarClose = true;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            // Condition set 1
            if (EMA(Short_EMA)[0] > EMA(Long_EMA)[0]
                && EMA(Short_EMA)[1] < EMA(Long_EMA)[1])
            {
                EnterLong(DefaultQuantity, "");
                ExitShort("", "");
            }

            // Condition set 2
            if (EMA(Long_EMA)[0] > EMA(Short_EMA)[0]
                && EMA(Long_EMA)[1] < EMA(Short_EMA)[1])
            {
                EnterShort(DefaultQuantity, "");
                ExitLong("", "");
            }
        }

        #region Properties
        [Description("")]
        [GridCategory("Parameters")]
        public int Short_EMA
        {
            get { return short_EMA; }
            set { short_EMA = Math.Max(1, value); }
        }

        [Description("")]
        [GridCategory("Parameters")]
        public int Long_EMA
        {
            get { return long_EMA; }
            set { long_EMA = Math.Max(2, value); }
        }
        #endregion
    }
}

#region Wizard settings, neither change nor remove
/**/ I've omitted this since it's very long, bit I can post it if needed.
#endregion

I've backtested using the following settings:


And got the following (scary) results:




So, where is the problem?
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!