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 NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              65 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              139 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              75 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              45 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              50 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X