Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SMA update on each tick.

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

    SMA update on each tick.

    Hello NT experts

    I have two SMA's in my strategy. SMA10 and HMA5.

    While SMA10 updates on each Bar Close[0], I would like HMA5 to update real time(update on each tick). Could you please provide me an example?

    Thanks for your patience and time.

    #2
    Hello NRITV,

    can you tell me is the strategy being manually coded or built using the builder. While you can do what you are asking it depends on how the strategy was created, this process would be different between manually coding and a strategy builder script.

    Comment


      #3
      Helo Jesse, I built the strategy manually.

      Thanks

      Comment


        #4
        Hello NRITV,

        Thanks for confirming that.

        To do what you are asking you are run the script using OnEachTick as its calculate mode in realtime. To simulate OnBarClose for parts of your logic you can surround that code with a first tick of bar condition.



        if (IsFirstTickOfBar)
        {
        // your code that you want to run OnBarClose
        }

        // your code that should be executed on each tick

        To get the last closed value of the SMA and not the current ticks value you can use the [1] bars ago price for the SMA which would be the last closed price.

        double price = SMA(12)[1];
        double price2 = HMA(12)[0]; ​

        Comment


          #5
          Thank You Jesse. Much appreciated!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          44 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          65 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X