Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Ohlc
Collapse
X
-
You need to add three lines of code to get OHLCOriginally posted by Malletto View PostHey, can someone help me add OHLC to my automated strategy? Thank you!!
1) At the very top of the script within the public class xyz : Strategy add the line:
private Series<double> OHLC;
2) Within OnStateChange() inside the section else if (State == State.DataLoaded) add the line:
OHLC = new Series<double>(this);
3) Within OnBarUpdate() add the line:
OHLC[0] = 0.25 * (Open[0] + High[0] + Low[0] + Close[0]) ;
That's it, now you can use OHLC like any other double time series for calculations and plotting.
Regards
-
Hello Malletto,
Kagi bars are based on the OHLC from underlying series that you select when configuring the test. They would not use a calculation like the one posted in post 2 but would use the raw OHLC values. You can read about how the kagi bars are built based on price movement in the following link.
Comment
-
Hello Malletto,
To use kaji bars in the strategy analyzer you would need to select kaji as the bar type you are testing. The default selection is minute bars, you can click that dropdown to get other bars types.
The strategy analyzer in addition to charts use OHLC data, any script you apply will use the bar series that you selected and its OHLC data. OHLC is in reference to the 4 individual data points not to be confused with making a Weighted price as shown in post 2. A script can access the individual data points for open high low or close individually, fills in a strategy would be based on the OHLC data points which are fed into the historical fill algorithm. You can read about that here:
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
65 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
139 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment