Finding barindex using function

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #75471 quote
    juanj
    Participant
    Master

    Hello Folks

    Can anyone tell me if it is possible to find the barindex value based on a function (i.e. barindex of lowest[10](low))

    Currently, I have to measure and compare each bar with the function output in order to find and identify the bar index of a specific function.

    #75472 quote
    Nicolas
    Keymaster
    Master

    Yes, apart doing loops, there is no function/instruction to do that. I asked IT Finance about adding this kind of instruction, don’t know when it will be available.

    #75474 quote
    juanj
    Participant
    Master

    Thank you for the prompt reply Nicolas.

    Currently, I am using loops was just hoping there was an easier way

    #86387 quote
    Hiraokii
    Participant
    Junior

    Bro how do I found the bar index using loops?

    #86396 quote
    Vonasi
    Moderator
    Master

    You can do something like this to find your lowest low in the previous 10 bars barindex.

    myindex = 0
    lowestlow = low
     
    for a = 0 to 9
    if low[a] <= lowestlow then
    lowestlow = low[a]
    myindex = a
    endif
    next
     
    graph myindex
    icharttop thanked this post
    #86397 quote
    Vonasi
    Moderator
    Master

    …or you can do something like this which works slightly faster as it does not need to complete each loop if the lowest low is found earlier in the run.

    myindex = 0
    
    for a = 0 to 9
    if low[a] = lowest[10](low) then
    myindex = a
    break
    endif
    next
    
    graph myindex
    icharttop thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Finding barindex using function


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
juanj @juanj Participant
Summary

This topic contains 5 replies,
has 4 voices, and was last updated by Vonasi
7 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/06/2018
Status: Active
Attachments: No files
Logo Logo
Loading...