Programming issue - NinjaTrader | futures io social day trading
futures io futures trading


Programming issue
Updated: Views / Replies:580 / 2
Created: by crazygarnett 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
 

Programming issue

  #1 (permalink)
Elite Member
Stuttgart+Germany
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES
 
Posts: 2 since Jun 2012
Thanks: 0 given, 0 received

Programming issue

Hi

I was wondering if someone can help me with Ninja code. I am new in the programming and trying to create my first strategy and have following issue. I want to set as Trailing Stop and exit condition, respectively "Chandelier Stop" but it does not react at all. What is wrong with this code? Would appreciate any help.

#region Variables
// Wizard generated variables
private double multi = 1.75; // ATR Multiplier
private int period = 1; // ATR Period
private double ch_Mulit = 3; // Chandelier Multiplier
private int ch_Period = 10; // Chandelier Period
private int stop_Loss = 25; // Initial Stop Loss
// 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()
{
Add(Bollinger(2, 20));
Add(Bollinger(2, 20));
Add(ATR(Period));
Add(Bollinger(2, 20));
Add(Bollinger(2, 20));
Add(ATR(Period));
SetStopLoss("", CalculationMode.Ticks, Stop_Loss, false);

CalculateOnBarClose = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (Bollinger(2, 20).Upper[0] - Bollinger(2, 20).Lower[0]
< Multi * ATR(Period)[0]
&& CrossAbove(Close, Bollinger(2, 20).Upper, 1))
{
EnterLong(DefaultQuantity, "");
}

// Condition set 2
if (Bollinger(2, 20).Upper[0] - Bollinger(2, 20).Lower[0]
< Multi * ATR(Period)[0]
&& CrossBelow(Close, Bollinger(2, 20).Lower, 1))
{
EnterShort(DefaultQuantity, "");
}

// Condition set 3
if (CrossBelow(Close, ChandelierStop(Ch_Period, Multi).ChandelierLo, 1))
{
ExitLong("", "");
}

// Condition set 4
if (CrossAbove(Close, ChandelierStop(Ch_Period, Multi).ChandelierHi, 1))
{
ExitShort("", "");
}
}

#region Properties
[Description("ATR Multiplier for Entry Signal")]
[GridCategory("Parameters")]
public double Multi
{
get { return multi; }
set { multi = Math.Max(1, value); }
}

[Description("ATR Period for Entry Signal")]
[GridCategory("Parameters")]
public int Period
{
get { return period; }
set { period = Math.Max(1, value); }
}

[Description("Chandelier Mulitplier for Trailing Stop")]
[GridCategory("Parameters")]
public double Ch_Mulit
{
get { return ch_Mulit; }
set { ch_Mulit = Math.Max(1, value); }
}

[Description("Chandelier Period for Trailing Stop")]
[GridCategory("Parameters")]
public int Ch_Period
{
get { return ch_Period; }
set { ch_Period = Math.Max(1, value); }
}

[Description("Initial Stop Loss")]
[GridCategory("Parameters")]
public int Stop_Loss
{
get { return stop_Loss; }
set { stop_Loss = Math.Max(1, value); }
}
#endregion
}
}

Reply With Quote
 
  #2 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,572 given, 3,982 received

First, in Initialize(), you only need these two:
 
Code
                            
Add(Bollinger(220));
Add(ATR(Period)); 
no need to add more "Add()" .

To check what's wrong with your exit condition, you may add some Print():
 
Code
                            
Print("Stop: "+ChandelierStop(Ch_PeriodMulti).ChandelierLo1));
Print(
"Stop: "+ChandelierStop(Ch_PeriodMulti).ChandelierHi1)); 
in the OnBarUpdate().
Then using Market Replay data feed, you'll quickly see what's wrong.

Success requires no deodorant! (Sun Tzu)

Last edited by sam028; December 31st, 2012 at 10:06 AM.
Reply With Quote
The following 2 users say Thank You to sam028 for this post:
 
  #3 (permalink)
Elite Member
Stuttgart+Germany
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES
 
Posts: 2 since Jun 2012
Thanks: 0 given, 0 received


Hi sam028

Thank you for your reply and your help.

Reply With Quote

Reply



futures io > > > > Programming issue

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
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Programming (programming without coding) LukeGeniol Platforms and Indicators 11 September 16th, 2016 01:49 PM
download issue? dbarno NinjaTrader 4 October 21st, 2012 09:32 AM
Need help for Expert Advisor Programming Issue excalibur7 The Elite Circle 2 November 29th, 2011 08:36 AM
OnMarketData serious issue baberg NinjaTrader Programming 13 September 27th, 2011 10:04 AM
Arcade Issue!!!! RJay Off-Topic 1 July 21st, 2009 03:01 PM


All times are GMT -4. The time now is 09:50 PM.

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-12 in 0.09 seconds with 25 queries on phoenix via your IP 54.221.93.187