![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Apr 2012
Posts: 141
Thanks: 30
Thanked 25 times in 6 posts
|
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(). |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Sep 2008
Posts: 543
Thanks: 80
Thanked 187 times in 131 posts
|
I have no idea if this will work, but maybe try using TickSize in OnStartUp()?
|
|
|
|
|
The following user says thank you to Radical for this post: |
|
|
|
#3 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
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.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#4 | |
|
Senior Member
Join Date: Apr 2012
Posts: 141
Thanks: 30
Thanked 25 times in 6 posts
|
Quote:
protected override void OnStartUp() { private object ts = TickSize; } protected override void OnStartUp() { ts = TickSize; } |
|
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Apr 2012
Posts: 141
Thanks: 30
Thanked 25 times in 6 posts
|
rat-tat! rat-tat! rat-tat! Please don't leave me alone
|
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Sep 2008
Posts: 543
Thanks: 80
Thanked 187 times in 131 posts
|
Try 'double ts = TickSize;' in OnStartUp()
|
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Apr 2012
Posts: 141
Thanks: 30
Thanked 25 times in 6 posts
|
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? |
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
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.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Apr 2012
Posts: 141
Thanks: 30
Thanked 25 times in 6 posts
|
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.
|
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
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
}
Basically, you need to declare your variable : Code:
public class LWMP : Strategy
{
#region Variables
private double TS;
#endregion
// other code and methods
}
Code:
private override void OnBarUpdate()
{
TS = TickSize;
//other code
}
Adam P.
NinjaTrader Customer Service
Last edited by NinjaTrader_AdamP; 04-18-2012 at 08:13 AM.
|
|
|
|
|
|
#11 |
|
Senior Member
Join Date: Apr 2012
Posts: 141
Thanks: 30
Thanked 25 times in 6 posts
|
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. |
|
|
|
|
|
#12 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
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.
Adam P.
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |