Nigel Hawks volume indicator

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #218276 quote
    SVK
    Participant
    Junior

    Hi all,

    would it be possible to translate PineScript indicator to Prorealcode please ?

    Thank you very much

    HawkEye volume, developed by Nigel Hawks, is supposed to be a premier VSA indicator.

    // @author LazyBear
    // If you use this code, in its original or modified form, do drop me a note. Thx.
    //
    study(“HawkEye Volume Indicator [LazyBear]”, shorttitle=”HVI_LB”)
    length=input(200)
    range=high-low
    rangeAvg=sma(range,length)
    volumeA=sma(volume, length)
    divisor=input(3.6)
    high1=high[1]
    low1=low[1]
    mid1=hl2[1]
    u1 = mid1 + (high1-low1)/divisor
    d1 = mid1 – (high1-low1)/divisor
    r_enabled1 = (range > rangeAvg) and (close < d1) and volume > volumeA
    r_enabled2 = close < mid1
    r_enabled = r_enabled1 or r_enabled2
    g_enabled1 = close > mid1
    g_enabled2 = (range > rangeAvg) and (close > u1) and (volume > volumeA)
    g_enabled3 = (high > high1) and (range < rangeAvg/1.5) and (volume < volumeA)
    g_enabled4 = (low < low1) and (range < rangeAvg/1.5) and (volume > volumeA)
    g_enabled = g_enabled1 or g_enabled2 or g_enabled3 or g_enabled4
    gr_enabled1 = (range > rangeAvg) and (close > d1) and (close < u1) and (volume > volumeA) and (volume < volumeA*1.5) and (volume > volume[1])
    gr_enabled2 = (range < rangeAvg/1.5) and (volume < volumeA/1.5)
    gr_enabled3 = (close > d1) and (close < u1)
    gr_enabled = gr_enabled1 or gr_enabled2 or gr_enabled3
    v_color=gr_enabled ? gray : g_enabled ? green : r_enabled ? red : blue
    plot(volume, style=histogram, color=v_color, linewidth=5)
    #218278 quote
    JS
    Participant
    Senior

    Hi @SVK

    Hereby the translation of the HawkEye Volume Indicator…

     

    Length=200
    xRange=Range
    RangeAvg=Average[Length](xRange)
    VolumeAvg=Average[Length](Volume)
    Divisor=3.6
    High1=High[1]
    Low1=Low[1]
    Mid1=(High1+Low1)/2
    u1=Mid1+(High1-Low1)/Divisor
    d1=Mid1-(High1-Low1)/Divisor
    REnabled1=(xRange>RangeAvg) and (Close<d1) and (Volume>VolumeAvg)
    REnabled2=Close<Mid1
    REnabled=REnabled1 or REnabled2
    GEnabled1=Close>Mid1
    GEnabled2=(xRange>RangeAvg) and (Close>u1) and (Volume>VolumeAvg)
    GEnabled3=(High>High1) and (xRange<RangeAvg/1.5) and (Volume<VolumeAvg)
    GEnabled4=(Low<Low1) and (xRange<RangeAvg/1.5) and (Volume>VolumeAvg)
    GEnabled=GEnabled1 or GEnabled2 or GEnabled3 or GEnabled4
    GREnabled1=(xRange>RangeAvg) and (Close>d1) and (Close<u1) and (Volume>VolumeAvg) and (Volume<VolumeAvg*1.5) and (Volume>Volume[1])
    GREnabled2=(xRange<RangeAvg/1.5) and (Volume<VolumeAvg/1.5)
    GREnabled3=(Close>d1) and (Close<u1)
    GREnabled=GREnabled1 or GREnabled2 or GREnabled3
    If GREnabled then
    R=128
    G=128
    B=128
    ElsIf GEnabled then
    R=0
    G=255
    B=0
    ElsIf REnabled then
    R=255
    G=0
    B=0
    EndIf
    Return Volume as "Volume" Coloured(R,G,B) Style(Histogram,2)
    SVK and coincatcha thanked this post
    #218311 quote
    SVK
    Participant
    Junior

    JS,

    thank you very much for your help.

    Works perfect 🙂

    Would you know how can I incorporate signals from this indicator into strategy ?
    Signals would be only Green & Red bars.

    Divisor setting I’m using is 1.5 which reduces amount of green & red bars significantly.

    Thank you very much for your help

    PS.

    If you have Paypal I’m more than happy to send you some beer money 🙂

    #218312 quote
    JS
    Participant
    Senior

    Hi SVK,

    As you’ve probably noticed, Renabled stands for “Red (enabled)”, Genabled for “Green (enabled)” and GREnabled for “Grey (enabled)”…

    If you want to use the green and red signals in a system, you will end up with the following:

    If GEnabled then

    Buy 1 contract at Market

    EndIf

    If REnabled then

    SellShort 1 contract at Market

    EndIf

    Thanks for the offer but is not necessary… 🙂  

    DefParam CumulateOrders=False
    Length=200
    xRange=Range
    RangeAvg=Average[Length](xRange)
    VolumeAvg=Average[Length](Volume)
    Divisor=1.5
    High1=High[1]
    Low1=Low[1]
    Mid1=(High1+Low1)/2
    u1=Mid1+(High1-Low1)/Divisor
    d1=Mid1-(High1-Low1)/Divisor
    REnabled1=(xRange>RangeAvg) and (Close<d1) and (Volume>VolumeAvg)
    REnabled2=Close<Mid1
    REnabled=REnabled1 or REnabled2
    GEnabled1=Close>Mid1
    GEnabled2=(xRange>RangeAvg) and (Close>u1) and (Volume>VolumeAvg)
    GEnabled3=(High>High1) and (xRange<RangeAvg/1.5) and (Volume<VolumeAvg)
    GEnabled4=(Low<Low1) and (xRange<RangeAvg/1.5) and (Volume>VolumeAvg)
    GEnabled=GEnabled1 or GEnabled2 or GEnabled3 or GEnabled4
    GREnabled1=(xRange>RangeAvg) and (Close>d1) and (Close<u1) and (Volume>VolumeAvg) and (Volume<VolumeAvg*1.5) and (Volume>Volume[1])
    GREnabled2=(xRange<RangeAvg/1.5) and (Volume<VolumeAvg/1.5)
    GREnabled3=(Close>d1) and (Close<u1)
    GREnabled=GREnabled1 or GREnabled2 or GREnabled3
    
    If GEnabled then
    Buy 1 contract at Market
    EndIf
    
    If REnabled then
    SellShort 1 contract at Market
    EndIf

    SVK thanked this post
    #218313 quote
    SVK
    Participant
    Junior
    Thank you 🙂 I’m going to try it out and see how it works 🙂
    #218314 quote
    JS
    Participant
    Senior
    Hi SVK, Good luck… Please note; the example is just a “basic” system, both Long and Short, 1 type of order, no MoneyManagement, no StopLoss, no TakeProfit or Trailing…etc. Plenty to do… 🙂
    SVK thanked this post
    #218315 quote
    SVK
    Participant
    Junior
    I have done following and it doesn’t work 🙁 On a graph you can see that Grey bars are highlighted as green.
    //Volume
    Length=200
    xRange=Range
    RangeAvg=Average[Length](xRange)
    VolumeAvg=Average[Length](Volume)
    Divisor=1.5
    High1=High[1]
    Low1=Low[1]
    Mid1=(High1+Low1)/2
    u1=Mid1+(High1-Low1)/Divisor
    d1=Mid1-(High1-Low1)/Divisor
    REnabled1=(xRange>RangeAvg) and (Close<d1) and (Volume>VolumeAvg)
    REnabled2=Close<Mid1
    REnabled=REnabled1 or REnabled2
    GEnabled1=Close>Mid1
    GEnabled2=(xRange>RangeAvg) and (Close>u1) and (Volume>VolumeAvg)
    GEnabled3=(High>High1) and (xRange<RangeAvg/1.5) and (Volume<VolumeAvg)
    GEnabled4=(Low<Low1) and (xRange<RangeAvg/1.5) and (Volume>VolumeAvg)
    GEnabled=GEnabled1 or GEnabled2 or GEnabled3 or GEnabled4
    GREnabled1=(xRange>RangeAvg) and (Close>d1) and (Close<u1) and (Volume>VolumeAvg) and (Volume<VolumeAvg*1.5) and (Volume>Volume[1])
    GREnabled2=(xRange<RangeAvg/1.5) and (Volume<VolumeAvg/1.5)
    GREnabled3=(Close>d1) and (Close<u1)
    GREnabled=GREnabled1 or GREnabled2 or GREnabled3
    
    IF GEnabled then
    VolumeON = 1
    ELSE
    VolumeON = 0
    ENDIF
    #218319 quote
    SVK
    Participant
    Junior
    Tried code on it’s own and I’m getting the same result. I have added green vertical lines to highlight where Red graph should allign with.  
    DefParam CumulateOrders=False
    Length=200
    xRange=Range
    RangeAvg=Average[Length](xRange)
    VolumeAvg=Average[Length](Volume)
    Divisor=1.5
    High1=High[1]
    Low1=Low[1]
    Mid1=(High1+Low1)/2
    u1=Mid1+(High1-Low1)/Divisor
    d1=Mid1-(High1-Low1)/Divisor
    REnabled1=(xRange>RangeAvg) and (Close<d1) and (Volume>VolumeAvg)
    REnabled2=Close<Mid1
    REnabled=REnabled1 or REnabled2
    GEnabled1=Close>Mid1
    GEnabled2=(xRange>RangeAvg) and (Close>u1) and (Volume>VolumeAvg)
    GEnabled3=(High>High1) and (xRange<RangeAvg/1.5) and (Volume<VolumeAvg)
    GEnabled4=(Low<Low1) and (xRange<RangeAvg/1.5) and (Volume>VolumeAvg)
    GEnabled=GEnabled1 or GEnabled2 or GEnabled3 or GEnabled4
    GREnabled1=(xRange>RangeAvg) and (Close>d1) and (Close<u1) and (Volume>VolumeAvg) and (Volume<VolumeAvg*1.5) and (Volume>Volume[1])
    GREnabled2=(xRange<RangeAvg/1.5) and (Volume<VolumeAvg/1.5)
    GREnabled3=(Close>d1) and (Close<u1)
    GREnabled=GREnabled1 or GREnabled2 or GREnabled3
     
    If GEnabled then
    Buy 1 contract at Market
    EndIf
    
    // Stops and targets
    SET STOP pLOSS 11
    SET TARGET pPROFIT 11
    
    graph GEnabled coloured(220,20,60) //RED
    #218321 quote
    JS
    Participant
    Senior
    Hi SVK, Strange, I think it’s because there’s an overlap between the different conditions… When you try like this you get the right result…
    //Volume
    Length=200
    xRange=Range
    RangeAvg=Average[Length](xRange)
    VolumeAvg=Average[Length](Volume)
    Divisor=1.5
    High1=High[1]
    Low1=Low[1]
    Mid1=(High1+Low1)/2
    u1=Mid1+(High1-Low1)/Divisor
    d1=Mid1-(High1-Low1)/Divisor
    REnabled1=(xRange>RangeAvg) and (Close<d1) and (Volume>VolumeAvg)
    REnabled2=Close<Mid1
    REnabled=REnabled1 or REnabled2
    GEnabled1=Close>Mid1
    GEnabled2=(xRange>RangeAvg) and (Close>u1) and (Volume>VolumeAvg)
    GEnabled3=(High>High1) and (xRange<RangeAvg/1.5) and (Volume<VolumeAvg)
    GEnabled4=(Low<Low1) and (xRange<RangeAvg/1.5) and (Volume>VolumeAvg)
    GEnabled=GEnabled1 or GEnabled2 or GEnabled3 or GEnabled4
    GREnabled1=(xRange>RangeAvg) and (Close>d1) and (Close<u1) and (Volume>VolumeAvg) and (Volume<VolumeAvg*1.5) and (Volume>Volume[1])
    GREnabled2=(xRange<RangeAvg/1.5) and (Volume<VolumeAvg/1.5)
    GREnabled3=(Close>d1) and (Close<u1)
    GREnabled=GREnabled1 or GREnabled2 or GREnabled3
    
    IF GEnabled and NOT REnabled and NOT GREnabled then
    VolumeON = 1
    ELSE
    VolumeON = 0
    ENDIF
    
    Return VolumeOn as "VolumeON" Coloured("Green")
    coincatcha thanked this post
    #218323 quote
    SVK
    Participant
    Junior
    Hi LS, Let me try 🙂
    
    
    #218337 quote
    SVK
    Participant
    Junior
    JS, looks good to me 🙂 Thank you very much
    JS thanked this post
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

Nigel Hawks volume indicator


ProBuilder support

New Reply
Author
author-avatar
SVK @svk Participant
Summary

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

Topic Details
Forum: ProBuilder support
Language: English
Started: 07/28/2023
Status: Active
Attachments: 5 files
Logo Logo
Loading...