Instantly share code, notes, and snippets.

View trail_point_exit.jl
# Built on Julia 1.0
# Trailing point stop
# dummy h l c
c = [2648,2649.75,2654.5,2725.5,2732.75,2729.5,2728,2720.25,2726.75,(2763.25-50),2790.5,2765.25,2721.75,2665,2684.75,2740.25,2711,2742.25,2763.5,2798.75,2805.25,2784,(2763.75-70),2760,2748.75
,2724,2723.75,2692.25,2653.75,2633.5]
l = [2643.0, 2644.75, 2649.5, 2720.5, 2727.75, 2724.5, 2723.0, 2715.25, 2721.75, 2763.25, 2785.5, 2760.25, 2716.75, 2660.0, 2679.75, 2735.25, 2706.0, 2737.25, 2758.5, 2793.75, 2800.25, 2779.0, 2758.75, 2755.0, 2743.75, 2719.0, 2718.75, 2687.25, 2648.75, 2628.5]
h = [2656.0, 2657.75, 2662.5, 2733.5, 2740.75, 2737.5, 2736.0, 2728.25, 2734.75, 2776.25, 2798.5, 2773.25, 2729.75, 2673.0, 2692.75, 2748.25, 2719.0, 2750.25, 2771.5, 2806.75, 2813.25, 2792.0, 2771.75, 2968.0, 2756.75, 2732.0, 2731.75, 2700.25, 2661.75, 2641.5]
some_entry_signal = [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0]
time_index = ["09:00","09:30","10:00","10:30","11:00","11:30","12:00","15:00","13:00","13:30","15:00","15:00","15:00","09:00","09:
View exit_nbar_highest_lowest.jl
# Built on Julia v1.0
# Sell n_bar highest or lowest
# Dummy data
c = [2,3,4,5,6,7,10,7,4,5,5,300,2,1,3,4,5,900,11,12,13,14,15,11,12,6,1,6,7,100]
h = [4, 5, 6, 7, 8, 9, 12, 9, 6, 7, 7, 5, 4, 3, 5, 6, 7, 79, 13, 14, 15, 16, 17, 13, 7, 8, 7, 8, 9, 10]
l = [4, 5, 6, 7, 8, 9, 12, 9, 6, 7, 7, 5, 4, 3, 5, 6, 7, 79, 13, 14, 15, 16, 17, 13, 7, 8, 7, 8, 9, 10]
some_entry_signal = [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0] # any type of signal entry
time_index = ["09:00","09:30","10:00","10:30","11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","09:00","09:30","10:00","10:30","11:00","11:30","12:00","12:30","13:00","09:30","10:00",
"10:30","11:00","11:30","12:00","12:30","13:00"]
View indicator_exit.jl
# Built on Julia v1.0
# Indicator Exit
########################################
# No overnight trades
########################################
# dummy h l c
c = [2,3,4,5,6,7,10,7,4,5,5,3,2,1,3,4,5,10,11,12,13,14,15,11,5,6,5,6,7,8]
View chandelier_exit.jl
# Updated to Julia 0.7 - fixed depreciation warnings
# Passed on v1.0
# Volatility Adjusted Exit
# https://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:chandelier_exit
# Step 1 = Rolling n_bar ATR
# Step 2 = Rolling n_bar high
# Step 3 = On any i calcualte ATR * mult (1,2,3,4,5 etc..)
# Step 4 = Subtract ATR mult - rolling n_bar high
View set_exit_on_close.jl
# Updated to Julia 0.7 - Fixed depreciation warnings
# Passed on v1.0
# Dummy Data
test_entry = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0]
test_data1_day = [5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10]
index = collect(1:1:length(test_entry))
# initialize output
test_n_bar = zero(test_entry)
View ASME_B31G.jl
# Provided for informational purposes - user required to verify the output
# ASME B31G-2012 - Manual for Determining the Remaining Strength of Corroded Pipelines
# B31G Level 0 Evaluation
D = 20
Tnom = 1.0
pitMAX = .200
Lm = 1.5
Ltable = 4.35
View first_profitable_exit.jl
###############################################################
# exit first profitable price over entry
# exit after fixed bars (max_hold) if no profitable trade
###############################################################
signal = [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
close_price = [10,10,20,3,14,5,6,2,4,22,2,1,1,1,10,3,3,3,3,3,3,30]
first_prof = zero(signal)
max_hold = 6
for i = 1:length(signal) # 1:length(signal)-1 if buying next bar at open
View n_bar_hold.jl
# Updated to Juli 0.7 - Fixed depreciation warnings
###################################
# n bar Hold - Stay in trade when repeat signals
###################################
# Dummy Data
signal = [0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
function RO_n_bar(x::Array{Int64}; nb::Int64=3)::Array{Int64}
n_bar = fill(0,length(x))
View Noise_Test.jl
# Packages
using Indicators
# Build H L C matrix
h = data1_h
l = data1_l
c = data1_c
m = Array{Float64}(zeros(length(data1_c),0))
m = hcat(m,h)
m = hcat(m,l)
View 1min_data.jl
using DataFrames
using CSV
using Missings
# Load 1 minute data - close data sampled every 1 minute
main_data1_1min = CSV.read("C:/Users/Andrew.Bannerman/Desktop/Julia/GE/ES Data/1.min.reg.sess.es_0830_to_1500.txt",types=[String; String; fill(Float64, 4); Int;Int],header=true)
main_data2_1min = CSV.read("C:/Users/Andrew.Bannerman/Desktop/Julia/GE/ES Data/1.min.reg.sess.es_0830_to_1500.txt", header=true)
main_data3_1min = CSV.read("C:/Users/Andrew.Bannerman/Desktop/Julia/GE/ES Data/1.min.reg.sess.es_0830_to_1500.txt", header=true)
test_one = CSV.read("C:/Users/Andrew.Bannerman/Desktop/Julia/GE/ES Data/10.min.reg.sess.es.txt", header=true)
test = convert(Array{Float64},test_one[:Close])