Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtest: EnterLong(quanity) on XBTUSD. BitMEX

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

    Backtest: EnterLong(quanity) on XBTUSD. BitMEX

    Hi Ninja Team,

    Running backtests with a quantity of 1 (which im assuming is $1), it seems to blow up to $10,000 in 6 months.

    Doesn't seem right.

    Can someone help explain what quantity means in this case? Is it the number of contracts you buy at bitmex or is it the PRICE of XBT (or bitcoin?)


    (unrelated question: does the backtester take into account the Maker/Taker fees at Bitmex?)

    Thank you.

    #2
    What version of NinjaTrader 8 are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.0.X.0)

    Are you using a custom strategy? If so, did you program it or is it from a another source?

    Where exactly within the strategy or Strategy Analyzer window are you manipulating a property "EnterLong(quanity)"?

    Does the same issue occur if you run the Sample MA Crossover strategy?

    Comment


      #3
      Hi Patrick

      Version 8.0.14.2 64-bit.

      I programmed the strategy myself, it is a very simple one.

      Code:
      			///Short Entry - Overbought RSI
      			if ((RSI1.Default[0] >= OverboughtRSI)
      				 && (CrossBelow(RSI1.Default, RSI1.Avg, 1))
      				 && (MACD1.Diff[1] >= MACD1.Diff[0]))
      			{
      				EnterShort(1);
      				DateTime.Now = EntryTime;
      				
      			    //DateTime.Now.Ticks = EntryTime;
      				//ExpiryTime = EntryTime 
      			}
      Entire code:
      Code:
      #region Using declarations
      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.ComponentModel.DataAnnotations;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows;
      using System.Windows.Input;
      using System.Windows.Media;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Gui;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Gui.SuperDom;
      using NinjaTrader.Gui.Tools;
      using NinjaTrader.Data;
      using NinjaTrader.NinjaScript;
      using NinjaTrader.Core.FloatingPoint;
      using NinjaTrader.NinjaScript.Indicators;
      using NinjaTrader.NinjaScript.DrawingTools;
      #endregion
      
      //This namespace holds Strategies in this folder and is required. Do not change it. 
      namespace NinjaTrader.NinjaScript.Strategies
      {
      	public class MasterScalper10 : Strategy
      	{
      		private RSI RSI1;
      		private EMA EMA1;
      		private EMA EMA2;
      		//private EMA EMA3;
      		//private EMA EMA4;
      		private MACD MACD1;
      		//private MACD MACD1;
      
      		
      		
      
      		protected override void OnStateChange()
      		{
      			if (State == State.SetDefaults)
      			{
      				Description									= @"Enter the description for your new custom Strategy here.";
      				Name										= "MasterScalper10";
      				Calculate									= Calculate.OnEachTick;
      				EntriesPerDirection							= 1;
      				EntryHandling								= EntryHandling.AllEntries;
      				IsExitOnSessionCloseStrategy				= true;
      				ExitOnSessionCloseSeconds					= 30;
      				IsFillLimitOnTouch							= false;
      				MaximumBarsLookBack							= MaximumBarsLookBack.TwoHundredFiftySix;
      				OrderFillResolution							= OrderFillResolution.Standard;
      				Slippage									= 0;
      				StartBehavior								= StartBehavior.WaitUntilFlat;
      				TimeInForce									= TimeInForce.Gtc;
      				TraceOrders									= false;
      				RealtimeErrorHandling						= RealtimeErrorHandling.StopCancelClose;
      				StopTargetHandling							= StopTargetHandling.PerEntryExecution;
      				BarsRequiredToTrade							= 20;
      				// Disable this property for performance gains in Strategy Analyzer optimizations
      				// See the Help Guide for additional information
      				IsInstantiatedOnEachOptimizationIteration	= true;
      				FastEMA					= 8;
      				SlowEMA					= 55;
      				OverboughtRSI					= 70;
      				OversoldRSI					= 30;
      				SL						= 0.01;
      				TP						= 0.03;
      			}
      			else if (State == State.Configure)
      			{
      				AddDataSeries("XBTUSD", Data.BarsPeriodType.Minute, 15, Data.MarketDataType.Last);
      				AddDataSeries("XBTUSD", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
      				AddDataSeries("XBTUSD", Data.BarsPeriodType.Minute, 3, Data.MarketDataType.Last);
      				AddDataSeries("XBTUSD", Data.BarsPeriodType.Minute, 5, Data.MarketDataType.Last);
      				SetStopLoss(CalculationMode.Percent, SL);
      				SetProfitTarget(CalculationMode.Percent, TP);
      			}
      			else if (State == State.DataLoaded)
      			{				
      				RSI1				= RSI(Close, 14, 3);
      				RSI1.Plots[0].Brush = Brushes.DodgerBlue;
      				RSI1.Plots[1].Brush = Brushes.Goldenrod;
      				AddChartIndicator(RSI1);
      				EMA1				= EMA(Close, 55);
      				EMA1.Plots[0].Brush = Brushes.Goldenrod;
      				AddChartIndicator(EMA1);
      				EMA2				= EMA(Close, 8);
      				EMA2.Plots[0].Brush = Brushes.Cyan;
      				AddChartIndicator(EMA2);
      				MACD1				= MACD(Close, 12, 26, 9);
      				MACD1.Plots[0].Brush = Brushes.DarkCyan;
      				MACD1.Plots[1].Brush = Brushes.Crimson;
      				MACD1.Plots[2].Brush = Brushes.DodgerBlue;
      				//EMA3				= EMA(Closes[4], 8);
      				//EMA4				= EMA(Closes[4], 55);
      				//MACD2				= MACD(Closes[3], 12, 26, 9);
      			}
      		}
      
      		protected override void OnBarUpdate()
      		{
      			//			if (BarsInProgress != 0) 
      			//return;
      
      			//if (CurrentBars[1] < 1
      			//|| CurrentBars[2] < 1)
      			//return;
      
      			//if (BarsInProgress != 0) 
      			//return;
      
      			//if (CurrentBars[0] < 1)
      			//return;
      
      			
      						//	 
      			///Short Entry - Overbought RSI
      			if ((RSI1.Default[0] >= OverboughtRSI)
      				 && (CrossBelow(RSI1.Default, RSI1.Avg, 1))
      				 && (MACD1.Diff[1] >= MACD1.Diff[0]))
      			{
      				EnterShort(1);
      				DateTime.Now = EntryTime;
      				
      			    //DateTime.Now.Ticks = EntryTime;
      				//ExpiryTime = EntryTime 
      			}
      								
      			if (DateTime.Now.Second > EntryTime + DateTime(0, 0, 15))
      			{
      				ExitShort(1);
      			}
      			
      			///Take Profit b4 you get rekt
      			//if (DateTime.Now.Ticks > Time[3].Ticks)
      			//{
      			//}
      			
      			///15 minute take profit timer - long
      			//if (0) && (Times[1][0].TimeOfDay == Times[1][3].TimeOfDay))
      			//{
      			//ExitLong(1)
      			//}
      			
      			///15 minute take profit timer - short
      			//if (0) && (Times[1][0].TimeOfDay == Times[1][3].TimeOfDay))
      			//{
      			//ExitLong(1)
      			//}
      			
      			
      		
      			
      			///Long Entry -Oversold RSI
      			//if ((RSI1.Default[0] <= OversoldRSI)
      			//	 && (CrossAbove(RSI1.Default, RSI1.Avg, 1)))
      			//{
      			//	EnterLong(1);
      			//}
      				
      			
      		}
      
      		#region Properties
      		[NinjaScriptProperty]
      		[Range(1, int.MaxValue)]
      		[Display(Name="FastEMA", Order=1, GroupName="Parameters")]
      		public int FastEMA
      		{ get; set; }
      
      		[NinjaScriptProperty]
      		[Range(1, int.MaxValue)]
      		[Display(Name="SlowEMA", Order=2, GroupName="Parameters")]
      		public int SlowEMA
      		{ get; set; }
      
      		[NinjaScriptProperty]
      		[Range(1, int.MaxValue)]
      		[Display(Name="OverboughtRSI", Order=3, GroupName="Parameters")]
      		public int OverboughtRSI
      		{ get; set; }
      
      		[NinjaScriptProperty]
      		[Range(1, int.MaxValue)]
      		[Display(Name="OversoldRSI", Order=4, GroupName="Parameters")]
      		public int OversoldRSI
      		{ get; set; }
      
      				[NinjaScriptProperty]
      		[Range(0, int.MaxValue)]
      		[Display(Name="SL", Order=5, GroupName="Parameters")]
      		public double SL
      		{ get; set; }
      		
      				[NinjaScriptProperty]
      		[Range(0, int.MaxValue)]
      		[Display(Name="TP", Order=6, GroupName="Parameters")]
      		public double TP
      		{ get; set; }
      		#endregion
      
      	}
      }
      Thank you.

      Comment


        #4
        Hello mohdhm,

        Thank you for your response.

        The Quantity of 1 is requesting 1 contract on the instrument. There are large movements in the XBTUSD market over the last 6 months that could equate to large gains or losses depending on your strategy.

        The Strategy Analyzer does not take into account the fees from BitMex.

        Please let me know if you have any questions.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sidlercom80, 10-28-2023, 08:49 AM
        170 responses
        2,272 views
        0 likes
        Last Post sidlercom80  
        Started by Irukandji, Yesterday, 02:53 AM
        2 responses
        17 views
        0 likes
        Last Post Irukandji  
        Started by adeelshahzad, Today, 03:54 AM
        0 responses
        3 views
        0 likes
        Last Post adeelshahzad  
        Started by CortexZenUSA, Today, 12:53 AM
        0 responses
        3 views
        0 likes
        Last Post CortexZenUSA  
        Started by CortexZenUSA, Today, 12:46 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Working...
        X