Custom Study

I am creating a custom study. Basically, I want to identify Bar X... where X is marked when Range(@) > MA((Range(@)[-1]),Exp,10); now what I want to do is WHEN the bar range exceeds the range of the prior 10 bars, I want to Draw a line from the 50% line. I know I am drawing today the Open and Close of the Bar X via 2 curves close/open(@)[0] when Range(@) > MA((Range(@)[-1]),Exp,10); ... but again, how do I say @ 50% of that bars price, I want to draw another curve? it is unclear from all your docs...

Comments

  • Hi,
    You may create another Curve under your existing Custom Study and use either:

    Mid(@) when (Range(@) > MA((Range(@)[-1]),Exp,10))
    or
    ((High(@)+Low(@))/2) when (Range(@) > MA((Range(@)[-1]),Exp,10))

    This will give you the 50% point of the bar you want to reference. When displaying this custom Study, ensure you are setting Sharescale to ON by right-clicking on the custom study, Modify, clicking under Display and set Sharescale to "On".
  • ok, I will try that... btw.. here is another question... I want to mark a bar when the following conditions meet... assume X[-1] is the bar... and I want to mark it when X[-2] and X[0] share no price. or have no overlap.. meaning if X[-2] was L=10.50 and H=11.50 and X[0] has a L=11.75 and H=12.25, then X[-1] is marked... as there was no price overlap... I've tried to do it with ABS, since I need to account for X[0] being L=9.5 and H=10 which would still have no overlap, but it is not working at all.. any suggestions?
  • High(@)[-1] < low(@) and high(@)[-1] < low(@)[-2] And Low(@)[-1] > high(@) and low(@)[-1] > high(@)[-2]

    The above is going to a pretty rare occurrence.

    (High(@)[-1] < low(@) and high(@)[-1] < low(@)[-2]) or (Low(@)[-1] > high(@) and low(@)[-1] > high(@)[-2])

    If testing for just one side.
  • btw, using MID or even AVG works fine... but when switching to anything to get a % it doesnt work quite fine.. as an example, I tried the following:

    (Open(@)-(Abs(Range(@)*.4)))

    but I keep running into the issue that it will overshoot whenever the bar is negative or positive (depending)
  • aha!... your prior response, which I hadnt read yet before I posted my other question gave me an idea to loop in an IF and test for the bar condition.. so I was able to do this..

    IF(Close(@)>;Open(@), Close(@)-Abs(((Open(@)-Close(@))*retracepct)), Open(@)-((Open(@)-Close(@))*retracepct))

    that works so far...

    lastly, is there no way to shade an area?
  • ok, with your example I was able to just in writing determine the conditions to identify no-overlapping of pricing, depending on the "trend" ..

    IF(Open(@) High(@)[-2])
    when Abs(Open(@)[-1]-Close(@)[-1]) > Abs((Open(@)[-2])-(Close(@)[-2]))

    however here is my issue... I only want the bar to be marked where the conditions takes place.. what happens now is that for as long as the condition remains true it marks all of the bars... which is not what I want...

    so assume 10 candles..

    C0... C9 with current candle being C9..

    the condition "the WHEN" takes place in C5, therefore I will evaluate C6 to make sure that price does not overlap C4, but only if C5 was a condition, follow? thats what they above does.. but what I want is to market C5 only when C5 <> C4... and thats it... the above code marks every single candle, until another condition is met.. in this case the condition to decide on a new comparison, which turns out to be a true condition but the comparison yields false.. thus nothing is marked.
  • edited June 29
    IF(Open(@) < Close(@)[-1], High(@) < Low(@)[-2], Low(@) > High(@)[-2])
    when Abs(Open(@)[-1] - Close(@)[-1]) > Abs((Open(@)[-2]) - (Close(@)[-2]))

    IF the Open of the Bar is less than the close of the previous bar (down trend candle), we want to determine if the high of the current bar is less than the low of two bars ago... otherwise (it is an uptrend) so we want to check if the Low of the current bar is higher than the high of two bars ago... meaning the current bar does not share any ticks with the candle two time periods ago (assume 5m for example).. logic says that if i am trending up, I have higher lows thus possibly higher lows than my previous 2 bars ago last high.

    now, I only want to make that check if the range of 1 bar ago is greater than the range of 2 bars ago... IF and ONLY IF when the range(@)[-1] > range(@)[-2] is when I want to check if the price of [0] overlaps with [-2]...

    does it makes sense now?

    when the prices do not overlap, then I want to mark the candle before (the middle candle) or [-1]...


  • it wouldnt let me add the pic after I created the post.,
    CQG.jpg 272.6K
  • Hi,

    Your code can actually be simplified. The "IF" is not necessary in this case.
    For the Downtrend, the following code will highlight the bar after the "big range" bar so long as the high is lower than the low[-2], which means that you can only be sure that the condition is totally valid when the bar is completed:
    Open(@) < Close(@)[-1]
    AND
    High(@) < Low(@)[-2]
    AND
    Range(@)[-1] > Range(@)[-2]


    According to your explanation, you are after the big range bar (middle bar) when this condition occurs, so for example, to identify the Close of that bar, you can use:
    Close(@)[-1] WHEN ( Open(@) < Close(@)[-1]
    AND
    High(@) < Low(@)[-2]
    AND
    Range(@)[-1] > Range(@)[-2])


    For the Uptrend, the formula is:
    Close(@)[-1] WHEN (Open(@) > Close(@)[-1]
    AND
    Low(@) > High(@)[-2]
    AND
    Range(@)[-1] > Range(@)[-2])
  • Another important point, the above formula, as a Custom Study, returns a value (the Close when the condition occurs). If you are after a Condition that marks the bar itself, you would need to offset your condition to the future (since you only know the middle bar condition is valid when the next bar is closed), which is not recommended. It is best to highlight the next bar in order to have a firm signal.
Sign In or Register to comment.