Maximum rise and fall in x candles indicator

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #104090 quote
    Vonasi
    Moderator
    Master

    I coded this little indicator to check what has been the historical maximum rise or fall from the open in x candles after the open. The idea being that you might for example be willing to give a trade x number of weeks or x number of days to play out and it would be helpful to know what sort of risk this could leave you open to. We all know that the past does not repeat in the future but at least we can have some rough idea how bad it might be from what has already happened.

    In the attached image we can see that the DJI has had a maximum rise from open in two weeks of 1792.2 and a maximum fall from open of 3498.2. That maximum fall would have been a horrible two weeks if you’d opened a long trade and given it two weeks breathing room to get going!

    I post the indicator here in case it is of use to anyone.

    x = 4 //set to however many candles you want to test
    
    once ll = high
    if barindex > x then
    hh = highest[x](high)
    maxrise = max(maxrise, hh-open[x-1])
    
    ll = lowest[x](low)
    maxfall = max(maxfall, open[x-1]-ll)
    endif
    
    return maxrise as "maximum rise", maxfall as "maximum fall"
    Bard thanked this post
    Screenshot_5-1.png Screenshot_5-1.png
    #105086 quote
    Malend
    Participant
    Average

    Hi Vonasi,
    I am new in this forum and I have programmed some basic personal indicators. So please if this question has passed this forum allready, my apologizes. I think my question is related to your indicator in a way. The difference is that yours is related to a fixed time of 4days or weeks or minutes. Mine is related to a certain price after the open.

    I have an indicator which marks the entering point of a possible trade. I am looking for a way to display in the chart at the entering candle if it has reached my target “price+100″ earlier then my stop loss”price-25”. So If it has reached my target befor the stop loss.

    indicator1: SMA[10]
    indicator2: close[1]

    c1 = indicator2 > indicator1

    And now the part I am struggling with…
    After c1 there can be 2 scenario’s, Scenario 1 is that the price will reach close[1] + 10 or Scenario2 is that the price will reach close[1] – 2. The scneario which shows up first is the one I want to see and display at the close[1] candle. The dispalying is n ot an issue for me.

    Can you help me out with this, taht would be amazing. Thanks, Marc

    So actually I want to use it as part of the indicator to backtest.

    Thank you, Marc

    #105100 quote
    Vonasi
    Moderator
    Master

    Please do not double post. Double posting just wastes the time of those who are trying to help you. I have deleted your other topic with an identical question.

    It is impossible in an indicator to tell whether a candle reached a high price before a low price or a low price before a high price as what an indicator outputs is finalised at the close of a candle except for the presently forming candle which is on the fly prior to it closing. If MTF was available for indicators then it would be possible but at present MTF is only available in ProOrder for strategies. If your indicator is just giving you entry and exit conditions then just code it as a strategy and use GRAPH or GRAPHONPRICE in an MTF strategy to highlight candles that meet your entry and exit conditions. Using MTF in a strategy will however massively reduce the data available for the back test.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Maximum rise and fall in x candles indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Vonasi @vonasi Moderator
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 08/03/2019
Status: Active
Attachments: 1 files
Logo Logo
Loading...