NT7 AtmStrategy Issues - Need Help - NinjaTrader Programming | futures io social day trading
futures io futures trading


NT7 AtmStrategy Issues - Need Help
Updated: Views / Replies:386 / 3
Created: by rmdavido Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • 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.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

NT7 AtmStrategy Issues - Need Help

  #1 (permalink)
Elite Member
Jackson, MS USA
 
Futures Experience: Advanced
Platform: ThinkOrSwim
Favorite Futures: Options
 
Posts: 12 since Feb 2014
Thanks: 7 given, 0 received

NT7 AtmStrategy Issues - Need Help

Hello,

Long time lurker, first time poster. I am developing a NT strategy using an AtmStrategy but it is not acting the way I want it to. I have attached the script. I want it to basically:

A) Kill the AtmEntryOrder after 1 bar if it does not fill - currently it does not
B) Kill any open AtmStrategies and positions after 3PM - currently it does not
C) When I specify to reverse positions, it does not.

Thanks for your help.

 
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 StochScalpRANGE12 : Strategy
    {
        #region Variables
        // Wizard generated variables
		private string	orderId				= string.Empty;
		private string	atmStrategyId		= string.Empty;
		private int 	BarsPast_OE 		= 1;
		private 		DataSeries 			barcount;
        #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()
        {
			barcount = new DataSeries (this) ;

        }

		private void GoLong()
		{
			if (orderId != null)
			{
				string[] entryOrder = GetAtmStrategyEntryOrderStatus(orderId);
				if (GetAtmStrategyMarketPosition(orderId) != MarketPosition.Flat)
					return;
				
				if (entryOrder.Length > 0)
				{                   
					if (entryOrder[2].ToString() != "Filled")
					return;
				} 
				
			
			}
			orderId = GetAtmStrategyUniqueId();
			atmStrategyId = GetAtmStrategyUniqueId();
			AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "CL-Ichi", atmStrategyId);
			barcount.Set(CurrentBars[0]);
		}
		
		private void GoShort()
        {
            if (orderId != null)
            {
                string[] entryOrder = GetAtmStrategyEntryOrderStatus(orderId);               
                if (GetAtmStrategyMarketPosition(orderId) != MarketPosition.Flat)
                    return;

                if (entryOrder.Length > 0)
               { 
                    if (entryOrder[2].ToString() != "Filled")
                    return;
               }
				
            }
       
            orderId    = GetAtmStrategyUniqueId();
			atmStrategyId = GetAtmStrategyUniqueId();
            AtmStrategyCreate(Cbi.OrderAction.SellShort, OrderType.Limit, High[0], 0, TimeInForce.Day, orderId, "CL-Ichi", atmStrategyId);
			barcount.Set(CurrentBars[0]);
        }
		
		private void ExitLong()
        {
            // check to see if not flat, close all open orders
            AtmStrategyClose(orderId);
        } 
			
		private void ExitShort()
        {
            // check to see if not flat, close all open orders
            AtmStrategyClose(orderId);
		}
			
		
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
      	{
				
			if (ToTime(Time[0]) >= ToTime(15, 0, 0))
            {
            AtmStrategyClose(orderId);
            } 
			
//			Cancels Limit order LONG
			if ((CurrentBars[0] + BarsPast_OE)  > barcount[0] && GetAtmStrategyMarketPosition(orderId) == MarketPosition.Long)
			{
			AtmStrategyCancelEntryOrder(orderId);
			orderId = string.Empty;
			Print("Cancelled LONG ENTRY Order from strategy");
			}
			
//			Cancels Limit order SHORT
			if ((CurrentBars[0] + BarsPast_OE)  > barcount[0] && GetAtmStrategyMarketPosition(orderId) == MarketPosition.Short)
			{
			AtmStrategyCancelEntryOrder(orderId);
			orderId = string.Empty;
			Print("Cancelled SHORT ENTRY Order from strategy");
			}
								
			if ((ToTime(Time[0]) > ToTime(5, 30, 0)) && (ToTime(Time[0]) < ToTime(15, 0, 0)))
			{
						
				// Condition set 1
				if (CrossAbove(MACD(10, 22, 5), MACD(10, 22, 5).Avg, 1))
				{
					if (Position.MarketPosition == MarketPosition.Flat)
					{
						GoLong();
					}
					
					if (Position.MarketPosition == MarketPosition.Short)
					{
						ExitShort();
						GoLong();
					}
				}
				
				// Condition set 2
				if (CrossBelow(MACD(10, 22, 5), MACD(10, 22, 5).Avg, 1))
				{
					if (Position.MarketPosition == MarketPosition.Flat)
					{
						GoShort();
					}
					
					if (Position.MarketPosition == MarketPosition.Long)
					{
						ExitLong();
						GoShort();
					}
	        	}
					
			}
			
		}


         #region Properties
		
       	 #endregion
}
}

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Greenhorn Trader
Austin, TX
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: NT Broker
Favorite Futures: ES
 
Posts: 121 since Mar 2015
Thanks: 258 given, 68 received

what does it do and what does it not do?


@rmdavido,

sprinkle print statements in the code before and after key decision points to see what it does and that it does or does not go where you expect.

Open the Output Window when you run the strategy and watch for the output from the print statements.

Rinse, Repeat until you find where it's going wrong.


Reply With Quote
 
  #4 (permalink)
Elite Member
Jackson, MS USA
 
Futures Experience: Advanced
Platform: ThinkOrSwim
Favorite Futures: Options
 
Posts: 12 since Feb 2014
Thanks: 7 given, 0 received

So the output window says this

**NT** Submitting order with strategy 'StochScalpRANGE12/32fa0ce14438448fb4be48d2155722f1'
**NT** GetAtmStrategyMarketPosition() method error: AtmStrategyId '4ef0caf2603f4510b2b0d95ba51324f4' does not exist

and

Cancelled LONG ENTRY Order from strategy
**NT** AtmStrategyCancelEntryOrder() method error: Missing orderId parameter

Reply With Quote

Reply



futures io > > > > > NT7 AtmStrategy Issues - Need Help

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Long and Short same equity option, issues issues. rigbyrigz Options on Futures 11 April 8th, 2015 01:30 AM
Security issues starforce MetaQuotes MetaTrader MQL Programming 9 October 1st, 2013 10:11 AM
Sierra and its issues... arnie Sierra Chart 6 September 30th, 2012 07:39 AM
ATMStrategy & Strategy Wizard fesx NinjaTrader Programming 4 March 28th, 2010 11:09 PM
Having some issues with this code. Please help. kaywai NinjaTrader Programming 3 March 4th, 2010 11:33 AM


All times are GMT -4. The time now is 03:35 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@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 2017-12-16 in 0.08 seconds with 19 queries on phoenix via your IP 54.196.201.241