Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

within x percent

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

    within x percent

    Hi,
    What's a good function to use to test:

    if (
    low[0] "is within x percent of" Low [1]
    )

    {do stuff}

    I want to know if a price is within x percent of another price whether above OR below

    Any ideas for something succinct within the library?

    thanks,
    David

    #2
    Hi trader3000, thanks for posting. There is no pre-made function to get a percentage but you can calculate it using C#. Here is a C# snippet of the OnBarUpdate method that will calculate a bar percentage:

    Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.


    Kind regards,
    -ChrisL

    Comment


      #3
      Something like this should work for you: if (Math.Abs(Low[0]/Low[1]-1.0)*100.0 <= PercentLimit) { // Do things }

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      45 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      31 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X