Skip to content

Instantly share code, notes, and snippets.

@tarnus
tarnus / updown.txt
Created October 15, 2021 20:58
Think or swim up down count
def UpCount = (if close > open then UpCount[1] + 1
else UpCount[1] +1 == 0);
def DownCount = (if close < open then DownCount[1] - 1
else DownCount[1] - 1 == 0);
plot bard = if close > open then UpCount else DownCount;
####Longterm Time Frame
input applyCloud = yes;
input LT_TimeFrame = AggregationPeriod.Week;
input lengthLT =8;
input averageTypeLT = { Simple, default Exponential, Weighted, Wilders, Hull};
def maLT = MovingAverage(averageType = averageTypeLT, close(period = LT_TimeFrame), lengthLT);
input lengthLT1 = 13;
input averageTypeLT1 = {Simple,default Exponential, Weighted, Wilders, Hull};
@tarnus
tarnus / rel-vol.txt
Last active August 28, 2020 17:13
TOS R-Vol color code
input length = 21;
input offset = 1;
def ADV = Average(volume, length)[offset];
def rVol = volume /ADV;
def rVolmult = rVol * 5;
# remove "#" infront of Addlabels to select prefer choice
#AddLabel(yes, round(rVol,2));
@tarnus
tarnus / .lando.yml
Created August 14, 2020 20:17
d8 lando
name: d8dev
recipe: drupal8
config:
php: '7.3'
via: nginx
webroot: web
database: mariadb:10.3
xdebug: false
tooling:
@tarnus
tarnus / luvnotes.module
Created July 27, 2020 21:15
Attache library to all pages
function luvnotes_custom_page_attachments(array &$attachments) {
$attachments['#attached']['library'][] = 'luvnotes_custom/luvnotes_custom';
}
@tarnus
tarnus / ip_address.txt
Created July 24, 2020 21:06
IP Address PHP funtion
function getUserIP() {
$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
@tarnus
tarnus / earnings.txt
Created July 22, 2020 00:03
Days to Earnings Column
#################
# ER Labels
#################
def daysBefore = 100;
def erInDays = AbsValue(GetEventOffset(Events.EARNINGS, 0));
def before = Sum(HasEarnings(), daysBefore)[-daysBefore];
AddLabel(Yes, IF before THEN "ER: "+erInDays+" days" ELSE "ER: No", IF before THEN Color.RED ELSE Color.GREEN);
@tarnus
tarnus / ivchange.txt
Created July 22, 2020 00:03
IV CHange Column
def IV = Imp_Volatility();
def R = ((IV / IV[1]) - 1);
AddLabel(1, AsPercent(R), if R > R[1] then Color.Green else Color.Red);
@tarnus
tarnus / gist:dfb11b78fc64a1fddf25
Created December 19, 2015 17:05
drupal 8 form alter submit handler
function mymodule_form_node_form_alter(&$form, FormStateInterface $form_state) {
// For entity builders.
kint($form['#form_id']);
if($form['#form_id'] == 'node_page_edit_form') {
foreach (array_keys($form['actions']) as $action) {
if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
$form['actions'][$action]['#submit'][] = 'mymodule_node_form_submit';
}
}
}
/**
* @param $obj
* @param $field
* @param $value
*
* @return bool|null
*/
function searchJson($obj, $field, $value) {
$item=NULL;
foreach($obj as $struct) {