NexusFi: Find Your Edge


Home Menu

 





VIDEO TUTORIAL: How to create an advanced NinjaTrader Strategy


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one calhawk01 with 10 posts (1 thanks)
    2. looks_two Big Mike with 9 posts (193 thanks)
    3. looks_3 stephenszpak with 6 posts (0 thanks)
    4. looks_4 spinnybobo with 6 posts (2 thanks)
      Best Posters
    1. looks_one Big Mike with 21.4 thanks per post
    2. looks_two piersh with 8 thanks per post
    3. looks_3 zeller4 with 7 thanks per post
    4. looks_4 Cloudy with 1.5 thanks per post
    1. trending_up 86,235 views
    2. thumb_up 231 thanks given
    3. group 61 followers
    1. forum 67 posts
    2. attach_file 3 attachments




 
Search this Thread

VIDEO TUTORIAL: How to create an advanced NinjaTrader Strategy

  #51 (permalink)
 calhawk01 
baltimore marylnd
 
Experience: Beginner
Platform: ninja
Trading: es
Posts: 91 since May 2013
Thanks Given: 5
Thanks Received: 11


spinnybobo View Post
Hey,

Ok, I know what you mean now. So, I think in order to access the entry price, you need to create an IOrder object.

 
Code
private IOrder _entry = null;

//then you can do this
_entry = EnterLong("tag you want to give");

//then later you can do this
if (High[0] >= (target1 * TickSize))
SetStopLoss(CaculationMode.Price, (_entry.AvgFillPrice);
I did not try it out yet. Look at Scott Shodsons Ninja Trader webinars. He uses IOrders a lot.
He has 2 webinars. They are very good.

 
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>
    /// Big Mike - 1/26/10 - https://nexusfi.com/beginners-introductions-tutorials/2512-video-tutorial-how-create-advanced-ninjatrader-strategy.html
    /// </summary>
    [Description("Make me millions Jan 27 2010")] //modified by Spencer Davis as a simple template 05/30/2013.  
    public class MyMoneyMaker_BigMike : Strategy
    {
        
		
		private int		_target1			= 12;
		private int		_target2			= 10;
		private int		_target3			= 24;
		private int		_stop			= 12;
		
		private IOrder _entry = null;
		
        protected override void Initialize()
        {
            CalculateOnBarClose = true;
			EntryHandling		= EntryHandling.UniqueEntries;
        }
		
		private void GoLong()
		{
			SetStopLoss("Enter_Position", CalculationMode.Price, Close[0] - (Stop*TickSize), false);

			_entry = EnterLong("Enter_Position");
		}
		
		private void ManageOrders()
		{
			if (Position.MarketPosition == MarketPosition.Long)
			{
				if(High[0] >= (_target1 * TickSize))
					SetStopLoss(CalculationMode.Price, _entry.AvgFillPrice);
				else if (High[0] >= (_target2 * TickSize))
					SetStopLoss(CalculationMode.Price, (_entry.AvgFillPrice + (_target1 * TickSize)));
				else if (High[0] >= (_target3 * TickSize))
					SetStopLoss(CalculationMode.Price, (_entry.AvgFillPrice + (_target2 * TickSize)));
			}
		}

        protected override void OnBarUpdate()
        {
            EntryHandling		= EntryHandling.UniqueEntries;
			ManageOrders();
			
			if (Position.MarketPosition != MarketPosition.Flat) return;
			
			//if ( enter reason for going long here ) 
			//	GoLong();
			
        }

		[Description("")]
        [Category("Parameters")]
        public int Target1
        {
            get { return _target1; }
            set { _target1 = Math.Max(1, value); }
        }
		[Description("")]
        [Category("Parameters")]
        public int Target2
        {
            get { return _target2; }
            set { _target2 = Math.Max(1, value); }
        }
		[Description("")]
        [Category("Parameters")]
        public int Target3
        {
            get { return _target3; }
            set { _target3 = Math.Max(1, value); }
        }
		[Description("")]
        [Category("Parameters")]
        public int Stop
        {
            get { return _stop; }
            set { _stop = Math.Max(1, value); }
        }
    }
}
hope this helps

I will code something later and test it.
Spencer

Spencer, I'm at work right now so won't be able to test it till later. Thank you for the help Spencer!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
What broker to use for trading palladium futures
Commodities
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
MC PL editor upgrade
MultiCharts
 
  #52 (permalink)
 
spinnybobo's Avatar
 spinnybobo 
Crete, IL/USA
 
Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Trading: ES, CL, EUR/USD, TF
Posts: 173 since Aug 2009
Thanks Given: 105
Thanks Received: 61

hmm, actually I am still new to Ninjascript. It seems like Position.AvgPrice is the average representation of the fill price. from the documentation

 
Code
{
    // Raise stop loss to breakeven when there is at least 10 ticks in profit
    if (Close[0] >= Position.AvgPrice + 10 * TickSize)
         ExitLongStop(Position.Quantity, Position.AvgPrice);
}
So, we probably don't need IOrder, but I hear that most professionals will only use them with real live strategies. We can always take IOrder out and replace _entry.AvgFillPrice with Position.AvgPrice and just add a simple SMA cross strategy or something.

Follow me on Twitter Reply With Quote
  #53 (permalink)
 calhawk01 
baltimore marylnd
 
Experience: Beginner
Platform: ninja
Trading: es
Posts: 91 since May 2013
Thanks Given: 5
Thanks Received: 11



spinnybobo View Post
hmm, actually I am still new to Ninjascript. It seems like Position.AvgPrice is the average representation of the fill price. from the documentation

 
Code
{
    // Raise stop loss to breakeven when there is at least 10 ticks in profit
    if (Close[0] >= Position.AvgPrice + 10 * TickSize)
         ExitLongStop(Position.Quantity, Position.AvgPrice);
}
So, we probably don't need IOrder, but I hear that most professionals will only use them with real live strategies. We can always take IOrder out and replace _entry.AvgFillPrice with Position.AvgPrice and just add a simple SMA cross strategy or something.


you're correct about position.avgprice

Reply With Quote
  #54 (permalink)
 
spinnybobo's Avatar
 spinnybobo 
Crete, IL/USA
 
Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Trading: ES, CL, EUR/USD, TF
Posts: 173 since Aug 2009
Thanks Given: 105
Thanks Received: 61

Hey calhawk01

I think this code pretty much works.
I did not use IOrders. You can always take out the reason to get long or short. You can also play with the drawLine things.
However, I believe it works or at least it is a general outline to what you were looking for

take care
Spencer

 
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
{
    /*
	Author:  Spencer Davis
	This is an outline Trade Management strategy for using dynamic stops and targets
	*/
    [Description("A strategy that trails the stops")]
    public class sdTM : Strategy
    {
		//periods
		private int fastPeriod = 8;
		private int slowPeriod = 34;
		
		//trade management
		private int stopLoss = 18;
		private int target1 = 10;
		private int target2 = 20;
		private int target3 = 30;
		private SMA fastSMA;
		private SMA slowSMA;
		
		private bool drawStop = false;
		
        
        protected override void Initialize()
        {
		CalculateOnBarClose = true;
		EntryHandling = EntryHandling.UniqueEntries;
		fastSMA = SMA(FastPeriod);
		slowSMA = SMA(SlowPeriod);
		Add(slowSMA);
		Add(fastSMA);
		fastSMA.Plots[0].Pen.Width = 2;
		fastSMA.Plots[0].Pen.Color = Color.Green;
		slowSMA.Plots[0].Pen.Width = 2;
		slowSMA.Plots[0].Pen.Color = Color.Red;
			
        }

        protected override void OnBarUpdate()
        {
		if (CurrentBar < 20) return; //make sure there is enough data

		//buy conditions
		if (CrossAbove(SMA(FastPeriod), SMA(SlowPeriod), 1)&& Flat)
			GoLong();
		else if (CrossBelow(SMA(FastPeriod),SMA(SlowPeriod),1) && Flat)
			GoShort();			
		ManageTrade();
        }
	private void ManageTrade()
	{
		if(Long)
		{
			if (!drawStop)
				this.DrawLine("StopLine"+CurrentBar, true, 0, (Position.AvgPrice - StopLoss*TickSize), -8, (Position.AvgPrice -StopLoss*TickSize), Color.Red, DashStyle.Dash, 2);				
				
			if (High[0] >= (Position.AvgPrice + Target1*TickSize) && High[0] < (Position.AvgPrice + Target2*TickSize))
			{
				SetStopLoss("EntryLong", CalculationMode.Price, Position.AvgPrice, false);
				this.DrawLine("BreakEvenLong"+CurrentBar,true,0,(Position.AvgPrice + Target1*TickSize), -8, (Position.AvgPrice + Target1*TickSize), Color.Gray, DashStyle.Dash, 2);
			}
			if (High[0] >= (Position.AvgPrice + Target2*TickSize)&& High[0] < (Position.AvgPrice + Target3*TickSize))
			{
				SetStopLoss("EntryLong", CalculationMode.Price, Position.AvgPrice + Target1*TickSize, false);
				this.DrawLine("Target1Long"+CurrentBar,true,0,(Position.AvgPrice + Target2*TickSize), -8, (Position.AvgPrice + Target2*TickSize), Color.Green, DashStyle.Dash, 2);
			}
			if (High[0] >= (Position.AvgPrice + Target3*TickSize))
			{
				ExitLong(1, "Exiting Long", "EntryLong");
				this.DrawLine("Target2Long"+CurrentBar,true,0,(Position.AvgPrice + Target3*TickSize), -8, (Position.AvgPrice + Target3*TickSize), Color.Green, DashStyle.Dash, 2);
			}
			drawStop = true;	
		}
		if(Short)
		{
			if (!drawStop)
				this.DrawLine("StopLine"+CurrentBar, true, 0, (Position.AvgPrice + StopLoss*TickSize), -8, (Position.AvgPrice + StopLoss*TickSize), Color.Red, DashStyle.Dash, 2);				

			if (Low[0] <= (Position.AvgPrice - Target1*TickSize)&& Low[0] > (Position.AvgPrice - Target2*TickSize))
			{
				SetStopLoss("EntryShort", CalculationMode.Price, Position.AvgPrice, false);
				this.DrawLine("BreakEvenShort"+CurrentBar,true,0,(Position.AvgPrice - Target1*TickSize), -8, (Position.AvgPrice - Target1*TickSize), Color.Gray, DashStyle.Dash, 2);
			}
			if (Low[0] <= (Position.AvgPrice - Target2*TickSize)&& Low[0] > (Position.AvgPrice - Target3*TickSize))
			{
				SetStopLoss("EntryShort", CalculationMode.Price, Position.AvgPrice - Target1*TickSize, false);
				this.DrawLine("Target1Long"+CurrentBar,true,0,(Position.AvgPrice - Target2*TickSize), -8, (Position.AvgPrice - Target2*TickSize), Color.Green, DashStyle.Dash, 2);
			}
			if (Low[0] <= (Position.AvgPrice - Target3*TickSize))
			{
				ExitShort(1, "Exiting Short", "EntryShort");
				this.DrawLine("Target2Long"+CurrentBar,true,0,(Position.AvgPrice - Target3*TickSize), -8, (Position.AvgPrice - Target3*TickSize), Color.Green, DashStyle.Dash, 2);
			}
			drawStop = true;
		}
	}
	private void GoLong()
	{
		SetStopLoss("EntryLong", CalculationMode.Ticks, StopLoss, false);
		EnterLong(1, "EntryLong");
		drawStop = false;
	}
	private void GoShort()
	{
		SetStopLoss("EntryShort", CalculationMode.Ticks, StopLoss, false);
		EnterShort(1, "EntryShort");
		drawStop = false;
	}
	//returns current state of Flat, Long, or Short
	#region TradeState
	private bool Flat { get{ return Position.MarketPosition == MarketPosition.Flat; } }
	private bool Long { get{ return Position.MarketPosition == MarketPosition.Long; } }
	private bool Short { get{ return Position.MarketPosition == MarketPosition.Short; } }
	#endregion

        #region Properties
        [Description("Fast Period")]
        [GridCategory("Parameters")]
        public int FastPeriod
        {
            get { return fastPeriod; }
            set { fastPeriod = Math.Max(1, value); }
        }
		[Description("Slow Period")]
        [GridCategory("Parameters")]
        public int SlowPeriod
        {
            get { return slowPeriod; }
            set { slowPeriod = Math.Max(1, value); }
        }
		[Description("Stop Loss")]
        [GridCategory("Parameters")]
        public int StopLoss
        {
            get { return stopLoss; }
            set { stopLoss = Math.Max(1, value); }
        }
		[Description("1st Target")]
        [GridCategory("Parameters")]
        public int Target1
        {
            get { return target1; }
            set { target1 = Math.Max(1, value); }
        }
		[Description("2nd Target")]
        [GridCategory("Parameters")]
        public int Target2
        {
            get { return target2; }
            set { target2 = Math.Max(1, value); }
        }
		[Description("3rd Target")]
        [GridCategory("Parameters")]
        public int Target3
        {
            get { return target3; }
            set { target3 = Math.Max(1, value); }
        }
		
        #endregion
    }
}

Follow me on Twitter Reply With Quote
Thanked by:
  #55 (permalink)
 jlwade123   is a Vendor
 
Posts: 929 since Oct 2012
Thanks Given: 684
Thanks Received: 897


Big Mike View Post
In this video tutorial I show how to create a strategy from scratch (not using the wizard, which I never use).

The strategy contains a few optimizable parameters such as SMA length, EMA length, HMA length, three different targets with custom tick settings on each, a stop size, and the option to move target 2 to breakeven after target 1 is hit, as well as move target 3 to breakeven after target 2 is hit.

[Mike

I got the following Recursive Property error when I compiled the strategy (see code below):
Your strategy likely holds one or more recursive properties which could cause NinjaTrader to crash: EMAlength HMALENGTH TARGET1 TARGET2 TARGET3 BE2 BE3

Do you want to edit these properties?
I have attached the code I created. Please note I did not use the SMA. Can anyone please point out what I typed in wrong?

Thank you.


JLW

#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("Create a strategy with optimizable variables")]
public class testbmt : Strategy
{
private int emalength = 20;
private int hmalength = 10;

private int target1 = 12;
private int target2 = 10;
private int target3 = 18;

private int stop = 12;

private bool be2 = false;
private bool be3 = false;

/// <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;
EntryHandling = EntryHandling.UniqueEntries;
}

private void GoLong();
(
SetStopLoss("target1", CalculationMode.Price, Close(0) - (Stop*TickSize), false);
SetStopLoss("target2", CalculationMode.Price, Close(0) - (Stop*TickSize), false);
SetStopLoss("target3", CalculationMode.Price, Close(0) - (Stop*TickSize), false);

SetProfitTarget("target1", CalculationMode.Price, Close(0) + (Target1*TickSize));
SetProfitTarget("target1", CalculationMode.Price, Close(0) + (Target1+Target2*TickSize));
SetProfitTarget("target1", CalculationMode.Price, Close(0) + (Target1+Target2+Target3*TickSize));

EnterLong("target1");
EnterLong("target2");
EnterLong("target3");
)

private void GoShort()
(
SetStopLoss("target1", CalculationMode.Price,Close(0) + (Stop*TickSize), false);
SetStopLoss("target2", CalculationMode.Price,Close(0) + (Stop*TickSize), false);
SetStopLoss("target3", CalculationMode.Price,Close(0) + (Stop*TickSize), false);

SetProfitTarget("target1", CalculationMode.Price, Close(0) - (Target1*TickSize));
SetProfitTarget("target1", CalculationMode.Price, Close(0) - (Target1+Target2*TickSize));
SetProfitTarget("target1", CalculationMode.Price, Close(0) - (Target1+Target2+Target3*TickSize));

EnterShort("target1");
EnterShort("target2");
EnterShort("target3");

)

private void ManageOrders()
(
if (Position.MarketPosition == MarketPosition.Long)
(
if (BE2 && High[0] > Position.AvgPrice + (Target1*TickSize))
SetStopLoss("target2", CalculatationMode.Price, Position.AvgPrice, false);

if (BE3 && High[0] > Position.AvgPrice + ((Target1+Target2)*TickSize))
SetStopLoss("target3", CalculatationMode.Price, Position.AvgPrice, false);
)

if (Position.MarketPosition == MarketPosition.Short)
(
if (BE2 && Low[0] < Position.AvgPrice - (Target1*TickSize))
SetStopLoss("target2", CalculatationMode.Price, Position.AvgPrice, false);

if (BE3 && Low[0] < Position.AvgPrice - ((Target1+Target2)*TickSize))
SetStopLoss("target3", CalculatationMode.Price, Position.AvgPrice, false);
)
)
protected override void OnBarUpdate()
{
EntryHandling = EntryHandling.UniqueEntries;

EMA emav = EMA(EMAlength);
HMA hmav = HMA(HMAlength);

ManageOrders();

if (Position.MarketPosition != MarketPosition.Flat) return;

if (Rising(emav) && Rising(hmav));
GoLong();
else if (Falling(emav) && Falling(hmav));
GoShort;
}

#region Properties
[Description("")]
[GridCategory("Parameters")]
public int EMAlength
{
get { return EMAlength; }
set { EMAlength = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int HMAlength
{
get { return HMAlength; }
set { HMAlength = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int target1;
{
get { return target1; }
set { target1 = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int target2;
{
get { return target2; }
set { target2 = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int target3;
{
get { return target3; }
set { target3 = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int Stop;
{
get { return stop; }
set { stop = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public bool be2;
{
get { return be2; }
set { be2 = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public bool be3;
{
get { return be3; }
set { be2 = Math.Max(1, value); }
}
#endregion
}
}

Follow me on Twitter Reply With Quote
  #56 (permalink)
 
spinnybobo's Avatar
 spinnybobo 
Crete, IL/USA
 
Experience: Intermediate
Platform: NinjaTrader, Mt4
Broker: Tradestation/Tradestation, NinjaTrader, FXCM and Tallinex
Trading: ES, CL, EUR/USD, TF
Posts: 173 since Aug 2009
Thanks Given: 105
Thanks Received: 61


jlwade123 View Post
I got the following Recursive Property error when I compiled the strategy (see code below):
Your strategy likely holds one or more recursive properties which could cause NinjaTrader to crash: EMAlength HMALENGTH TARGET1 TARGET2 TARGET3 BE2 BE3

Do you want to edit these properties?
I have attached the code I created. Please note I did not use the SMA. Can anyone please point out what I typed in wrong?

Thank you.


JLW

#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("Create a strategy with optimizable variables")]
public class testbmt : Strategy
{
private int emalength = 20;
private int hmalength = 10;

private int target1 = 12;
private int target2 = 10;
private int target3 = 18;

private int stop = 12;

private bool be2 = false;
private bool be3 = false;

/// <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;
EntryHandling = EntryHandling.UniqueEntries;
}

private void GoLong();
(
SetStopLoss("target1", CalculationMode.Price, Close(0) - (Stop*TickSize), false);
SetStopLoss("target2", CalculationMode.Price, Close(0) - (Stop*TickSize), false);
SetStopLoss("target3", CalculationMode.Price, Close(0) - (Stop*TickSize), false);

SetProfitTarget("target1", CalculationMode.Price, Close(0) + (Target1*TickSize));
SetProfitTarget("target1", CalculationMode.Price, Close(0) + (Target1+Target2*TickSize));
SetProfitTarget("target1", CalculationMode.Price, Close(0) + (Target1+Target2+Target3*TickSize));

EnterLong("target1");
EnterLong("target2");
EnterLong("target3");
)

private void GoShort()
(
SetStopLoss("target1", CalculationMode.Price,Close(0) + (Stop*TickSize), false);
SetStopLoss("target2", CalculationMode.Price,Close(0) + (Stop*TickSize), false);
SetStopLoss("target3", CalculationMode.Price,Close(0) + (Stop*TickSize), false);

SetProfitTarget("target1", CalculationMode.Price, Close(0) - (Target1*TickSize));
SetProfitTarget("target1", CalculationMode.Price, Close(0) - (Target1+Target2*TickSize));
SetProfitTarget("target1", CalculationMode.Price, Close(0) - (Target1+Target2+Target3*TickSize));

EnterShort("target1");
EnterShort("target2");
EnterShort("target3");

)

private void ManageOrders()
(
if (Position.MarketPosition == MarketPosition.Long)
(
if (BE2 && High[0] > Position.AvgPrice + (Target1*TickSize))
SetStopLoss("target2", CalculatationMode.Price, Position.AvgPrice, false);

if (BE3 && High[0] > Position.AvgPrice + ((Target1+Target2)*TickSize))
SetStopLoss("target3", CalculatationMode.Price, Position.AvgPrice, false);
)

if (Position.MarketPosition == MarketPosition.Short)
(
if (BE2 && Low[0] < Position.AvgPrice - (Target1*TickSize))
SetStopLoss("target2", CalculatationMode.Price, Position.AvgPrice, false);

if (BE3 && Low[0] < Position.AvgPrice - ((Target1+Target2)*TickSize))
SetStopLoss("target3", CalculatationMode.Price, Position.AvgPrice, false);
)
)
protected override void OnBarUpdate()
{
EntryHandling = EntryHandling.UniqueEntries;

EMA emav = EMA(EMAlength);
HMA hmav = HMA(HMAlength);

ManageOrders();

if (Position.MarketPosition != MarketPosition.Flat) return;

if (Rising(emav) && Rising(hmav));
GoLong();
else if (Falling(emav) && Falling(hmav));
GoShort;
}

#region Properties
[Description("")]
[GridCategory("Parameters")]
public int EMAlength
{
get { return EMAlength; }
set { EMAlength = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int HMAlength
{
get { return HMAlength; }
set { HMAlength = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int target1;
{
get { return target1; }
set { target1 = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int target2;
{
get { return target2; }
set { target2 = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int target3;
{
get { return target3; }
set { target3 = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int Stop;
{
get { return stop; }
set { stop = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public bool be2;
{
get { return be2; }
set { be2 = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public bool be3;
{
get { return be3; }
set { be2 = Math.Max(1, value); }
}
#endregion
}
}

Hey JLW,

just to let you know, if you use

 
Code
  

//write code here
makes it look more readable.
It looks like you used () in places you should use {}

you wrote:

 
Code
private void GoShort()
(
SetStopLoss("target1", CalculationMode.Price,Close(0) + (Stop*TickSize), false);
SetStopLoss("target2", CalculationMode.Price,Close(0) + (Stop*TickSize), false);
SetStopLoss("target3", CalculationMode.Price,Close(0) + (Stop*TickSize), false);

SetProfitTarget("target1", CalculationMode.Price, Close(0) - (Target1*TickSize));
SetProfitTarget("target1", CalculationMode.Price, Close(0) - (Target1+Target2*TickSize));
SetProfitTarget("target1", CalculationMode.Price, Close(0) - (Target1+Target2+Target3*TickSize));

EnterShort("target1");
EnterShort("target2");
EnterShort("target3");

)
it should be:

 
Code
private void GoShort()
{
SetStopLoss("target1", CalculationMode.Price,Close(0) + (Stop*TickSize), false);
SetStopLoss("target2", CalculationMode.Price,Close(0) + (Stop*TickSize), false);
SetStopLoss("target3", CalculationMode.Price,Close(0) + (Stop*TickSize), false);

SetProfitTarget("target1", CalculationMode.Price, Close(0) - (Target1*TickSize));
SetProfitTarget("target1", CalculationMode.Price, Close(0) - (Target1+Target2*TickSize));
SetProfitTarget("target1", CalculationMode.Price, Close(0) - (Target1+Target2+Target3*TickSize));

EnterShort("target1");
EnterShort("target2");
EnterShort("target3");

}
This will probably give you a bunch of errors.
(....) are for functions and arguments
{....} is for blocks of code --- everything that goes inside of a method, class, namespace

Spencer

Follow me on Twitter Reply With Quote
Thanked by:
  #57 (permalink)
Wazoo
Boston, Massachusetts
 
Posts: 7 since Mar 2013
Thanks Given: 1
Thanks Received: 1

Big Mike

You mention in the video your running ninja on a virtual machine. Could you amplify on this. I guess more specifically
I am wondering if this gives some enhanced level of security for your code etc. From who, Ninja, Hackers etc.
and what virtual machine do you recommend?

Thanks
Jerry

Reply With Quote
  #58 (permalink)
maiers
Wiesbaden
 
Posts: 2 since Mar 2014
Thanks Given: 1
Thanks Received: 0


Wazoo View Post
Big Mike

You mention in the video your running ninja on a virtual machine. Could you amplify on this. I guess more specifically
I am wondering if this gives some enhanced level of security for your code etc. From who, Ninja, Hackers etc.
and what virtual machine do you recommend?

Thanks
Jerry

I am not sure if those are the reasons Big Mike does it, but the following advantages come to my mind when running it on a Virtual Machine:
1. You can run a 2. instance of NinjaTrader
2. Assuming you are connecting to a demo account on your VM: Your testing of strategies etc. won't interfere with your live trading accounts (depending on how you test this could happen if you test it on your primary NT connected to your live accounts)
Hence: you completely keep your live trading and your research separated

Reply With Quote
  #59 (permalink)
 jlwade123   is a Vendor
 
Posts: 929 since Oct 2012
Thanks Given: 684
Thanks Received: 897


Wazoo View Post
Big Mike

You mention in the video your running ninja on a virtual machine. Could you amplify on this. I guess more specifically
I am wondering if this gives some enhanced level of security for your code etc. From who, Ninja, Hackers etc.
and what virtual machine do you recommend?

Thanks
Jerry

I use Amazon S3 for free to house my Ninja data backup. I have been thinking increasing storage/memory from Amazon to use as a sandbox for my strategy development. Amazon is pretty cheap.

Follow me on Twitter Reply With Quote
  #60 (permalink)
sra18376
kansas city, ks
 
Posts: 17 since Jun 2014
Thanks Given: 0
Thanks Received: 5


great video, thanks

Reply With Quote




Last Updated on October 23, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts