Skip to main content
All CollectionsFAQs and Troubleshooting
How to connect with CryptoHopper
How to connect with CryptoHopper

How to connect with CryptoHopper

Raldrich Oracion avatar
Written by Raldrich Oracion
Updated over a week ago

Prerequisites

  • Add your APIs to the Cryptohopper

    • at least Essential Plan or higher plan

    • set 2-factor authentication

    • Add TradingView Username to the Token Metrics-Settings-Trading View Details to get access to the Token Metrics Indicator

Add Token Metrics Indicator to TradingView

1.) Open BTCUSDT, and add Token Metrics Indicator to the chart.

2.) Change Token Metrics Indicator order size. It will cause duplicate buys if we set multiple orders. So, we will likely buy with all the money and sell all the holdings every time.

Order size - 100 %

Pyramiding - 1 orders


Set up a Cryptohopper bot

1.) Select Trading Bot

2.) Click Configure yourself In the upper right corner, set the information for the bot. Here is an example,

  • Basic settings

    • name: Token Metrics Indicator Bot

  • Exchange

    • Paper trading (sandbox trading) or input your API keys

  • Buy settings

    • Set the order type to market We want to ensure the order is filled out when there is a signal.

  • Coins and amounts

    • Select the Quote current as USDT and allowed coins as Bitcoin (BTC)

    • Set the order, the Minimal USDT amount per order, as 100



Let the bot act following the signal from Token Metrics Indicator

1.) Go back to TradingView
2.) Click "Alert”.

3.) Fill in the “Conditions". Every indicator shows different fields.
4.) For example, select how often you want to send a TradingView Alert to your bot. BTCUSDT 1D.

5.)Fill in the expiration time.

6.) Under “Notification” check the “Webhook URL” options.

<aside> 💡 To check the Webhook URL, you must be:

  • at least Essential Plan or higher plan

  • set 2-factor authentication </aside>

7.) You can go back to your Cryptohopper account.

8.) Click “Marketplace”.

9.) Click “Apps”.

10.) Click “TradingView”.

11.) There you find the Alert Generator.

12.) Select the bot that needs to receive the TradingView Alert.

13.) Fill in the currency symbol, excluding the quote currency.

14.) Fill in the Action

15.) Select the Order Type.

16.) Click on "Generate".

17.) Paste the Alert Message into the Message on TradingView.

18.) Paste the Webhook URL from CryptoHopper to the trading view Webhook URL.

19.) Click Create

Checking bot status


If you have any questions or concerns regarding the article please send us a message through our support channel.

Pine Script

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tokenmetrics

//@version=5

//Define Strategy

strategy("Token Metrics Indicator", overlay=true, pyramiding = 4, default_qty_value=25, default_qty_type=strategy.percent_of_equity, initial_capital=1000)

// Inputs

long_term = input.bool(true, "long-term strategy (>= 1d)", group = "Strategy type")
short_term = input.bool(false, "high-frequency strategy (<= 1h)", group = "Strategy type")
trendline = input.bool(true, "show trendline", group = "Appearance")
channel = input.bool(true, "show channel", group = "Appearance")
strategyType = input.string("LongShort", "Strategy Type", options = ["LongShort", "LongOnly", "ShortOnly"])
longOnly = strategyType == "LongOnly"
shortOnly = strategyType == "ShortOnly"


// Enter back testing period


startDate = input.time(timestamp("2018-01-01T00:00:00"), "Start Date", group = "Back testing period")
endDate = input.time(timestamp("2040-01-01T00:00:00"), "End Date", group = "Back testing period")

backtestPeriod = if (time > startDate) and (time < endDate)
true // forms part of entry condition
else
false // forms part of entry condition


// check if current bar is after start date, BOOL
// afterStartDate = time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0)


// Short-term
// Parameters
init = input.int(9, "Look-back Bars", group = "High-frequency parameters")


high_factor = 0.3

low_factor = 0.3


stop = if short_term
input.float(2, "Stop-loss(%)", group = "High-frequency parameters")*0.01


// Adaptive Donchian Logic

// Define functions (highest and lowest don't work with series__integer type)
maximum(length) =>
out = high
for i = 1 to length-1
out := math.max(out, high[i])
out
minimum(length) =>
out = low
for i = 1 to length-1
out := math.min(out, low[i])
out

// Initialize variables
upn = init
dnn = init
upper = ta.highest(init)
lower = ta.lowest(init)

// update variables
// upn := upper==high ? upn+adj : (lower==low ? upn-adj : upn)
// dnn := upper==high ? dnn-adj : (lower==low ? dnn+adj : dnn)
// upadj := round(upn*factor)
// dnadj := round(dnn*factor)
if upper == high
upn := math.round(upn*high_factor)
dnn := math.round(dnn*(1-low_factor))
if lower == low
upn := math.round(upn*(1-high_factor))
dnn := math.round(dnn*low_factor)
if lower != low and upper != high
upn := math.round(upn*(1-high_factor))
dnn := math.round(dnn*(1-low_factor))
upper := maximum(upn)
lower := minimum(dnn)

upper_lag = upper[1]
lower_lag = lower[1]

// Plots
// TM Channel (Adaptive Donchian Channel)
col_channel = if channel
color.new(#0073ff, 0)
p1 = plot(upper, color = col_channel, title="Upper Channel")
p2 = plot(lower, color= col_channel, title="Lower Channel")
plot((upper+lower)/2, color=col_channel, title="Mid Channel")


// Define conditions

// longCondition
longCondition_short = ta.crossunder(close, lower_lag)

// shortCondition
shortCondition_short = ta.crossover(close, upper_lag)


// Trading

// Stoploss
longLastClose = close[0]
shortLastClose = close[0]


// longStop = if long_term
// input.float(8, "(long-term)Long Stop-loss(%)")*0.01
// else if short_term
// input.float(2, "(high-frequency)Long Stop-loss(%)")*0.01

// Open position
if (longCondition_short and short_term and backtestPeriod)
longLastClose := close
strategy.entry("long", strategy.long)


if (shortCondition_short and short_term and backtestPeriod)
shortLastClose := close
strategy.entry("short", strategy.short)


// Trading stop-loss

if (strategy.position_size > 0 and short_term)
if close > longLastClose
longLastClose := close
strategy.exit(id="exit", stop=longLastClose * (1 - stop))
if (strategy.position_size < 0 and short_term)
if close < shortLastClose
shortLastClose := close
strategy.exit(id="exit", stop=shortLastClose * (1 + stop))




// Long-term

// TM Trendline
// Original Hilbert by everget : https://www.tradingview.com/script/aaWzn9bK-Ehlers-MESA-Adaptive-Moving-Averages-MAMA-FAMA/ {
len = input(20, title='MA Length', group = "Long-term parameters")
DClen = input(20, title='Channels Length', group = "Long-term parameters")
src = input(close, title='Source', group = "Long-term parameters")

PI = 2 * math.asin(1)
fastclose = ta.sma(close, 1)

hilbertTransform(src) =>
0.0962 * src + 0.5769 * nz(src[2]) - 0.5769 * nz(src[4]) - 0.0962 * nz(src[6])

computeComponent(src, mesaPeriodMult) =>
hilbertTransform(src) * mesaPeriodMult

computeAlpha(src, fastLimit, slowLimit) =>
mesaPeriod = 0.0
mesaPeriodMult = 0.075 * nz(mesaPeriod[1]) + 0.54

smooth = 0.0
smooth := (4 * src + 3 * nz(src[1]) + 2 * nz(src[2]) + nz(src[3])) / 10

detrender = 0.0
detrender := computeComponent(smooth, mesaPeriodMult)

// Compute InPhase and Quadrature components
I1 = nz(detrender[3])
Q1 = computeComponent(detrender, mesaPeriodMult)

// Advance the phase of I1 and Q1 by 90 degrees
jI = computeComponent(I1, mesaPeriodMult)
jQ = computeComponent(Q1, mesaPeriodMult)

I2 = 0.0
Q2 = 0.0

// Phasor addition for 3 bar averaging
I2 := I1 - jQ
Q2 := Q1 + jI

// Smooth the I and Q components before applying the discriminator
I2 := 0.2 * I2 + 0.8 * nz(I2[1])
Q2 := 0.2 * Q2 + 0.8 * nz(Q2[1])

// Homodyne Discriminator
Re = I2 * nz(I2[1]) + Q2 * nz(Q2[1])
Im = I2 * nz(Q2[1]) - Q2 * nz(I2[1])

Re := 0.2 * Re + 0.8 * nz(Re[1])
Im := 0.2 * Im + 0.8 * nz(Im[1])

if Re != 0 and Im != 0
mesaPeriod := 2 * PI / math.atan(Im / Re)
mesaPeriod

if mesaPeriod > 1.5 * nz(mesaPeriod[1])
mesaPeriod := 1.5 * nz(mesaPeriod[1])
mesaPeriod

if mesaPeriod < 0.67 * nz(mesaPeriod[1])
mesaPeriod := 0.67 * nz(mesaPeriod[1])
mesaPeriod

if mesaPeriod < 6
mesaPeriod := 6
mesaPeriod

if mesaPeriod > 50
mesaPeriod := 50
mesaPeriod

mesaPeriod := 0.2 * mesaPeriod + 0.8 * nz(mesaPeriod[1])

phase = 0.0

if I1 != 0
phase := 180 / PI * math.atan(Q1 / I1)
phase

deltaPhase = nz(phase[1]) - phase

if deltaPhase < 1
deltaPhase := 1
deltaPhase

alpha = fastLimit / deltaPhase

if alpha < slowLimit
alpha := slowLimit
alpha
[alpha, alpha / 2.0]
// }

er = math.abs(ta.change(src, len)) / math.sum(math.abs(ta.change(src)), len)

[a, b] = computeAlpha(src, er, er * 0.1)

mama = 0.0
mama := a * src + (1 - a) * nz(mama[1])

fama = 0.0
fama := b * mama + (1 - b) * nz(fama[1])

col_bull = if trendline
color.new(#4CAF50, 70)
col_bear = if trendline
color.new(#FF5252, 70)
mama_p = plot(mama, color=#00000000, title='MAMA')
fama_p = plot(fama, color=#00000000, title='FAMA')
fill(mama_p, fama_p, color=mama > fama ? col_bull : col_bear)

alpha = math.pow(er * (b - a) + a, 2)
kama = 0.0
kama := alpha * src + (1 - alpha) * nz(kama[1])

col = if trendline
fixnan(kama > kama[1] ? color.green : kama < kama[1] ? color.red : na)

// Donchian Channels
Highs = ta.highest(high, DClen)[1]
Lows = ta.lowest(low, DClen)[1]
Mid = (Highs + Lows) / 2
// conditions
upBrkOut = barstate.isconfirmed and ta.crossover(close, Highs)
downBrkOut = barstate.isconfirmed and ta.crossover(close, Lows)

plot(kama, color=col, linewidth=3, title='KAMA')


// Conditions

longCondition_long2 = mama > fama
longCondition_long = fastclose > kama


// Trading

if (longCondition_long and longCondition_long2 and long_term and backtestPeriod and not shortOnly)
// lbl = label.new(bar_index, low, "Long")
// label.set_color(lbl, color.green)
// label.set_yloc(lbl, yloc.belowbar)
// label.set_style(lbl, label.style_label_up)
strategy.entry('Long', strategy.long)


shortCondition_long2 = fastclose < kama
shortCondition_long = mama < fama
CloseShortCondition = mama > fama

if (shortCondition_long and shortCondition_long2 and long_term and backtestPeriod and not longOnly)
// lbl = label.new(bar_index, high, "Short")
//label.set_color(lbl, color.red)
//label.set_yloc(lbl, yloc.abovebar)
//label.set_style(lbl, label.style_label_down)
strategy.entry('Short', strategy.short)

plot(kama, color=col, linewidth=3, title='KAMA')

ExitShort = ta.crossover(mama, fama)
ExitLong = ta.crossover(fama, mama)

if strategy.position_size < 0 and ExitShort and long_term
strategy.exit(id='Close Short', stop=close)

if strategy.position_size > 0 and ExitLong and long_term
strategy.exit(id='Close Long', stop=close)

// Close trade at last day of backtest
// EndDate = time == timestamp(syminfo.timezone, 2022, 11, 24, 0, 0)

// if EndDate
// strategy.close_all()


The Token Metrics Trading View Indicator ("the Indicator") is only provided for informational and educational purposes. It should not be construed as investment advice, a recommendation to buy or sell securities, an offer to sell, or a solicitation of an offer to buy any securities. The content presented herein is provided as general information and for educational purposes and is not intended to provide legal, tax, accounting, or investment advice.

The Indicator uses a combination of technical analysis tools and is intended to assist users in making independent decisions regarding cryptocurrency trading. While the information included in the Indicator has been obtained from sources believed to be reliable, neither Token Metrics nor any of its affiliates guarantees its accuracy or completeness and it should not be relied upon as such.

Historical performance is not indicative of future results. Any backtesting or simulation data presented by the Indicator reflects past performance and does not guarantee future results. Trading cryptocurrencies involves significant risk and can result in the loss of your invested capital. You should carefully consider whether trading suits you in light of your circumstances, knowledge, and financial resources.

Opinions, market data, and recommendations are subject to change anytime. The Indicator does not consider the investment objectives, financial situation, or particular needs of any specific person who may use it. The Indicator is not intended as a complete analysis of every material fact regarding any country, region, market, industry, investment, or strategy.

Decisions based on information contained within the Indicator are the user's sole responsibility. In exchange for using the Indicator, you agree to hold Token Metrics and its affiliates harmless against any claims for damages arising from any decision you make based on such information.

Token Metrics is not responsible for errors, omissions, or results obtained from using this information. All information is provided "as is", with no guarantee of completeness, accuracy, timeliness, or the results obtained from using this information.

Using fixed stop-losses and adjustments for different trading patterns or strategies does not guarantee the limitation of losses or the achievement of gains. Users are fully responsible for any trading decisions they make, which should reflect their own trading style and risk tolerance.

Before using the Indicator, consider consulting with a qualified professional who understands your particular situation. Cryptocurrency trading involves a high degree of risk and is unsuitable for all investors.

By using the Indicator, you accept full responsibility for your trading and investment decisions and agree not to hold Token Metrics and any of its officers, directors, employees, and representatives liable for any losses that may result from such decisions.

Did this answer your question?