NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 04-14-2012, 09:03 AM   #1
alexstox
Senior Member
 
Join Date: Apr 2012
Posts: 141
Thanks: 30
Thanked 25 times in 6 posts
Exclamation tick size for Initialize()

Hello! What should I use to return ticket size of instrument (futures), that could be used in Initialize().
Example:
SetStopLoss("Long Entry 1", CalculationMode.Ticks, MyDouble*TickSize, false);

MyDouble=0.0123. It should be in ticks for Stop target, =123.

Unfortunately TickSize doesn't work in Initialize().
alexstox is offline  
Reply With Quote
Old 04-14-2012, 09:06 AM   #2
Radical
Senior Member
 
Join Date: Sep 2008
Posts: 543
Thanks: 80
Thanked 187 times in 131 posts
Default

I have no idea if this will work, but maybe try using TickSize in OnStartUp()?
Radical is offline  
Reply With Quote
The following user says thank you to Radical for this post:
Old 04-14-2012, 12:34 PM   #3
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

To all,

Yes, TickSize should not be used in Initialize(). Unfortunately there aren't any supported work arounds available, but someone may have a solution here.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 04-15-2012, 03:25 PM   #4
alexstox
Senior Member
 
Join Date: Apr 2012
Posts: 141
Thanks: 30
Thanked 25 times in 6 posts
Default

Quote:
Originally Posted by Radical View Post
I have no idea if this will work, but maybe try using TickSize in OnStartUp()?
Please write here how I can do it? These two versions don't work, because I don't know how to assign TickSize to ts ---> ts = TickSize

protected override void OnStartUp()
{
private object ts = TickSize;
}

protected override void OnStartUp()
{
ts = TickSize;
}
alexstox is offline  
Reply With Quote
Old 04-17-2012, 02:20 PM   #5
alexstox
Senior Member
 
Join Date: Apr 2012
Posts: 141
Thanks: 30
Thanked 25 times in 6 posts
Unhappy

rat-tat! rat-tat! rat-tat! Please don't leave me alone
alexstox is offline  
Reply With Quote
Old 04-17-2012, 02:30 PM   #6
Radical
Senior Member
 
Join Date: Sep 2008
Posts: 543
Thanks: 80
Thanked 187 times in 131 posts
Default

Try 'double ts = TickSize;' in OnStartUp()
Radical is offline  
Reply With Quote
Old 04-18-2012, 07:01 AM   #7
alexstox
Senior Member
 
Join Date: Apr 2012
Posts: 141
Thanks: 30
Thanked 25 times in 6 posts
Default

before "protected override void Initialize()" I inserted
"protected override void OnStartUp()
{
double ts = TickSize;
}
But error "The name `ts` does not exist in the current context"
Where should I declair `ts`? In "#region Properties"? as private double or just as double?
alexstox is offline  
Reply With Quote
Old 04-18-2012, 07:42 AM   #8
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

alexstox,

Where are you using the variable ts? I suspect you would need to declare :

private double ts;

in the "variables" section to make it accessible by the other methods.

A variable declared within a method like OnStartup() or OnBarUpdate() will only be accessible in OnStartup() or OnBarUpdate() respectively the way you are declaring it.

Please let me know if I may assist further.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 04-18-2012, 08:00 AM   #9
alexstox
Senior Member
 
Join Date: Apr 2012
Posts: 141
Thanks: 30
Thanked 25 times in 6 posts
Default

public class LWMP : Strategy
{
#region Variables
private double TS = TickSize;
#endregion

error: An object reference is required for the non-static field, method, or property `NinjaTrader.Strategy.StrategyBase.TickSize.Get`


P.S. The problem is I can't get TickSize in Initialize(), but there are conditions that use it.
For example:
protected override void Initialize()
{
SetProfitTarget("Long Entry 1", CalculationMode.Ticks, 2*A_big/TS);
Last edited by alexstox; 04-18-2012 at 08:11 AM.
alexstox is offline  
Reply With Quote
Old 04-18-2012, 08:10 AM   #10
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

alexstox,

This is the issue : private double TS = TickSize;

Here :

Code:
public class LWMP : Strategy
{
#region Variables
private double TS = TickSize; 
#endregion

//other code and methods

}
The TickSize variable is only accessible in the OnBarUpdate() method, though some people seem to get it to work in OnStartup() which is unsupported currently.

Basically, you need to declare your variable :

Code:
public class LWMP : Strategy
{
#region Variables
private double TS; 
#endregion

// other code and methods

}
Then assign it in another method like :

Code:
private override void OnBarUpdate()
{

TS = TickSize;

//other code

}
Please let me know if I may assist further.
Last edited by NinjaTrader_AdamP; 04-18-2012 at 08:13 AM.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 04-18-2012, 08:44 AM   #11
alexstox
Senior Member
 
Join Date: Apr 2012
Posts: 141
Thanks: 30
Thanked 25 times in 6 posts
Default

The problem is I can't get TickSize in Initialize(), but there are conditions that use it.
For example:
protected override void Initialize()
{
SetProfitTarget("Long Entry 1", CalculationMode.Ticks, 2*A_big/TS);

When I do like you wrote - Backtest work bad, incorrect. When I just use 0.0001 instead of TS - everything is OK. So, what can you advise? How can I use TickSize in Profit and Stop targets? I need it to be divide by TickSize to get {2*0.0112/0.0001=224} ticks for targets.
alexstox is offline  
Reply With Quote
Old 04-18-2012, 08:49 AM   #12
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

alexstox,

Unfortunately TickSize is not accessible in the Initialize() method.

http://www.ninjatrader.com/support/h...l?ticksize.htm

Please keep in mind you can also specify a stop loss in the OnBarUpdate() method, where TickSize would be accessible, and it will apply this stop loss to your orders.

http://www.ninjatrader.com/support/f...ead.php?t=3222

Please let me know if I may assist further.
NinjaTrader_AdamP 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
different forex tick size same feed ATI user Strategy Development 11 02-17-2011 10:47 AM
Tick-Size-Settings for IB nachig Charting 3 12-28-2009 07:47 AM
Problem with FX-Tick-Size Joerg Strategy Development 7 03-29-2009 08:01 AM
How can I get market tick size? maxima Indicator Development 2 05-04-2008 10:54 AM
ZN Custom Tick Size Futures_Shark SuperDOM and other Order Entry Windows 5 11-15-2007 08:32 AM


All times are GMT -6. The time now is 02:34 AM.