Spread Order management (Page 2) - NinjaTrader Programming | futures.io
futures.io futures trading

Go Back   futures.io

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming

Spread Order management
Started:November 25th, 2015 (09:02 AM) by ural01 Views / Replies:441 / 11
Last Reply:November 29th, 2015 (03:46 AM) Attachments:0

Welcome to futures.io.

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

Spread Order management

Old November 27th, 2015, 07:12 AM   #11 (permalink)
Trading Apprentice
Gomel + Belarus
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: NQ, CL
Posts: 18 since Sep 2015
Thanks: 3 given, 9 received

Multi-Time Frame entry/exit

@ural01, it works for me

#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;

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
    /// <summary>
    /// </summary>
    public class VzSpread : Strategy
        #region Variables
        // User defined variables (add any user defined variables below)
		private string secondaryInstrument = "TF 12-15"; // <- type here your instrument name
		private PeriodType secondaryPeriodType = PeriodType.Minute;
		private int secondaryPeriodValue = 10;
		private int quantity = 1;
		private double profit = 200;
		private double loss = 100;
		const int PRIMARY_INDEX = 0;
		const int SECONDARY_INDEX = 1;

        /// <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;
            Add(secondaryInstrument, secondaryPeriodType, secondaryPeriodValue);

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
			if (!Historical) return;
			// enter
			if (Position.MarketPosition == MarketPosition.Flat) {
				EnterLong(PRIMARY_INDEX, quantity, "primaryInstrumentLong");
				EnterLong(SECONDARY_INDEX, quantity, "secondaryInstrumentLong");
			// exit
			double profitLoss = Position.GetProfitLoss(Close[0], PerformanceUnit.Currency);
			if (profitLoss > profit || profitLoss < -loss) {

        #region Properties

Reply With Quote
The following user says Thank You to vadzzim for this post:

Old November 29th, 2015, 03:46 AM   #12 (permalink)
Elite Member
Colorado Springs, CO
Futures Experience: Master
Platform: NinjaTrader
Favorite Futures: Currency Futures
ural01's Avatar
Posts: 17 since Mar 2010
Thanks: 8 given, 0 received

Thank you , i find the problem
you have to point to data series if (BarsInProgress==0) or 1
in order to exit at same time

Reply With Quote


futures.io > Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming > Spread Order management

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional order to close options spread help Martzee IB Trader Workstation 1 May 24th, 2015 11:17 AM
Order management Zwaen Traders Hideout 7 December 20th, 2012 11:41 AM
Order Management Question MWinfrey NinjaTrader Programming 2 February 16th, 2012 01:42 PM
Order Management togier Traders Hideout 4 April 10th, 2011 12:25 PM
Order Management Strategy Rohok NinjaTrader Programming 4 January 26th, 2010 12:16 AM

All times are GMT -4. The time now is 03:13 PM.

Copyright © 2016 by futures.io. 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.
no new posts

Page generated 2016-10-27 in 0.07 seconds with 19 queries on phoenix via your IP