Insider Actions: Airlines

A custom indicator created by TrendSpider on TrendSpider. You can import this script into your TrendSpider account. Don't have TrendSpider? Create an account first, then import the script.

Chart featuring the Insider Actions: Airlines indicator

This script paints all airline insiders' actions on the chart.

Source code

This indicator had been implemented by TrendSpider in JavaScript on TrendSpider. Check out the developer documentation to learn more about JS on TrendSpider.

// This script had been cloned from "Insider actions Airlines" at 22 Jan 2024, 14:54
describe_indicator('Insider Actions: Airlines');

const tickers = ['AA', 'ALK', 'LUV', 'HA', 'UAL', 'DAL'];

await Promise.all(tickers.map(ticker => plotInsiderActions(ticker)));
// await Promise.all(tickers.map(ticker => plotClosePrice(ticker)));


// async function plotClosePrice(ticker) {
// 	const history = await request.history(ticker, constants.resolution);
// 	plot(land_points_onto_series(history.time, history.close, time), { style: 'line' });
// }


async function plotInsiderActions(ticker) {
	const trades = await request.insider_trading(ticker);

	if (!Array.isArray(trades?.transactions)) {
		return;
	}
	
	const buys = trades.transactions.filter(item => item.transaction == 'buy');
	const sells = trades.transactions.filter(item => item.transaction == 'sell');
	const gifts = trades.transactions.filter(item => item.transaction == 'gift' || item.transaction == 'award');


	const buysLanded = land_points_onto_series(
		buys.map(item => item.timestamp),
		buys.map(() => ticker == constants.ticker ? 'buy' : `${ticker} buy`),
		time, 'ge'
	);

	const sellsLanded = land_points_onto_series(
		sells.map(item => item.timestamp),
		sells.map(() => ticker == constants.ticker ? 'sell' : `${ticker} sell`),
		time, 'ge'
	);

	const giftsLanded = land_points_onto_series(
		gifts.map(item => item.timestamp),
		gifts.map(() => ticker == constants.ticker ? 'gift' : `${ticker} gift`),
		time, 'ge'
	);

	
	paint(sellsLanded, { style: 'labels_above', color: 'red', backgroundBorderRadius: 4, backgroundColor: 'red' });
	paint(buysLanded, { style: 'labels_below', color: 'green', backgroundBorderRadius: 4, backgroundColor: 'green' });
	paint(giftsLanded, { style: 'labels_below', color: 'white', backgroundBorderRadius: 4, backgroundColor: 'white' });
}