new stratergy help - NinjaTrader Programming | futures io social day trading
futures io futures trading


new stratergy help
Updated: Views / Replies:4,205 / 19
Created: by benrock Attachments:1

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
 1  
 
Thread Tools Search this Thread
 

new stratergy help

  #11 (permalink)
Elite Member
Atkinson, NH USA
 
Futures Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker/Data: NinjaTrader Brokerage
Favorite Futures: Futures, CL, ES, ZB
 
NJAMC's Avatar
 
Posts: 1,925 since Dec 2010
Thanks: 2,962 given, 2,294 received


benrock View Post
im brand new to ninja , and i dont understand the inputs , can u recommend something ? i have the rest sorted out i think , just the inputs i need help with

thanks by the way

Okay,

I assume you are asking how to get the parameters from the dialog box to/from your strategy. The best thing to do is start downloading indicators and looking at how they work. I have to admit, NT doesn't document them well. You may also want to try the Strategy Wizard to have it setup the input parameters, then cut/paste those parts into your code. Also check out a few of the helper threads & webinars:
https://futures.io/elite-automated-ninjatrader-trading/11208-auto-trading-ninjatrader-7-newbies.html

Here is an example of the UI code embedded within the code (Taken from RiskReward V2 Indie):

 
Code
        #region Properties
        [Category("Parameters")]
        [Description("Size of trading account in dollars")]
        [Gui.Design.DisplayNameAttribute("1. UserAcctSize")]
        public double UserAcctSize {
            get { return userAcctSize; }
            set { userAcctSize = Math.Max(0,value); }
        }

        [Category("Parameters")]
        [Description("Percent of Account to Risk per trade Ex: 2 is 2%")]
        [Gui.Design.DisplayNameAttribute("2. UserAcctRisk (%)")]
        public double UserAcctRisk {
            get { return userAcctRisk; }
            set { userAcctRisk = Math.Max(0,value); }
        }

        [Category("Parameters")]
        [Description("Dollar Account to Risk per trade Ex: 100 is $100")]
        [Gui.Design.DisplayNameAttribute("3. DollarRisk")]
        public double UserDollarRisk {
            get { return userDollarRisk; }
            set { userDollarRisk = Math.Max(0,value); }
        }

        [Category("Parameters")]
        [Description("Fixed Share/Contract Size")]
        [Gui.Design.DisplayNameAttribute("4. FixedPositionSize")]
        public int FixedShares {
            get { return fixedShares; }
            set { fixedShares = Math.Max(0,value); }
        }

        [Category("Parameters")] // Use of Category will hide it from parameter list
        [Description("Lots Type (For Forex only).")]
        [Gui.Design.DisplayNameAttribute("5. Lots Type")]
        public FXLotsType LotsType
        {
            get { return fxLotsType; }
            set { fxLotsType = value; }
        }

.... global variables removed.....
        #endregion
The parameter section holds the UI for NT. Take the "FixedShares" public variable above. Based upon the lines above, it is stored in the "Parameters" section of the UI, with the description in the next line, but has a specific display name in the UI box (without this last line you would see just the variable name). It is defined as an "int", it uses the private variable "fixedShares" (note the lowercase "f" rather than capital "F"). Upon opening the dialog box, "fixedShares" is loaded into the dialog box. Upon closing the "value" of the parameter is set back into the variable but will have a minimum value of 0 due to the Math.Max() statement.

Hope that give you a taste, hopefully that is what you are asking.

Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Reply With Quote
The following user says Thank You to NJAMC for this post:
 
  #12 (permalink)
Banned: Vendor self-promotion
hampton bays
 
Futures Experience: Master
Platform: ninjatrader , TOS
Broker/Data: CQG
Favorite Futures: FUTURES
 
Posts: 85 since Mar 2012
Thanks: 3 given, 25 received

heres the code i wrte but im not getting any results , can anyone help ?


#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 Trend3bar : Strategy
{
#region Variables
// Wizard generated variables
// 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()
{
SetProfitTarget("", CalculationMode.Ticks, 2);
SetStopLoss("", CalculationMode.Ticks, 3, false);

CalculateOnBarClose = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar < 3) return;
//rest of the codes

// Condition set 1
if (Close[0] > Close[1]
&& Close[1] == Close[2]
&& Close[2] == Close[3])
{
}
}

#region Properties
#endregion
}
}

Reply With Quote
 
  #13 (permalink)
Elite Member
Orlando, FL
 
Futures Experience: Advanced
Platform: NinjaTrader, ToS, Sierra Chart, MCDT
Broker/Data: Interactive Brokers
Favorite Futures: ES, NQ, 6E, 6A, TF, CL
 
kojava's Avatar
 
Posts: 43 since Jan 2011
Thanks: 53 given, 28 received


I believe something like this is what you want.

 
Code
        protected override void OnBarUpdate()
        {
            if(CurrentBar < 4)
                return;

            // Sell condition
            if(Close[0] < Close[1] &&
               Close[1] < Close[2] &&
               Close[2] < Close[3])
            {
                DrawArrowDown("Down"+CurrentBar, true, 2, High[2]+TickSize, Color.Red);
            }
            
            // Buy condition
            if(Close[0] > Close[1] &&
               Close[1] > Close[2] &&
               Close[2] > Close[3])
            {
                DrawArrowUp("Up"+CurrentBar, true, 2, Low[2]-TickSize, Color.Green);
            }        
        }

Reply With Quote
The following user says Thank You to kojava for this post:
 
  #14 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,238 since Jun 2009
Thanks: 29,350 given, 83,214 received


benrock View Post
heres the code i wrte but im not getting any results , can anyone help ?

You never EnterLong() or EnterShort() in that code, thus no entries.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #15 (permalink)
Elite Member
Denver, CO
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: NinjaTrader Brokerage
Favorite Futures: ES
 
NinjaTrader's Avatar
 
Posts: 1,260 since May 2010
Thanks: 153 given, 1,890 received

We posted a 30 minute learning NinjaScript video last week, it might be helpful?

NinjaTrader 7 Tips - Learn NinjaScript Tip #1 - YouTube

Reply With Quote
 
  #16 (permalink)
Banned: Vendor self-promotion
hampton bays
 
Futures Experience: Master
Platform: ninjatrader , TOS
Broker/Data: CQG
Favorite Futures: FUTURES
 
Posts: 85 since Mar 2012
Thanks: 3 given, 25 received

ok i got it to work but i want it to wait till a new up pr down trend before it trades again .

like this in tos --- see how it gives me a buy or sell signal

Attached Thumbnails
new stratergy help-2012-04-05_1726.png  
Reply With Quote
 
  #17 (permalink)
Banned: Vendor self-promotion
hampton bays
 
Futures Experience: Master
Platform: ninjatrader , TOS
Broker/Data: CQG
Favorite Futures: FUTURES
 
Posts: 85 since Mar 2012
Thanks: 3 given, 25 received

heres what i have so far but im not getting targets i want





#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 MyCustomStrategy : Strategy
{
#region Variables
// Wizard generated variables
// 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()
{
SetProfitTarget("", CalculationMode.Ticks, 2);
SetStopLoss("", CalculationMode.Ticks, 3, false);

CalculateOnBarClose = true;
}
private bool isBuy = true;
private bool isSell = true;

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()


{if (CurrentBar < 3) return;
//rest of the codes

{
isBuy = false; //setting it to false makes sure there is no additional buys
isSell = true; //resets isSell so that buy orders can be taken
//rest of the buy order codes
}


{
isBuy = true; //resets buy so that buy orders can be taken
isSell = false; //set isSell to false so that no other sell is taken

//rest of the sell order codes
}
// Condition set 1
if (Close[0] > Close[1]
&& Close[1] > Close[2]
&& Close[2] == Close[3])
{
EnterLong(DefaultQuantity, "");
EnterShort(DefaultQuantity, "");
}
}

#region Properties
#endregion
}
}


Last edited by benrock; April 6th, 2012 at 01:34 PM.
Reply With Quote
 
  #18 (permalink)
Elite Member
Atkinson, NH USA
 
Futures Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker/Data: NinjaTrader Brokerage
Favorite Futures: Futures, CL, ES, ZB
 
NJAMC's Avatar
 
Posts: 1,925 since Dec 2010
Thanks: 2,962 given, 2,294 received


benrock View Post
heres what i have so far but im not getting targets i want





#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 MyCustomStrategy : Strategy
{
#region Variables
// Wizard generated variables
// 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()
{
SetProfitTarget("", CalculationMode.Ticks, 2);
SetStopLoss("", CalculationMode.Ticks, 3, false);

CalculateOnBarClose = true;
}
private bool isBuy = true;
private bool isSell = true;

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()


{if (CurrentBar < 3) return;
//rest of the codes
You need a condition statement here or this block of code executes for each run
{
isBuy = false; //setting it to false makes sure there is no additional buys
isSell = true; //resets isSell so that buy orders can be taken
//rest of the buy order codes
}


You need a condition statement here or this block of code executes for each run, it ultimately resets the values from above the those you have listed below
{
isBuy = true; //resets buy so that buy orders can be taken
isSell = false; //set isSell to false so that no other sell is taken

//rest of the sell order codes
}
// Condition set 1
if (Close[0] > Close[1]
&& Close[1] > Close[2]
&& Close[2] == Close[3])
{
Do you mean if (isBuy)
EnterLong(DefaultQuantity, "");
and if (isSell)
EnterShort(DefaultQuantity, "");
}
}

#region Properties
#endregion
}
}

I put some notes in your code above to help get you closer. The last block tries to enter both a long and short at the same time. Not sure what happens in NT, net is 0 orders (buy then sell really fast), but I think one gets overwritten so you are likely to aways get a short or a long depend on the sequence.

Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Reply With Quote
The following user says Thank You to NJAMC for this post:
 
  #19 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,238 since Jun 2009
Thanks: 29,350 given, 83,214 received


benrock View Post
heres what i have so far but im not getting targets i want

You need to learn some basics.

Watch the programming webinars on futures.io (formerly BMT), there are several.

Check out the Battle of the Bots thread, there are many strategies there where you can read source code and learn the basics.

Check out some of the joint project strategies in this section of the forum:
Elite Automated Trading - Big Mike's Trading Forum

All will give you countless examples of the basics of a strategy.

Or, if this is important to you and/or time sensitive, hire someone to do it for you.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #20 (permalink)
Banned: Vendor self-promotion
hampton bays
 
Futures Experience: Master
Platform: ninjatrader , TOS
Broker/Data: CQG
Favorite Futures: FUTURES
 
Posts: 85 since Mar 2012
Thanks: 3 given, 25 received


this is just me tring to learn and this is what support on the ninjatrader forum gave me to put in the code .

the best way to learn for me is to do it myself . practice and help , but thankyou

Reply With Quote

Reply



futures io > > > > > new stratergy help

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     


All times are GMT -4. The time now is 01:49 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-11 in 0.17 seconds with 19 queries on phoenix via your IP 54.226.34.209