Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ohlc

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Ohlc

    Hey, can someone help me add OHLC to my automated strategy? Thank you!!

    #2
    Originally posted by Malletto View Post
    Hey, can someone help me add OHLC to my automated strategy? Thank you!!
    You need to add three lines of code to get OHLC

    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

    Comment


      #3
      Thank you so much. Just to confirm, do you know or are you aware that on the strategy analyzer, kagi bars calculate on OHLC?

      Comment


        #4
        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


          #5
          Thank you for getting back to me Jesse. Do you have the calculation so that I can input it into my strategies code? Also, i was told that the strategy analyzer executes based off OHLC. Is that true? Thanks!!

          Comment


            #6
            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


              #7
              Thank you for confirming Jesse. Do you have the exact code that needs to be implemented?

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CarlTrading, 05-11-2026, 05:56 AM
              0 responses
              56 views
              0 likes
              Last Post CarlTrading  
              Started by CarlTrading, 05-10-2026, 08:12 PM
              0 responses
              34 views
              0 likes
              Last Post CarlTrading  
              Started by Hwop38, 05-04-2026, 07:02 PM
              0 responses
              195 views
              0 likes
              Last Post Hwop38
              by Hwop38
               
              Started by CaptainJack, 04-24-2026, 11:07 PM
              0 responses
              359 views
              0 likes
              Last Post CaptainJack  
              Started by Mindset, 04-21-2026, 06:46 AM
              0 responses
              281 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Working...
              X