NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 11-25-2010, 07:57 AM   #1
Trade From My Recliner
Junior Member
 
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default Break HOD go long

ok...I am a noob but I think I should be able to figure this out. I am trying to do something very simple but can't get it to work right. I am using the strategy wizard and trying to simply put on a long position when price touches 1 tick past the high of the current day. I have wasted way too much time on this as I just know it is very simple. Any help would be appreciated.
Trade From My Recliner is offline  
Reply With Quote
Old 11-25-2010, 08:06 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
Default

Welcome to our forums - what issues have you run into? If your entry triggers, the trade would be executed on the next bar in backtesting.
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 11-25-2010, 08:20 AM   #3
Trade From My Recliner
Junior Member
 
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

I suppose since I am new at this I am using flawed logic. Here is what I have come up with and a pic of what I get:

// 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 HiLowBreak : Strategy
{
#region Variables
// Wizard generated variables
private int target = 1; // Default setting for Target
private int stop = 1; // Default setting for Stop
// 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(CurrentDayOHL());
SetProfitTarget("", CalculationMode.Ticks, Target);
SetStopLoss("", CalculationMode.Ticks, Stop, false);

CalculateOnBarClose = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (GetCurrentBid() > CurrentDayOHL().CurrentHigh[1] + 1 * TickSize)
{
EnterLong(DefaultQuantity, "");
}

}

#region Properties
[Description("")]
[GridCategory("Parameters")]
public int Target
{
get { return target; }
set { target = Math.Max(0, value); }
}

[Description("")]
[GridCategory("Parameters")]
public int Stop
{
get { return stop; }
set { stop = Math.Max(0, value); }
}
#endregion
}

Trade From My Recliner is offline  
Reply With Quote
Old 11-25-2010, 08:22 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
Default

Looks good to me, but unfortunately I did not see the pic with the outcome....also: GetCurrentBid uses the Close value in backtesting, so this might be different from what you expect.
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 11-25-2010, 08:22 AM   #5
Trade From My Recliner
Junior Member
 
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

http://www.screencast.com/t/yOV17AvOylq
Trade From My Recliner is offline  
Reply With Quote
Old 11-25-2010, 08:25 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
Default

Correct this setup will trigger continously if a new HOD is made - are you looking to enter only once per day?
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 11-25-2010, 08:28 AM   #7
Trade From My Recliner
Junior Member
 
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

No...each time HOD is exceeded by 1 tick unless, of course, it is already actively in a trade.
Trade From My Recliner is offline  
Reply With Quote
Old 11-25-2010, 08:35 AM   #8
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
Default

I suggest you add a drawing to your strategy so you can visually see when exactly it would trigger to place a trade on the next bar - http://www.ninjatrader-support.com/H...gOnAChart.html
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 11-25-2010, 08:39 AM   #9
Trade From My Recliner
Junior Member
 
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

ok I will try that, but I actually want it to place the trade on the current bar...on touch one tick beyond HOD
Trade From My Recliner is offline  
Reply With Quote
Old 11-25-2010, 08:49 AM   #10
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
Default

Then you need to work with CalculateOnBarClose = false in realtime to be able to update the calcs on each tick - http://www.ninjatrader-support.com/H...BarClose1.html
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 11-25-2010, 09:59 AM   #11
Trade From My Recliner
Junior Member
 
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

well...you must love working with noobs....I can't get a drawing object to print in my strategy. Nothing shows up on the chart. ideas?
Trade From My Recliner is offline  
Reply With Quote
Old 11-25-2010, 10:02 AM   #12
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
Default

What y axis value did you choose to draw the object at? Most leave it a first at 0, so this will then never show up unfortunately.
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 11-25-2010, 10:07 AM   #13
Trade From My Recliner
Junior Member
 
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

I've tried 0, 1, -1. I can get a bar color to change or outline color to change...cant get dot, triangle, arrow, etc. to print
Trade From My Recliner is offline  
Reply With Quote
Old 11-25-2010, 10:10 AM   #14
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
Default

Please follow the example here very closely - http://www.ninjatrader-support.com/H...gOnAChart.html

0, 1, -1 would not make sense, to draw you would want to use a valid value on your Y Price axis, such as the High / Low with an offset.
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 11-25-2010, 10:19 AM   #15
Trade From My Recliner
Junior Member
 
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

oops...yeah that got it, thanks.
Trade From My Recliner is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
T&S HOD/LOD prints smeagol Miscellaneous Support 1 09-28-2010 09:49 AM
B6 : Incorrect HOD on same chart settings superarrow Version 7 Beta General Questions & Bug Reports 4 01-08-2010 07:08 AM
Pivot line shifts at day break, not session break?? billy822 Charting 4 03-23-2009 10:19 AM
Execute on price HOD tahoebry Strategy Development 9 10-16-2008 04:18 PM
How to display ticks to HOD & LOD zq655 Indicator Development 1 01-22-2008 07:45 AM


All times are GMT -6. The time now is 08:58 AM.