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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      90 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      137 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      120 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      72 views
      0 likes
      Last Post PaulMohn  
      Working...
      X