i dont understund thankz
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
how calculate a body of a candel?
Collapse
X
-
Hello faustf,
I am not sure what you are asking, the code I just provided is calling Close[14] directly. Can you explain your question further?
Are you asking about the condition I had added: "if(CurrentBar < 14) return; " ?
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(Close[0]);
double barOpenPrice = Open[14];
double barClosePrice = Close[14];
double barLong=( barOpenPrice- barClosePrice);
Print( barLong);
}
in this mode return me error
Comment
-
Originally posted by faustf View Posthi guys i try to calculate a body of candel in 14" position how is possible to do that i try open[14]-close[14] but return me error if i use 0 return me many value o_O
i dont understund thankz
When you use Open[14] it means 14 bars ago relative to the current bar that just closed.
As each new bar is added to chart, the actual bar referenced by Open[14] keeps changing,
it may look like an array index but, strictly speaking, it is not. Remember, when you use
Open and Close in NinjaScript, these are DataSeries, not arrays.
If X is an Array then X[n] means the nth value from the beginning.
If X is a DataSeries then X[n] means the nth value from the end.
Open[14] means 14 bars backwards -- as in, 14 bars behind the bar that just closed.
Why do you need the body of the candle 14 bars ago?
Per chance,
Are you using a daily chart and trying to look at the bar from 2 weeks ago?
Can you explain more precisely what you're wanting to do?
Comment
-
i try to understund how work nijatrader , usally i use metatrader , but have many limits , and i want know NJ Platform and logic .
so , i try to simply return a dimention of a candel 14 in 30 min , why 14 ? ....is random , i like 14 , but my finish plan is (if arrive to understund somthing o_O) find a univoc dimention of candel. example suppose you have 2 chart in Y you have price in X you have time (is chart ) so inside of chart A you have a candel long 0.5cm and inside of chart B you have the same candel 0.5cm , but if you use open and close for have a size of body if instruments is different return 2 value differents but for my eye and for my analisys is the same candel , or i consider the same , therfore how is possible resolve it ?
but for start i want to understund how work NJ
i try this code but why return me all this numbner ???
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(Close[0]);
if(CurrentBar < 14) return;
Print(Open[14]-Close[14]);
}
0,000850000000000017
9,9999999999989E-05
-0,000399999999999956
0,000349999999999961
0,000399999999999956
-0,000199999999999978
-0,00154999999999994
0,000249999999999972
0,000399999999999956
-4,99999999999945E-05
0,000300000000000078
0,000199999999999978
-0,000500000000000056
0,000149999999999983
4,99999999999945E-05
0,000350000000000072
0,00149999999999995
-0,000750000000000028
0,00119999999999998
0,00180000000000002
-0,000349999999999961
9,9999999999989E-05
0,000650000000000039
-0,000199999999999978
-0,000800000000000023
-0,000950000000000006
-0,000499999999999945
0,000199999999999978
-0,000199999999999978
-4,99999999999945E-05
-0,000750000000000028
-0,000849999999999906
0,000549999999999939
-4,99999999999945E-05
0,000249999999999972
-0,000749999999999917
4,99999999999945E-05
0,000399999999999956
-0,000700000000000034
-0,000549999999999939
0,000599999999999934
-0,000149999999999983
0,001
-0,000649999999999928
-0,000750000000000028
-0,000600000000000045
0,00134999999999996
0
0
0,000400000000000067
-4,99999999999945E-05
0
0,000599999999999934
9,9999999999989E-05
9,9999999999989E-05
0,000200000000000089
0
0,000199999999999978
-0,000450000000000061
4,99999999999945E-05
0,000399999999999956
0,000700000000000034
9,9999999999989E-05
-0,000700000000000034
-0,000199999999999978
-0,00114999999999998
0,000750000000000028
-0,000149999999999983
-0,000399999999999956
0,00119999999999998
0,000650000000000039
0,000199999999999978
0,000750000000000028
0,000599999999999934
-0,000599999999999934
-0,00055000000000005
-0,000399999999999956
-0,00165000000000004
-0,000249999999999972
-0,000199999999999978
0,000499999999999945
0,000150000000000095
0
0,00129999999999997
-0,000750000000000028
-0,000499999999999945
0,00259999999999994
0,000600000000000045
-0,000800000000000023
0,000500000000000056
-0,000200000000000089
0,00120000000000009
0,000750000000000028
-0,0011500000000001
0,0001000000000001
0,000250000000000083
4,99999999999945E-05
-9,9999999999989E-05
-0,000500000000000056
0,00155000000000005
0,000849999999999906
-0,000399999999999956
0
-4,99999999999945E-05
0,000149999999999983
4,99999999999945E-05
-0,000399999999999956
9,9999999999989E-05
-0,000399999999999956
0,00119999999999998
0,000700000000000034
0,000799999999999912
0,000149999999999983
0
0,00169999999999992
4,99999999999945E-05
0,000300000000000078
-0,00105
0,000299999999999967
-0,000249999999999972
-0,000250000000000083
0,000450000000000061
-0,00055000000000005
-0,00165000000000004
-0,000249999999999972
0,00114999999999998
0,000199999999999978
-0,000249999999999972
0,000199999999999978
0,000250000000000083
-0,000200000000000089
-4,99999999999945E-05
-0,00129999999999997
0,00109999999999999
-0,00119999999999998
0,000249999999999972
0,000750000000000028
0,000499999999999945
0,000249999999999972
-0,000149999999999983
-0,000149999999999983
-0,000249999999999972
0,000699999999999923
-0,000499999999999945
0,000149999999999983
0,000399999999999956
-0,000699999999999923
0,000149999999999983
0,000749999999999917
0,000750000000000028
0,000349999999999961
0,000299999999999967
-0,000450000000000061
-0,00124999999999997
-0,000800000000000023
-0,000499999999999945
-0,000149999999999983
-0,00135000000000007
Comment
-
NinjaScript is event driven -- you've got to learn to insert your mind into what
the indicator is doing. It's a learning curve, everybody goes through it.
The event driven design of every indicator is that it sees each bar on your chart.
Yes, I mean every bar, even that very first bar if you scroll all the way to left on
your chart. Yep, your indicator gets to process every one of these bars.
Well, how does it do that?
The internal NinjaScript framework calls your OnBarUpdate at the close of each bar.
So, why all the prints?
Well, let's say there were 500 bars in your chart, you're probably not seeing all 500 at
once, your screen is probably not big enough, so you have to scroll to the left to see
more -- but your indicator saw all 500 bars -- and your OnBarUpdate was called 500
times.
Therefore, if your OnBarUpdate is automatically called once for each bar on your
chart, then naturally you will see output of your print statements for each bar.
Make sense?Last edited by bltdavid; 04-22-2020, 10:49 AM.
Comment
-
Originally posted by faustf View Postwhy 14 ? ....is random , i like 14
i try this code but why return me all this numbner ???
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(Close[0]);
if(CurrentBar < 14) return;
Print(Open[14]-Close[14]);
}
Code:protected override void OnBarUpdate() { if (CurrentBar == 14) { Print(Open[0]-Close[0]); } }
Comment
-
i try your code for look only one bar
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(Close[0]);
if(CurrentBar == 14) return;
Print(Open[0]-Close[0]);
}
but return me all this
0,000850000000000017
9,9999999999989E-05
-0,000399999999999956
0,000349999999999961
0,000399999999999956
-0,000199999999999978
-0,00154999999999994
0,000249999999999972
0,000399999999999956
-4,99999999999945E-05
0,000300000000000078
0,000199999999999978
-0,000500000000000056
0,000149999999999983
0,000350000000000072
0,00149999999999995
-0,000750000000000028
0,00119999999999998
0,00180000000000002
-0,000349999999999961
9,9999999999989E-05
0,000650000000000039
-0,000199999999999978
-0,000800000000000023
-0,000950000000000006
-0,000499999999999945
0,000199999999999978
-0,000199999999999978
-4,99999999999945E-05
-0,000750000000000028
-0,000849999999999906
0,000549999999999939
-4,99999999999945E-05
0,000249999999999972
-0,000749999999999917
4,99999999999945E-05
0,000399999999999956
-0,000700000000000034
-0,000549999999999939
0,000599999999999934
-0,000149999999999983
0,001
-0,000649999999999928
-0,000750000000000028
-0,000600000000000045
0,00134999999999996
0
0
0,000400000000000067
-4,99999999999945E-05
0
0,000599999999999934
9,9999999999989E-05
9,9999999999989E-05
0,000200000000000089
0
0,000199999999999978
-0,000450000000000061
4,99999999999945E-05
0,000399999999999956
0,000700000000000034
9,9999999999989E-05
-0,000700000000000034
-0,000199999999999978
-0,00114999999999998
0,000750000000000028
-0,000149999999999983
-0,000399999999999956
0,00119999999999998
0,000650000000000039
0,000199999999999978
0,000750000000000028
0,000599999999999934
-0,000599999999999934
-0,00055000000000005
-0,000399999999999956
-0,00165000000000004
-0,000249999999999972
-0,000199999999999978
0,000499999999999945
0,000150000000000095
0
0,00129999999999997
-0,000750000000000028
-0,000499999999999945
0,00259999999999994
0,000600000000000045
-0,000800000000000023
0,000500000000000056
-0,000200000000000089
0,00120000000000009
0,000750000000000028
-0,0011500000000001
0,0001000000000001
0,000250000000000083
4,99999999999945E-05
-9,9999999999989E-05
-0,000500000000000056
0,00155000000000005
0,000849999999999906
-0,000399999999999956
0
-4,99999999999945E-05
0,000149999999999983
4,99999999999945E-05
-0,000399999999999956
9,9999999999989E-05
-0,000399999999999956
0,00119999999999998
0,000700000000000034
0,000799999999999912
0,000149999999999983
0
0,00169999999999992
4,99999999999945E-05
0,000300000000000078
-0,00105
0,000299999999999967
-0,000249999999999972
-0,000250000000000083
0,000450000000000061
-0,00055000000000005
-0,00165000000000004
-0,000249999999999972
0,00114999999999998
0,000199999999999978
-0,000249999999999972
0,000199999999999978
0,000250000000000083
-0,000200000000000089
-4,99999999999945E-05
-0,00129999999999997
0,00109999999999999
-0,00119999999999998
0,000249999999999972
0,000750000000000028
0,000499999999999945
0,000249999999999972
-0,000149999999999983
-0,000149999999999983
-0,000249999999999972
0,000699999999999923
-0,000499999999999945
0,000149999999999983
0,000399999999999956
-0,000699999999999923
0,000149999999999983
0,000749999999999917
0,000750000000000028
0,000349999999999961
0,000299999999999967
-0,000450000000000061
-0,00124999999999997
-0,000800000000000023
-0,000499999999999945
-0,000149999999999983
-0,00135000000000007
0,000850000000000017
-0,000499999999999945
-0,000300000000000078
-0,000349999999999961
0,00044999999999995
-0,000599999999999934
0,000549999999999939
4,99999999999945E-05
0,000200000000000089
-0,00105
0,000549999999999939
-0,000149999999999983
0,00114999999999998
-0,000299999999999967
-0,000249999999999972
-0,000800000000000023
0,000900000000000012
0,000499999999999945
Comment
-
i understund a logic behind or i accepts logic behind but why this sense ?, example in MT (sorry but i come from here), you call simply open[14]-Close[14] finish , not must use a if ,probably do the same work but internal of method Open , but no problem i will study
Comment
-
Originally posted by faustf View Posti try your code for look only one bar
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(Close[0]);
if(CurrentBar == 14) return;
Print(Open[0]-Close[0]);
}
but return me all this
The code above is not the code sample I provided.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,404 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
||
Started by Shai Samuel, 07-02-2022, 02:46 PM
|
4 responses
95 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
7 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
159 views
0 likes
|
Last Post Yesterday, 10:23 PM | ||
Started by Belfortbucks, Yesterday, 09:29 PM
|
0 responses
8 views
0 likes
|
Last Post
by Belfortbucks
Yesterday, 09:29 PM
|
Comment