Username: Password:

Author Topic: Webhook json  (Read 839 times)

Offline donuts

  • Rookie
  • *
  • Posts: 13
    • View Profile
Webhook json
« on: May 31, 2025, 11:37:33 PM »
Is there a json file for webhook. i can see or Edit in

Cant get it to work, i Try the gunbot chatgpt but when load it dont work
Just keep thinking.

I can get it to run in a standart gunbot setting like tssl its runing. But dont Need that ekstra in there, recive all my alarts from tradingview webhook.

Hope some one can help.



Need it to run tradingview webhook like


For long
webhookpassphrasecode buy COINBASE ETH-USDC 1000 0

webhookpassphrasecode sell COINBASE ETH-USDC 1000 0


For short

webhookpassphrasecode short COINBASE ETH-USDT  1000 0

webhookpassphrasecode close COINBASE ETH-USDT 1000 0

Offline donuts

  • Rookie
  • *
  • Posts: 13
    • View Profile
Re: Webhook json
« Reply #1 on: June 04, 2025, 10:39:04 PM »
to all trying to get webhook running(for me a pine in the ass)

u can use this code below, its a json webhook code to use.

(copy and save as .js(use notepad++) you put in the /customStrategies)

in gunbot trade setting you pick custom 

find
core setting
Strategy filename
and put in the name you gave the file
ex customwebhook.js
and save


webhook alart format will buy long and sell long:

yourpass binance buy USDC-ETH 0.004 {{close}} 0

yourpass binance sell USDC-ETH 0.004 {{close}} 0


webhook format will buy short and sell short:

yourpass binanceFutures short USDC-ETH 0.004 {{close}} 0

yourpass binanceFutures close USDC-ETH -0.004 {{close}} 0



set your password in the tradeview menu in gunbot
webhook
"password"



use ngrok to sent your tradingview  alarms to gunbot
you need a pay version (free dont remeber setting)

To set up ngrok on Windows and use it on port 443, you need to download ngrok, extract the file, add it to your system's PATH, and then use the ngrok http 443 command to expose your local server.

Here's a more detailed breakdown:

Download and Install ngrok:
Visit the Ngrok website and download the correct version for Windows.
Extract the downloaded ZIP file.
Place the ngrok.exe file in a directory that is included in your system's PATH environment variable.
Connect your ngrok account:

Sign up for a free ngrok account if you haven't already.

Go to your dashboard and copy your authtoken.

Run the following command in your terminal to add the authtoken: ngrok config add-authtoken YOUR_AUTH_TOKEN.

Start your local server (if not already running):

Ensure your local web server is running and accessible on port 443.
Launch ngrok:

Open a new command prompt or PowerShell window.

Run the command ngrok http 443.             will look like this when pay and get your link   ngrok http --url=bla-blablabla-bla-free.app 443 so you use that when start it.

Ngrok will provide you with a public-facing URL, usually HTTPS.

Access your local server:

Open the provided ngrok URL in your browser.
Important notes:
HTTPS and Port 443:
Ngrok uses port 443 for HTTPS traffic, which is the standard port for secure web connections.
Authentication:
You can add basic authentication to your ngrok tunnel for added security.
Static Domains:
If you want to use a static domain, create one on your ngrok dashboard and use the --url flag when starting ngrok.







// === Gunbot Custom Webhook Strategy (Node 14 compatible) ===

if (!gb.data.pairLedger.customStratStore) {
  gb.data.pairLedger.customStratStore = {};
}
const store = gb.data.pairLedger.customStratStore;

// === TIMING GUARD ===
const enoughTimePassed = (() => {
  if (!store.timeCheck || typeof store.timeCheck !== "number") {
    store.timeCheck = Date.now();
    return false;
  }
  return Date.now() - store.timeCheck > 8000;
})();
const setTimestamp = () => store.timeCheck = Date.now();

if (!enoughTimePassed) return;

// === Read action from strategy config ===
const webhookAction = gb.data.pairLedger.whatstrat.CUSTOM_WEBHOOK_ACTION;
if (!webhookAction || typeof webhookAction !== 'object') return;

const action = webhookAction.action;
const amount = parseFloat(webhookAction.amount || 0);
const actionTime = parseInt(webhookAction.timestamp || 0);

if (Date.now() - actionTime > 15000) return;

const pair = gb.data.pairName;
const exchange = gb.data.exchangeName;
const base = gb.data.baseBalance;
const quote = gb.data.quoteBalance;
const bid = gb.data.bid;
const ask = gb.data.ask;
const limit = parseFloat(gb.data.pairLedger.whatstrat.TRADING_LIMIT || 0);
const buyAmount = limit / ask;
const sellAmount = base;

console.log(` Webhook: ${action} | Pair: ${pair} | Amt: ${amount}`);

const notify = (txt, color) => {
  gb.data.pairLedger.notifications = [
    { text: txt, variant: color, persist: false }
  ];
};

const bubble = (text, price, color) => {
  gb.data.pairLedger.customChartTargets = [
    {
      text: text,
      price: price,
      lineStyle: 0,
      lineWidth: 0,
      lineColor: '#000000',
      bodyBackgroundColor: '#000000',
      quantityBackgroundColor: color
    }
  ];
};

// === Action Handling ===
switch (action) {
//START LONG BUY WEBHOOK
  case 'LONG_BUY':
    if (!gb.data.gotBag && quote >= limit) {
      gb.method.buyMarket(buyAmount, pair, exchange);
      console.log(` Executed LONG BUY on ${pair}`);
      notify(` LONG BUY executed on ${pair}`, 'success');     
      bubble('BUY ✅', gb.data.candlesLow[gb.data.candlesLow.length - 1] - (gb.data.atr || 1), '#00ff00');


    // ✅ Draw green bubble below the bar
    gb.data.pairLedger.customChartTargets = [
      {
        text: 'LONG BUY WEBHOOK ',
      price: gb.data.candlesLow[gb.data.candleslow.length - 1] - (gb.data.atr || 1),
        // Option 1: fixed offset
        //price: gb.data.bid + 7,
        // Option 2 above price: gb.data.candlesHigh[gb.data.candlesHigh.length - 1] + 0.2
      // Option 2 below price: gb.data.candlesLow[gb.data.candlesHigh.length - 1] + 0.2   
        // Option 3 (preferred): just use ATR auto-spacing instead:
        // above price: gb.data.candlesHigh[gb.data.candlesHigh.length - 1] + (gb.data.atr || 1),
      //below price: gb.data.candlesLow[gb.data.candlesHigh.length - 1] - (gb.data.atr || 1),

        lineStyle: 0, // hide the line
        lineWidth: 0,
        lineColor: '#00ff00', // doesn't matter since line is invisible
        bodyBackgroundColor: '#000',
      //Option 1: quantityBackgroundColor: '#00ff00'' // green dot
        //Option 2: quantityBackgroundColor: '#ff0000' // red dot
      quantityBackgroundColor: '#00ff00' // green dot color
      }
    ];

    setTimestamp(); // ✅ only once
  }
  break;
//END LONG BUY WEBHOOK   

//START LONG SELL WEBHOOK
  case 'LONG_SELL':
    if (gb.data.gotBag && base > 0) {
      gb.method.sellMarket(base, pair, exchange);
      console.log(` Executed LONG SELL on ${pair}`);
      notify(` LONG SELL executed on ${pair}`, 'success');
      bubble('SELL ', gb.data.candlesHigh[gb.data.candlesHigh.length - 1] + (gb.data.atr || 1), '#ff0000');

// ✅ Draw red bubble above the bar
    gb.data.pairLedger.customChartTargets = [
      {
        text: 'LONG SELL WEBHOOK ',
      price: gb.data.candlesHigh[gb.data.candlesHigh.length - 1] + (gb.data.atr || 1),
        // Option 1: fixed offset
        //price: gb.data.bid + 7,
        // Option 2 above price: gb.data.candlesHigh[gb.data.candlesHigh.length - 1] + 0.2
      // Option 2 below price: gb.data.candlesLow[gb.data.candlesHigh.length - 1] + 0.2   
        // Option 3 (preferred): just use ATR auto-spacing instead:
        // above price: gb.data.candlesHigh[gb.data.candlesHigh.length - 1] + (gb.data.atr || 1),
      //below price: gb.data.candlesLow[gb.data.candlesHigh.length - 1] - (gb.data.atr || 1),

        lineStyle: 0, // hide the line
        lineWidth: 0,
        lineColor: '#00ff00', // doesn't matter since line is invisible
        bodyBackgroundColor: '#000',
      //Option 1: quantityBackgroundColor: '#ff0000' // red dot
        quantityBackgroundColor: '#ff0000' // red dot
      //Option 2: quantityBackgroundColor: '#00ff00' // green dot color
      }
    ];

     setTimestamp();
    }
    break;
//END LONG SELL WEBHOOK

//START SHORT BUY WEBHOOK
  case 'SHORT_SELL':
    if (!gb.data.gotBag && quote >= limit) {
      gb.method.sellMarket(buyAmount, pair, exchange);
      console.log(` Executed SHORT SELL on ${pair}`);
      notify(` SHORT SELL executed on ${pair}`, 'warning');
      bubble('SHORT ⬇️', gb.data.candlesHigh[gb.data.candlesHigh.length - 1] + (gb.data.atr || 1), '#ff00ff');


// ✅ Draw green bubble above the bar
    gb.data.pairLedger.customChartTargets = [
      {
        text: 'SHORT BUY WEBHOOK ',
        price: gb.data.candlesHigh[gb.data.candlesHigh.length - 1] + (gb.data.atr || 1),
        // Option 1: fixed offset
        //price: gb.data.bid + 7,
        // Option 2 above price: gb.data.candlesHigh[gb.data.candlesHigh.length - 1] + 0.2
      // Option 2 below price: gb.data.candlesLow[gb.data.candlesHigh.length - 1] + 0.2   
        // Option 3 (preferred): just use ATR auto-spacing instead:
        // above price: gb.data.candlesHigh[gb.data.candlesHigh.length - 1] + (gb.data.atr || 1),
      //below price: gb.data.candlesLow[gb.data.candlesHigh.length - 1] - (gb.data.atr || 1),

        lineStyle: 0, // hide the line
        lineWidth: 0,
        lineColor: '#00ff00', // doesn't matter since line is invisible
        bodyBackgroundColor: '#000',
      //Option 1: quantityBackgroundColor: '#ff0000' // red dot
        quantityBackgroundColor: '#00ff00' // green dot color
      //Option 2: quantityBackgroundColor: '#00ff00' // green dot color
      }
    ];





      setTimestamp();
    }
    break;
//END SHORT BUY WEBHOOK   








//START SHORT SELL WEBHOOK
  case 'SHORT_BUY':
    if (gb.data.gotBag && base > 0) {
      gb.method.buyMarket(base, pair, exchange);
      console.log(` Executed SHORT COVER on ${pair}`);
      notify(` SHORT COVER executed on ${pair}`, 'info');
      bubble('COVER ', gb.data.candlesLow[gb.data.candlesLow.length - 1] - (gb.data.atr || 1), '#00ffff');

// ✅ Draw red bubble below the bar
    gb.data.pairLedger.customChartTargets = [
      {
        text: 'SHORT SELL WEBHOOK ',
        price: gb.data.candlesHigh[gb.data.candlesLow.length - 1] + (gb.data.atr || 1),
        // Option 1: fixed offset
        //price: gb.data.bid + 7,
        // Option 2 above price: gb.data.candlesHigh[gb.data.candlesHigh.length - 1] + 0.2
      // Option 2 below price: gb.data.candlesLow[gb.data.candlesHigh.length - 1] + 0.2   
        // Option 3 (preferred): just use ATR auto-spacing instead:
        // above price: gb.data.candlesHigh[gb.data.candlesHigh.length - 1] + (gb.data.atr || 1),
      //below price: gb.data.candlesLow[gb.data.candlesHigh.length - 1] - (gb.data.atr || 1),

        lineStyle: 0, // hide the line
        lineWidth: 0,
        lineColor: '#00ff00', // doesn't matter since line is invisible
        bodyBackgroundColor: '#000',
      //Option 1: quantityBackgroundColor: '#ff0000' // red dot
      //Option 2: quantityBackgroundColor: '#00ff00' // green dot color
        quantityBackgroundColor: '#ff0000' // red dot

      }
    ];




      setTimestamp();
    }
    break;
//END SHORT SELL WEBHOOK

  default:
    console.log(`⚠️ Unknown action: ${action}`);
}
« Last Edit: June 04, 2025, 11:46:57 PM by donuts »