# How to modify the indicator to work with CDZV Toolkit

{% hint style="info" %}
For modification the indicator must be written in pine-script version 5

//@version=5
{% endhint %}

To integrate with CDZV Toolkit, you can use TradingView indicators that display information using the [**plot**](https://www.tradingview.com/pine-script-reference/v5/#fun_plot) function.

All other indicators that are open source can be easily **modified**.

**CDZV Toolkit** processes two types of input information from indicators:

1. *Numeric values* (price, volume and any other **floating point numeric value**).
2. *Signal* (this is also a numeric value, but it is limited: **0 - no signal** or **1 - signal is present**).

These values can be sent from the indicator using the *PineScript* **plot()** function with the parameter **display = display.data\_window**. This parameter indicates that we do not draw anything on the plot, but will be available to the **CDZV Toolkit**.

***Examples**:*

1️⃣ The indicator draws BUY/SELL labels on the chart or sends alerts. We need to pass them to Condition Manager as signals. <https://www.tradingview.com/script/lSHzm9zV-CM-I-RideTheWave7/>

```
// Here the original indicator draws the inscriptions
plotshape(buySignalk[1] and showsignalsk and O1[1] > K2 ? AlphaTrend[2] * 0.9999 : na, title='LONG', text='LONG', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(#0022FC, 0), textcolor=color.new(color.white, 0))
plotshape(sellSignalk[1] and showsignalsk and O2[1] > K1 ? AlphaTrend[2] * 1.0001 : na, title='SHORT', text='SHORT', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.maroon, 0), textcolor=color.new(color.white, 0))

// Here the original indicator sends alerts
alertcondition(buySignalk[1] and O1[1] > K2, title='Confirmed BUY Alarm', message='BUY SIGNAL APPROVED!')
alertcondition(sellSignalk[1] and O2[1] > K1, title='Confirmed SELL Alarm', message='SELL SIGNAL APPROVED!')
```

Make modifications to the indicator code:

```
// We add code to send signals to the CDZV Toolkit
// We define the logic for drawing and sending signals
// and create a plot() object that sends a 0 or 1 signal.
plot(buySignalk[1] and O1[1] > K2 ? 1 : 0, "SIGNAL: BUY", display = display.data_window)
plot(sellSignalk[1] and O2[1] > K1 ? 1 : 0, "SIGNAL: SELL", display = display.data_window)
```

Result:

<figure><img src="https://754838710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYAV7aJldax3OC32dTSHO%2Fuploads%2FsIODCP5UzGYaKlJawCZE%2Fimage.png?alt=media&#x26;token=1d29661c-3dc3-4063-b018-204a8209da9c" alt=""><figcaption></figcaption></figure>

2️⃣ The indicator draws fractals/pivots on the chart. It is necessary to transfer their price to **CDZV Toolkit**. <https://www.tradingview.com/script/1yk1pUCb-CM-I-Williams-Fractals/>

```
// The indicator draws fractals from above and below with offset=-n
plotshape(downFractal, style=shape.triangledown, location=location.belowbar, offset=-n, color=#F44336, size = size.small)
plotshape(upFractal, style=shape.triangleup, location=location.abovebar, offset=-n, color=#009688, size = size.small)
```

add the code that passes the price to **CDZV Toolkit**:

<figure><img src="https://754838710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYAV7aJldax3OC32dTSHO%2Fuploads%2Fmj7hfxYMVO7lmBLjH7ok%2Fimage.png?alt=media&#x26;token=bf815e68-efab-4e12-b80f-a3a2cd087f99" alt=""><figcaption></figcaption></figure>

```
// get the Low and High price if a fractal was found earlier
if upFractal
    last_up_price := high[n]

if downFractal
    last_down_price := low[n]

// We add code to send fractal prices to CDZV Toolkit
// create a plot() object that sends a price (a number with a plaвающей запятой)
plot(last_up_price, title = 'UP Price', display = display.data_window)
plot(last_down_price, title = 'DOWN Price', display =display.data_window)
```

Result:

<figure><img src="https://754838710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYAV7aJldax3OC32dTSHO%2Fuploads%2FxPeT74RMu1VVdWv5VcxJ%2Fimage.png?alt=media&#x26;token=677d5cb5-dedc-46e5-b77a-1acac90997cb" alt=""><figcaption></figcaption></figure>

3️⃣ The indicator draws an oscillator that changes its color and it is necessary to transmit signals when the oscillator is **GREEN** or **RED**. <https://www.tradingview.com/script/JUK476pQ-CM-I-Schaff-Trend-Cycle-STC/>

```
// Find the code responsible for the oscillator color
mSTC = STC(defLen, fastLen, slowLen)
mColor = mSTC > mSTC[1] ? color.new(color.green, 20) : color.new(color.red, 20)

plot(mSTC, color=mColor, title='STC', linewidth=2)
```

and below that add logic that will send a **GREEN**/**RED** signal

```
plot(mSTC > mSTC[1] ? 1 : 0, 'SIGNAL: GREEN', display = display.data_window)
plot(mSTC <= mSTC[1] ? 1 : 0, 'SIGNAL: RED', display = display.data_window)
```

Result:

<figure><img src="https://754838710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYAV7aJldax3OC32dTSHO%2Fuploads%2F7Fvlx89JymKohZLOQDs5%2Fimage.png?alt=media&#x26;token=637c0abc-dc0c-493a-8909-b7b477a83a1e" alt=""><figcaption></figcaption></figure>
