Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
tick size for Initialize()
Collapse
X
-
Hello outsource,
As koganam stated, if you could provide additional information as to exactly what you are trying to achieve with this particular code, we will be able to provide further guidance. A snippet of your actual code around where you are inserting this may be beneficial to include as well.
Thank you in advance!
-
Originally posted by outsource View PostThanks koganam,
i tried this very equation,but it seems after that it ignored the other confditions i have.
Should i bracket this equation?
What are you trying to do in this small instance, and I may be able to give you a complete statement, that might be more useful?
Leave a comment:
-
Originally posted by olres7 View PostTry this one
SetStopLoss("Long Entry 1", CalculationMode.Ticks, Instrument.MasterInstrument.Round2TickSize(MyDoubl e*TickSize), false);
SetProfitTarget("Long Entry 1", CalculationMode.Ticks, (2.0*A_big/TickSize));
but it`s not about setting stops and profits.It`s about adding some degree of freedom to conditions to take place.
Leave a comment:
-
Originally posted by koganam View PostBy separating them.
Code:Value[0][0] < Value[0][1] - TickSize || Value[0][0] > Value[0][1] + TickSize
i tried this very equation,but it seems after that it ignored the other confditions i have.
Should i bracket this equation?
Leave a comment:
-
Try this one
SetStopLoss("Long Entry 1", CalculationMode.Ticks, Instrument.MasterInstrument.Round2TickSize(MyDoubl e*TickSize), false);
SetProfitTarget("Long Entry 1", CalculationMode.Ticks, (2.0*A_big/TickSize));
Leave a comment:
-
Originally posted by outsource View PostA bit off top...
But,how to achieve -/+ ticksize within the same condition?
So for Value[0][0] > Value[0][1] +/- ticksize
So,it would be true n ticks above OR n ticks below
Thanks to All
Code:Value[0][0] < Value[0][1] - TickSize || Value[0][0] > Value[0][1] + TickSize
Leave a comment:
-
A bit off top...
But,how to achieve -/+ ticksize within the same condition?
So for Value[0][0] > Value[0][1] +/- ticksize
So,it would be true n ticks above OR n ticks below
Thanks to All
Leave a comment:
-
alexstox,
Unfortunately TickSize is not accessible in the Initialize() method.
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.
Please let me know if I may assist further.
Leave a comment:
-
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.
Leave a comment:
-
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 }
Last edited by NinjaTrader_AdamP; 04-18-2012, 08:13 AM.
Leave a comment:
-
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, 08:11 AM.
Leave a comment:
-
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.
Leave a comment:
-
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?
Leave a comment:
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ZeroKuhl, Today, 04:31 PM
|
0 responses
7 views
0 likes
|
Last Post
by ZeroKuhl
Today, 04:31 PM
|
||
Started by Vulgoth_t_Destroyer, 05-09-2022, 04:45 PM
|
54 responses
5,336 views
0 likes
|
Last Post
by Gaterz
Today, 04:29 PM
|
||
Started by ETFVoyageur, 05-07-2024, 07:05 PM
|
11 responses
73 views
0 likes
|
Last Post
by -=Edge=-
Today, 04:27 PM
|
||
Started by _Zero_, 04-10-2020, 03:21 PM
|
145 responses
7,899 views
6 likes
|
Last Post
by johng2
Today, 04:19 PM
|
||
Started by TheTradingMantis, 01-19-2023, 02:05 AM
|
43 responses
921 views
0 likes
|
Last Post
by jmagaia
Today, 04:13 PM
|
Leave a comment: