I’m trying to port Lazy Bear Hawk Eye Volume indicator into the Haasscript, calculations are good but have offset while Plotting

  • 2 Answers
    343 Views
    asked 1 year ago

    I'm trying to port Lazy Bear Hawk Eye Volume indicator into the HaasScript, calculations and sequence of bar color are good but have offset while Plotting by 1 bar backwards, is anybody knows how to fix that ?

    -- Define command parameters. local chartIndex = DefineParameter(NumberType, 'chartIndex', 'The index on which to chart', true, 1, 'Number') local name = DefineParameter(StringType, 'name', 'Unique name of the indicator.', true, '', 'Text') local interval = DefineParameter(NumberType, 'interval', 'Used interval for price data. Default is 0 and the main interval will be used.', true, 0, 'Number,InputInterval') DefineIntervalOptimization(interval) --Define inputs local length = Input('SMA Length', 200) local HV_ma = Input('HV_ma', 20) local divisor = Input('Divisor',3.6) local high = HighPrices() local low = LowPrices() local range = high - low local rangeAvg = SMA(range,length) local volume = GetVolume() local close = ClosePrices() local sma = SMA(volume, HV_ma) local volumeA = SMA(volume, length) --Calculations local high1 = high[2] local low1 = low[2] --local high1 = HighPrices()[2] --local low1 = LowPrices()[2] local mid1 = (high1+low1)/2 local u1 = mid1 + (high1-low1)/divisor local d1 = mid1 - (high1-low1)/divisor local r_enabled1 = (range > rangeAvg) and (close volumeA local r_enabled2 = close mid1 local g_enabled2 = (range > rangeAvg) and (close > u1) and (volume > volumeA) local g_enabled3 = (high > high1) and (range < rangeAvg/1.5) and (volume < volumeA) local g_enabled4 = (low < low1) and (range volumeA) local g_enabled = g_enabled1 or g_enabled2 or g_enabled3 or g_enabled4 local gr_enabled1 = (range > rangeAvg) and (close > d1) and (close volumeA) and (volume volume[2]) local gr_enabled2 = (range < rangeAvg/1.5) and (volume d1) and (close < u1) local gr_enabled = gr_enabled1 or gr_enabled2 or gr_enabled3 --Bar Color local v_color = gr_enabled and Gray or g_enabled and Green or r_enabled and Red or Blue --Plotting CC_PlotVarColor(chartIndex, "Volume", volume, v_color, "Bars") Plot(chartIndex, "SMA", sma, LineOptions({color=Orange, width=2}))

2 Answers

  • 1

    Hi there!

    First of all, thanks for the script. This showed us that the parsing of code doesn't work properly... Case reported though. ;)

    Secondly, I don't think there is a problem with your calculations related to HawkEye, but in the CC you are using to plot with variable colors. I think it is changing the color 1 bar too soon, so you gotta figure out another way to do it (or contact the maker of that CC for further assistance).

    ~pshai

  • 0

    Ok, so I've found an issue. It was in CC_PlotVarColor command, I updated it slightly and now it's work correctly, thanks !)

Your Answer

Not the answer you're looking for? Browse other questions tagged chartinghaascriptpinescript or ask your own question.