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,
I've actually found a possible way to access TickSize from Initialize()
#region Variables
protected double tickSizeForum = 0;
#endregion Variables
protected override void Initialize()
{
this.tickSizeForum = base.Instrument.MasterInstrument.TickSize;
}
and then, being that this is not supported, we check that this actually works
protected override void OnStartUp()
{
if (this.tickSizeForum != base.Instrument.MasterInstrument.TickSize) throw new InvalidOperationException("tickSize taken from Initialize() has changed in OnStartUp()");
}
Regards,
giogio
-
Originally posted by koganam View PostSearch engines are very useful, but only if we use them.
ref: https://msdn.microsoft.com/en-us/library/ms173144.aspx
https://msdn.microsoft.com/en-us/lib...85(VS.88).aspx
Leave a comment:
-
Originally posted by outsource View PostSo is it applicable for the both sides - Long and Short?The expression you provided creates the tick range,correct? What "if the expression returns true" means?I`m not that good with the C# brogue yet.
ref: https://msdn.microsoft.com/en-us/library/ms173144.aspx
Leave a comment:
-
Originally posted by koganam View PostIf the expression returns true, that means that the "Close/current price" is within a maximum of one tick outside of the SMA of the Highs and Lows. Period.
Leave a comment:
-
Originally posted by outsource View PostSo this way it could be inside the channel or TickSize outside the channel,whatever appears,for both - either long or short,correct?
Leave a comment:
-
Originally posted by koganam View PostEven though that is logical it is sort of mathematically redundant. If you want to test for a value between 2 other values just test for that.
Code:if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] - TickSize){/* ... */}
Leave a comment:
-
Originally posted by outsource View PostBecause i need this logic instead:
if (Close[0] <= SMA(High, 10)[0] || Close[0] <=SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] || Close >=SMA(Low, 8)[0] - TickSize)
Would this equation work in real life?
Code:if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] - TickSize){/* ... */}
Last edited by koganam; 11-19-2015, 06:32 PM.
Leave a comment:
-
Originally posted by NinjaTrader_ChelseaB View PostHello outsource,
No, these would not be the same.
if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] - TickSize)
if the close is equal to or less than the sma high plus one tick and is also equal to or greater than the sma low minus one tick trigger
if (Close[0] <= SMA(High, 10)[0] || Close[0] <=SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] || Close >=SMA(Low, 8)[0] - TickSize)
if the close is less than or equal to the sma high then trigger
if the close is less than or equal to the high plus one tick and the close is greater than the sma low then trigger
if the close is greater than or equal to the sma low minus one tick then trigger
That said, can you respond to my question from post #25?
I am not understanding how the example logic i provided is not what you are asking for. Can you clarify this?
if (Close[0] <= SMA(High, 10)[0] || Close[0] <=SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] || Close >=SMA(Low, 8)[0] - TickSize)
Would this equation work in real life?
Leave a comment:
-
Hello outsource,
No, these would not be the same.
if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] - TickSize)
if the close is equal to or less than the sma high plus one tick and is also equal to or greater than the sma low minus one tick trigger
if (Close[0] <= SMA(High, 10)[0] || Close[0] <=SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] || Close >=SMA(Low, 8)[0] - TickSize)
if the close is less than or equal to the sma high then trigger
if the close is less than or equal to the high plus one tick and the close is greater than the sma low then trigger
if the close is greater than or equal to the sma low minus one tick then trigger
That said, can you respond to my question from post #25?
I am not understanding how the example logic i provided is not what you are asking for. Can you clarify this?Last edited by NinjaTrader_ChelseaB; 11-19-2015, 11:42 AM.
Leave a comment:
-
Originally posted by NinjaTrader_ChelseaB View PostHello outsource,
Without being able to see what you have written I wouldn't be able to comment.
However, when you say "It`s not exactly what i asked.I need the price to be inside the channel OR slightly(ticksize) above the High(10) for buy signal and vice versa for sell.", this is a bit confusing.
Inside the channel or slightly above.
This is telling me that if you add 1 tick to the upper channel price and then the close is at this price or below that this is what you are looking for.
This is exactly what I have written from how i understand it.
My comment is:
// close is 1 tick outside of the channel or within
Can you explain how this is incorrect?
Would it be different or would it be the same?
if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] - TickSize)
if (Close[0] <= SMA(High, 10)[0] || Close[0] <=SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] || Close >=SMA(Low, 8)[0] - TickSize)Last edited by outsource; 11-18-2015, 07:46 PM.
Leave a comment:
-
Hello outsource,
Without being able to see what you have written I wouldn't be able to comment.
However, when you say "It`s not exactly what i asked.I need the price to be inside the channel OR slightly(ticksize) above the High(10) for buy signal and vice versa for sell.", this is a bit confusing.
Inside the channel or slightly above.
This is telling me that if you add 1 tick to the upper channel price and then the close is at this price or below that this is what you are looking for.
This is exactly what I have written from how i understand it.
My comment is:
// close is 1 tick outside of the channel or within
Can you explain how this is incorrect?
Leave a comment:
-
Originally posted by NinjaTrader_ChelseaB View PostHello Outsource,
As an example here is how that logic is created with TickSize. This is following the pattern set by koganam.
Code:if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] - TickSize) { // close is 1 tick outside of the channel or within // close is less than or equal to sma using high as input with a period of 10 // and close is greater than or equal to the sam using the low as input with period of 8 } if (Close[0] > SMA(High, 10)[0] + TickSize || Close < SMA(Low, 8)[0] - TickSize) { // close is more than 1 tick outside the channel // close is greater than sma using high as input with period of 10 // OR close is less than sma using low as input with period of 8 }
For example:
int buffer = 2;
Print(SMA(High, 10)[0] + buffer * TickSize);
This would print the value of the sma using the high with a period of 10 plus 2 ticks.
if buffer was equal to -3 this would subtract 3 ticks.
thank you for the example.It`s not exactly what i asked.I need the price to be inside the channel OR slightly(ticksize) above the High(10) for buy signal and vice versa for sell.
So that
if (Close[0] <= SMA(High, 10)[0] && Close >= SMA(Low, 8)[0] ) +/- TickSize
Is there a way to accomplish something like this.When i try to imply the "||" statement it doesnt work properly.
Leave a comment:
-
Hello Outsource,
As an example here is how that logic is created with TickSize. This is following the pattern set by koganam.
Code:if (Close[0] <= SMA(High, 10)[0] + TickSize && Close >= SMA(Low, 8)[0] - TickSize) { // close is 1 tick outside of the channel or within // close is less than or equal to sma using high as input with a period of 10 // and close is greater than or equal to the sam using the low as input with period of 8 } if (Close[0] > SMA(High, 10)[0] + TickSize || Close < SMA(Low, 8)[0] - TickSize) { // close is more than 1 tick outside the channel // close is greater than sma using high as input with period of 10 // OR close is less than sma using low as input with period of 8 }
For example:
int buffer = 2;
Print(SMA(High, 10)[0] + buffer * TickSize);
This would print the value of the sma using the high with a period of 10 plus 2 ticks.
if buffer was equal to -3 this would subtract 3 ticks.Last edited by NinjaTrader_ChelseaB; 11-17-2015, 03:25 PM.
Leave a comment:
-
Originally posted by NinjaTrader_MichaelM View PostHello 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!
For illustration,you can take Snake eye method as an exampe with its two SMAs one is 8 period for the Low input,and another is 10 period for the High input.Thus create a channel.So now the price should be inside the channel or slightly above(but no more then) 10 SMA of the High or below(but no more then) 8 SMA of the Low
Leave a comment:
-
Originally posted by koganam View PostHard to say.. You asked a very specific question, and I gave you the specific expression that you would use. Generally, you have to write statements in a program, so the expression itself standing alone would not do much.
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:
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by wzgy0920, 02-22-2024, 01:11 AM
|
5 responses
32 views
0 likes
|
Last Post
by wzgy0920
Today, 10:33 PM
|
||
Started by wzgy0920, Yesterday, 09:53 PM
|
2 responses
49 views
0 likes
|
Last Post
by wzgy0920
Today, 10:29 PM
|
||
Started by Kensonprib, 04-28-2021, 10:11 AM
|
5 responses
191 views
0 likes
|
Last Post
by Hasadafa
Today, 10:19 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
11 responses
3,230 views
0 likes
|
Last Post Today, 08:07 PM | ||
Started by andrewtrades, Today, 04:57 PM
|
1 response
14 views
0 likes
|
Last Post Today, 05:02 PM |
Leave a comment: