Skip to content

Instantly share code, notes, and snippets.

@smyth64
smyth64 / breakeven.pinescript
Created March 23, 2022 00:10
Pinescript Set Stop Loss to breakeven
breakEvenActivated = input(true, title = 'Break Even Activated', type = input.bool, group="Weedy")
breakEvenPercentage = input(1, title = 'At how many % will the break even stop loss be activated', step=0.1, type = input.float, group="Weedy") * 0.01
breakEvenProfitPercentage = input(0, title = 'Move Stop loss to x% profit', step=0.1, type = input.float, group="Weedy") * 0.01
isLong = strategy.position_size > 0
isShort = strategy.position_size < 0
if (breakEvenActivated)
breakEvenLong = isLong and close > strategy.position_avg_price * (1 + breakEvenPercentage)
breakEvenPriceLong = strategy.position_avg_price * (1 + breakEvenProfitPercentage)
//
// enter_short and enter_long are the conditions that you use to enter a trade. they need to be defined by you
// They look something like this:
// enter_long = window() and entryConfirmed
// strategy.entry(id='Long', long = true, when=enter_long)
//
bgcolor = close > strategy.position_avg_price[1] ? color.new(#168978, 80) : color.new(#f05350, 80)
border_color = close > strategy.position_avg_price[1] ? color.new(color.green, 20) : color.new(color.red, 20)
barsSinceLong = barssince(enter_long and strategy.position_size <= 0)
@smyth64
smyth64 / Kroll
Last active October 27, 2023 06:40
Kubernetes Force Repull of Image
#!/bin/bash
kubectl patch deployment $1 -p '{"spec": {"template": {"spec":{"containers":[{"name": "'$1'", "imagePullPolicy":"Always"}]}}}}'
sleep 15
kubectl rollout restart deployment $1
sleep 15
kubectl patch deployment $1 -p '{"spec": {"template": {"spec":{"containers":[{"name": "'$1'", "imagePullPolicy":"IfNotPresent"}]}}}}'
# Getting Started
# 1. sudo nano /usr/local/bin/kroll
# 2. paste the code
@smyth64
smyth64 / docker-and-docker-compose-one-click-ubuntu-install.sh
Last active May 19, 2018 08:08
One Command to install Docker and Docker Compose on Ubuntu
sudo apt-get update &&
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common &&
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - &&
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
@smyth64
smyth64 / Docker Compose Letsencrypt Reverse Proxy Setup
Last active April 20, 2018 13:25
Fast Docker Letsencrypt Reverse Proxy
```
docker network create webproxy &&
git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion proxy &&
cd proxy &&
cp .env.sample .env &&
sed -i -e 's/\/path\/to\/your\/nginx\/data/\.\/data/g' .env &&
docker-compose up -d
```
An example of a docker-compose project looks like this:
```
#!/usr/bin/env bash
set -e
UNUSED_USER_ID=21338
UNUSED_GROUP_ID=21337
echo "Fixing permissions."
var log = new (require('captains-log'))();
var Stardog = require('stardog');
// Stardog is our database.
// To test this case you need a Stardog Server running.
var conn = new Stardog.Connection();
conn.setEndpoint("localhost:5820");
conn.setCredentials("admin", "admin");