Last active
April 27, 2018 13:41
-
-
Save smtlaissezfaire/c5603d9b747fc4a6c8e2425c2dfd2454 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# { Pivot Point Breakout Copyright 2011, P.J.Kaufman. All rights reserved. } | |
# | |
# inputs: period(3); | |
# vars: startday(0), ix(0), lasthigh(0), lastlow(0), lowpassed(false), size(0), | |
# investment(25000); | |
# | |
# | |
# startday = 2*period + 1; | |
# | |
# { test high pivot point } | |
# if high[period+1] >= highest(high,startday) then lasthigh = high[period+1]; | |
# | |
# { test low pivot point } | |
# If low[period+1] <= lowest(low,startday) then lastlow = low[period+1]; | |
# | |
# If marketposition <> 1 and High > lasthigh then begin | |
# size = investment/(AvgTrueRange(10)*bigpointvalue); | |
# If Marketposition = -1 then buy to cover this bar on close; | |
# Buy size contracts this bar on close; | |
# end | |
# Else if Marketposition <> -1 and low < lastlow then begin | |
# size = investment/(AvgTrueRange(10)*bigpointvalue); | |
# If Marketposition = 1 then sell this bar on close; | |
# Sell short size contracts this bar on close; | |
# end; | |
# | |
def strategy(period) | |
# pivot points | |
prices = @stock.prices_between(period.days - now, now) | |
highest_high = prices.map(*&:high).max | |
lowest_low = prices.map(*&:low).min | |
todays_high = prices.last.high | |
todays_low = prices.last.low | |
# how does position sizing here work? what's big point value | |
# size = investment/(AvgTrueRange(10)*bigpointvalue); | |
if todays_high >= pivot_point_high | |
close_all_positions | |
buy(...) | |
else if todays_low <= pivot_point_high | |
close_all_positions | |
sell(..) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment