![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Feb 2010
Posts: 16
|
Hi,
How can I display daily pivots lines on intraday charts? Andrew |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 1,760
|
Andrew, you can just apply the Pivots indicator to an intraday chart. From the chart, open the indicators window and then double-click on Pivots to add it.
__________________
Austin, NinjaTrader Customer Service NinjaTrader is a FREE application for advanced charting, market analytics, system development and trade simulation. View schedule of upcoming online product training events. |
|
|
|
|
|
#3 |
|
Member
Join Date: May 2009
Location: Cologne
Posts: 44
|
Andrew, you can use the PivotPoint-Indicator shipped with NinjaTrader.
Here is an example, if you want to add it in your strategies: Code:
Add(Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 50)); DT |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Feb 2010
Posts: 16
|
Thanks guys,
How do I go about about buy / sell at pivot point value? How do I add it into the EnterLong / EnterShort function? Thanks, Andrew |
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Hamburg / Lueneburg - Germany
Posts: 11,643
|
Andrew, you can try for example starting with this simple snippet to go long if Close crosses over the PP -
Code:
if (CrossAbove(Close, Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 20).PP, 1))
{
EnterLong(DefaultQuantity, "");
}
__________________
Bertrand, NinjaTrader Customer Service NinjaTrader is a FREE application for advanced charting, market analytics, system development and trade simulation. View schedule of upcoming online product training events. |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Feb 2010
Posts: 16
|
Thanks,
I would like to enter long if close crosses above previous day close and enter short if close crosses below previous day close. My code is below, I try it on the 15min chart but there doesn't seem to be any trade that gets entered. Is there something wrong with the code? protected override void Initialize() { Add(Pivots(NinjaTrader.Data.PivotRange.Daily, NinjaTrader.Data.HLCCalculationMode.CalcFromIntrad ayData, 20)); Add(Pivots(NinjaTrader.Data.PivotRange.Daily, NinjaTrader.Data.HLCCalculationMode.CalcFromIntrad ayData, 20)); SetProfitTarget("", CalculationMode.Price, 28); SetStopLoss("", CalculationMode.Price, 60, false); CalculateOnBarClose = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Condition set 1 if (CrossAbove(Close, Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 20).PP[-1], 1)) { EnterLong(DefaultQuantity, ""); } // Condition set 2 if (CrossAbove(Close, Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 20).PP[-1], 1)) { EnterShort(DefaultQuantity, ""); } } Thanks in advance, Andrew |
|
|
|
|
|
#7 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 16,367
|
Andrew,
You are using [-1] which is not allowed. You cannot use a negative index value. [0] means current bar, [1] means previous bar, [2] means bar before that. [-1] doesn't mean future bar, it is not allowed and actually throws an error which should be viewable in the Control Center log. Please adjust this and it should work better.
__________________
Josh, NinjaTrader Customer Service NinjaTrader is a FREE application for advanced charting, market analytics, system development and trade simulation. View schedule of upcoming online product training events. |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Feb 2010
Posts: 16
|
Thanks Josh,
There either seem to be something wrong with my entry or exits, my exits are as follows; protected override void Initialize() { Add(Pivots(NinjaTrader.Data.PivotRange.Daily, NinjaTrader.Data.HLCCalculationMode.CalcFromIntrad ayData, 20)); Add(Pivots(NinjaTrader.Data.PivotRange.Daily, NinjaTrader.Data.HLCCalculationMode.CalcFromIntrad ayData, 20)); SetProfitTarget("", CalculationMode.Ticks, 28); SetStopLoss("", CalculationMode.Ticks, 60, false); CalculateOnBarClose = true; } Essentially what I am after is profit at entry +28 pts and stoploss at -60pt. Please see pic of backtest. THanks for your help, Andrew |
|
|
|
|
|
#9 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Hamburg / Lueneburg - Germany
Posts: 11,643
|
Andrew, strange it seems to be submitted at price instead of ticks - which NT version you running? Please check under Help > About and ensure this is the latest 6.5.1000.14.
__________________
Bertrand, NinjaTrader Customer Service NinjaTrader is a FREE application for advanced charting, market analytics, system development and trade simulation. View schedule of upcoming online product training events. |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Feb 2010
Posts: 16
|
thats the version I got.
Andrew |
|
|
|
|
|
#11 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Hamburg / Lueneburg - Germany
Posts: 11,643
|
Andrew, any way you could attach the script so I can check into it on my end?
__________________
Bertrand, NinjaTrader Customer Service NinjaTrader is a FREE application for advanced charting, market analytics, system development and trade simulation. View schedule of upcoming online product training events. |
|
|
|
|
|
#12 |
|
Junior Member
Join Date: Feb 2010
Posts: 16
|
OK,
// 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 Pivot3 : Strategy { #region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 // 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(Pivots(NinjaTrader.Data.PivotRange.Daily, NinjaTrader.Data.HLCCalculationMode.CalcFromIntrad ayData, 20)); Add(Pivots(NinjaTrader.Data.PivotRange.Daily, NinjaTrader.Data.HLCCalculationMode.CalcFromIntrad ayData, 20)); SetProfitTarget("", CalculationMode.Ticks, 28); SetStopLoss("", CalculationMode.Ticks, 60, false); CalculateOnBarClose = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Condition set 1 if (CrossAbove(Close, Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 20).PP[1], 1)) { EnterShort(DefaultQuantity, ""); } // Condition set 2 if (CrossBelow(Close, Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 20).PP[1], 1)) { EnterLong(DefaultQuantity, ""); } } #region Properties [Description("")] [Category("Parameters")] public int MyInput0 { get { return myInput0; } set { myInput0 = Math.Max(1, value); } } #endregion } } Thanks, Andrew |
|
|
|
|
|
#13 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Hamburg / Lueneburg - Germany
Posts: 11,643
|
Andrew, I don't see I reason why you should see this strange behavior noted - does for example our SampleMACrossOver strategy work for you properly?
If not, I would suggest doing a clean install of the latest NT 6.5.1000.14 and then rechecking. Thanks
__________________
Bertrand, NinjaTrader Customer Service NinjaTrader is a FREE application for advanced charting, market analytics, system development and trade simulation. View schedule of upcoming online product training events. |
|
|
|
|
|
#14 |
|
Junior Member
Join Date: Feb 2010
Posts: 16
|
Thanks Bertrand,
It worked after I did a reinstall, just one other question. I would like to enter only once per session (day) I found the following code on another thread, but where do I enter it in my code below? // in variables section private bool canTrade = true; OnBarUpdate() { if (SessionBreak) canTrade = true; if (long trade conditions are met) { canTrade = false; EnterLong(...); } if (short conditions are met) { canTrade = false; enterShort(...); } Thanks, Andrew |
|
|
|
|
|
#15 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 16,367
|
Andrew,
You would place that inside your OnBarUpdate() method over your trade logic.
__________________
Josh, NinjaTrader Customer Service NinjaTrader is a FREE application for advanced charting, market analytics, system development and trade simulation. View schedule of upcoming online product training events. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Addition to the pivot indicator | Avn_0903 | Indicator Development | 1 | 02-03-2010 06:17 AM |
| Pivot indicator | saeed | Charting | 3 | 12-22-2009 08:03 AM |
| Pivot Indicator | designer | Indicator Development | 6 | 11-25-2009 03:24 PM |
| Best pivot indicator | blazer | Indicator Development | 2 | 10-11-2009 04:12 AM |
| Pivot indicator | mballagan | Indicator Development | 6 | 10-01-2009 10:44 AM |