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 02-07-2010, 01:41 AM   #1
andrew100
Junior Member
 
Join Date: Feb 2010
Posts: 16
Default pivot indicator

Hi,

How can I display daily pivots lines on intraday charts?

Andrew
andrew100 is offline  
Reply With Quote
Old 02-07-2010, 01:08 PM   #2
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 1,760
Default

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.

NinjaTrader_Austin is offline  
Reply With Quote
Old 02-07-2010, 01:09 PM   #3
DarthTraderson
Member
 
Join Date: May 2009
Location: Cologne
Posts: 44
Default

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));
I guess you are interested in the HLCCalculationMode parameter.

DT
DarthTraderson is offline  
Reply With Quote
Old 02-07-2010, 11:17 PM   #4
andrew100
Junior Member
 
Join Date: Feb 2010
Posts: 16
Default

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
andrew100 is offline  
Reply With Quote
Old 02-08-2010, 06:50 AM   #5
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Hamburg / Lueneburg - Germany
Posts: 11,643
Default

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.

NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-08-2010, 11:32 PM   #6
andrew100
Junior Member
 
Join Date: Feb 2010
Posts: 16
Default

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
andrew100 is offline  
Reply With Quote
Old 02-09-2010, 03:31 PM   #7
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 16,367
Default

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.
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-10-2010, 03:10 AM   #8
andrew100
Junior Member
 
Join Date: Feb 2010
Posts: 16
Default

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
Attached Images
File Type: jpg Untitled.jpg (16.7 KB, 22 views)
andrew100 is offline  
Reply With Quote
Old 02-10-2010, 06:28 AM   #9
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Hamburg / Lueneburg - Germany
Posts: 11,643
Default

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.

NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-11-2010, 01:38 AM   #10
andrew100
Junior Member
 
Join Date: Feb 2010
Posts: 16
Default

thats the version I got.

Andrew
andrew100 is offline  
Reply With Quote
Old 02-11-2010, 06:40 AM   #11
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Hamburg / Lueneburg - Germany
Posts: 11,643
Default

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.

NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-12-2010, 12:44 AM   #12
andrew100
Junior Member
 
Join Date: Feb 2010
Posts: 16
Default

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
andrew100 is offline  
Reply With Quote
Old 02-12-2010, 08:52 AM   #13
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Hamburg / Lueneburg - Germany
Posts: 11,643
Default

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.

NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-13-2010, 04:47 PM   #14
andrew100
Junior Member
 
Join Date: Feb 2010
Posts: 16
Default

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
andrew100 is offline  
Reply With Quote
Old 02-15-2010, 07:14 AM   #15
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 16,367
Default

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.
NinjaTrader_Josh 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
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


All times are GMT -6. The time now is 10:50 PM.