![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
|
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 } |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
|
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
|
Correct this setup will trigger continously if a new HOD is made - are you looking to enter only once per day?
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
|
No...each time HOD is exceeded by 1 tick unless, of course, it is already actively in a trade.
|
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
|
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
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
|
ok I will try that, but I actually want it to place the trade on the current bar...on touch one tick beyond HOD
|
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
|
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
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Junior Member
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
|
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?
|
|
|
|
|
|
#12 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#13 |
|
Junior Member
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
|
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
|
|
|
|
|
|
#14 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,566
Thanks: 261
Thanked 1,016 times in 997 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#15 |
|
Junior Member
Join Date: Nov 2010
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
|
oops...yeah that got it, thanks.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |