ROCKI
ROCKI

Reputation: 1

IQOption Script | QuadCode

I have an iqoption script (quadcode, https://quadcode-tech.github.io/quadcodescript-docs) that, if certain ema and hist functions are met, for example, if ema > a hist, makes all candles that meet this condition turn red and 90% of the time, whenever a candle turns red or green, it has at least 1 or 2 more with the same color. What I did was implement a signal system with plotshape that indicates when to buy and when to sell. What happens is that, as I told you before, whenever a candle turns a certain color, the next one follows the trend of that candle. For example, if the candle turns red, the next one is usually red too. The problem I have is that I made the indicator generate a sell or buy signal every time a candle turns red or green, since the next candle is usually the same color, what I want is for the signal not to be generated on all candles in the trend. I want it to be plotted only on the first candle in the trend of bars which are painted by the indicador.

enter image description here


instrument {
    name = 'ETM PROFIT',
    short_name = 'ETM',
    icon = 'https://etmtradingbucket.s3.amazonaws.com/public/logo.png',
    overlay = true
}

Signal_period = input(5,"VIP | Signals Period",input.integer,1,1000,1)

input_group {
    "Compra Proxima vela",
    colorBuy = input { default = "green", type = input.color }, 
    visibleBuy = input { default = true, type = input.plot_visibility }
}

input_group {
    "Venda Proxima vela",
    colorSell = input { default = "red", type = input.color },
    visibleSell = input { default = true, type = input.plot_visibility }
}

input_group {
    "MACD",
    "Slow and fast EMA periods, used in MACD calculation",
    fast = input (12, "front.platform.fast period", input.integer, 1, 250),
    slow = input (26, "front.platform.fast period", input.integer, 1, 250)
}
input_group {
    "front.platform.signal-line",
    "Reference signal series period",
    signal_period = input (9, "front.period", input.integer, 1, 250)
}
input_group {
    "front.newind.emaperiod",
    ema_period = input (13, "front.period", input.integer, 1, 250)
}
input_group {
    "front.newind.barcolors",
    positive = input { default = "#2CAC40",   type = input.color },
    neutral  = input { default = "#C7CAD1", type = input.color },
    negative = input { default = "#DB4931",   type = input.color },
}
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, signal_period)
hist = macd - signal
ema13 = ema (close, ema_period)
local bar_color
        
    if ema13 > ema13 [1] and hist > hist [1] then
    bar_color = positive
elseif ema13 < ema13 [1] and hist < hist [1] then
    bar_color = negative
else
    bar_color = neutral
end
plot_candle (open, high, low, close, "ES", bar_color)
buyCondition = conditional(ema13 > ema13 [1] and hist > hist [1])

sellCondition = conditional(ema13 < ema13 [1] and hist < hist [1])

            plot_shape(
                (buyCondition),
                "",
                shape_style.triangleup,
                shape_size.huge,    
                colorBuy,    
                shape_location.belowbar,
                0,
               "RX-Buy",
                "pink"
               ) 

          plot_shape(
              (sellCondition),
                "ENTER",
                shape_style.triangledown,
                shape_size.huge,
                colorSell,
                shape_location.abovebar,
                0,
                "RX-Sell",
                "salmon"
          )

The problem I have is that I made the indicator generate a sell or buy signal every time a candle turns red or green, since the next candle is usually the same color, what I want is for the signal not to be generated on all candles in the trend. I want it to be plotted only on the first candle in the trend of bars which are painted by the indicador.

Upvotes: -1

Views: 11344

Answers (1)

GlamSelva1297934
GlamSelva1297934

Reputation: 137

'use nan.

or

drop_plot_value('i don't want', current_bar_id) drop_plot_value('i don't that', current_bar_id) drop_plot_value('i don't this', current_bar_id)`

Upvotes: -1

Related Questions