Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Formula for bar lookback periods

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

    Formula for bar lookback periods

    I have a strategy I am working on and cant get my head to wrap around the math needed for the situation. Here's my problem.

    I am evaluating a bunch of functions for enter signal. One of the function is the ADX. What I want to be able to do is evaluate the ADX on a certain period and check the value of X number of bars back to see if a certain value was met. Is some case I want to look back 3 bars in others 13 bars. So I created variables for ADX Period and the # of bars back a wanted to evaluate. The place I am getting stuck is how to write the formula. The ghetto side of me wants to do a bunch of if / else if statements but that requires me to change the code each time to account for the # of bar look backs rather than just change the variable in the strategy.

    Is there any help out there for me?

    #2
    erik949, it might not be following you fully here but for the lookbacks to check you would have two variables for example that could also be user inputs you would then use in the final condition to check. For repetitive code parts it might be worth exploring the looping commands available in C# -

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    153 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    72 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    125 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    79 views
    0 likes
    Last Post PaulMohn  
    Working...
    X