First candle with a lower low

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #16957 quote
    Johan
    Participant
    Average

    I need to get the recent lower candle. How is this made? Have tried summation but in that case, say if i put in [5], i can get an even lower candle and also, a candle thats not lower then the closing one. I need the first candle that has a lower low then the closing candle.

    Any suggestions?

    #16959 quote
    Nicolas
    Keymaster
    Master
    To get the lower low, you only need to use the Lowest instruction : get the recent lowest low
    #17055 quote
    Johan
    Participant
    Average
    Thanks Nicolas! I’ve tried that. But if, lets say that there are five lower candles after each other, “lowest” is going to pick the last candle since that’s the absolut lowest one. I want the get the low of the first. But if the first and the second have a higher low and then the third have a lower, then i want to pick the third. I did a strict “if” solution:
    //Recent low
    if (low > low[1]) then
    rl = low[1]
    rlBar = 1
    elsif (low > low[2]) then
    rl = low[2]
    rlBar = 2
    elsif (low > low[3]) then
    rl = low[3]
    rlBar = 3
    elsif (low > low[4]) then
    rl = low[4]
    rlBar = 4
    elsif (low > low[5]) then
    rl = low[5]
    rlBar = 5
    else
    rl = low - (x * pipSize)
    rlBar = 6
    endif
    …but rather have a function that can stretch back in time until it finds the lower low and then stop.
    #17070 quote
    Nicolas
    Keymaster
    Master
    I’m not sure to understand well, but you can refer to the last lower low previous of the current candle like this:
    ll = lowest[5](low)[1]
    You’ll get the lowest low of the 5 previous candlesticks before the current one.
    #17080 quote
    Johan
    Participant
    Average
    Yes. But i need the the first low. Not the last. The first candle who has a lower low. Should be simple but i cant get my head around it 🙂
    #17091 quote
    GraHal
    Participant
    Master
    Hi Johan First low, Last Low?? Out of 5 bars / candles there is only one bar that will be the lowest low (out of 5) and Nicolas code above will give you that. Or do you want the low (in price?) of the first of 5 previous candles? I am intrigued so get back to us please? Regards GraHal
    #17112 quote
    JC_Bywan
    Moderator
    Master
    I must admit I didn’t understand your question the first time around, now I think I do but to be honest, I’m still not sure… Let’s assume I have understood the question correctly, then I’ve come up with this to solve it. However, we need to be aware a “while” loop could end up in some cases being considered as an infinite loop without solution returning an error message, that’s why I’ve included a maximum number of candles to look back, you can change this number in case the chosen 100 value is not enough for your needs. The main return is “barnumber”, it gives you the barindex value of the candle in the past with the most recent lower low than your current candle’s low. For easier visual localisation of such bar number found, I’ve added “barindex” in the return line too. And I’ve added another line parallel to barindex which shows the oldest candle search limit in the past (the safeguard against infinite loop). When “barnumber” touches it, it means there was no success finding a lower low within the maximum chosen number of candles to look back. That would be a probuilder piece of code of course. How you include this and make use of it within a larger piece of pro-order code and without the return line is up to you. Just remember to separate cases when a lower low is found before the limit, from cases it isn’t.
    // Finding candle with most recent lower low than current candle's low
    // to help a fellow PRC forum member
    // By Noobywan Nov.24 2016
    //
    i=1
    maxcandlelookback=100
    oldest=barindex-maxcandlelookback-1
    while low[i]>=low do
       i=i+1
       if i>maxcandlelookback then
          break
       endif
    wend
    barnumber=barindex-i
    
    return barnumber as "candle number of most recent lower low", barindex as "barindex", oldest as "oldest candle search limit"
    Nicolas and Johan thanked this post
    #17429 quote
    Johan
    Participant
    Average
    Right on the money. This was exactly what i was looking for. Thanks a lot Noobywan!
    #17433 quote
    Johan
    Participant
    Average
    Another thing… Might even be suited for a new topic, but when i “graph” values like barindex they always start from 1000 for some reason. How can i get the barindex to graph from 0? Have anybody stumble upon this?
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

First candle with a lower low


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Johan @johan_holmberg Participant
Summary

This topic contains 8 replies,
has 4 voices, and was last updated by Johan
9 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/22/2016
Status: Active
Attachments: No files
Logo Logo
Loading...