Pan Rolling has Translated TFS-DIY
It is available on Pan Rolling’s website at PanRolling.com – just search for George Pruitt.
I am in the process of updating the data through the last couple of days and will have that available on the website. I am also refactoring the code to make it easier to wade through – thanks to my readers and some very smart people. I will create a video on the refactored version very soon. But here is an example of the latest version of TS-18 that I will release soon. So just keep working with the current version – I will release this new version for free of course.
Here is an example of the refactored TS-18 module
# Remember every line of code is executed on every day of every market#
# Make sure you want to do this - if not it can slow down processing
# Define Long, Short, ExitLong and ExitShort Levels - mind your indentations
# Build some weekly bars
dateW,openW,highW,lowW,closeW,rangeW,tRangeW = getWeeklyData(marketMonitorList[curMarket].marketData,9,curBar)
# rangeW1 = [a - b for a, b in zip(highW, lowW)]
weeklyAVGRange = sAverage2(rangeW,8,2)
dailyATR = sAverage(myTrueRange,20,curBar,1)
buyLevel = sAverage(myClose,39,curBar,1) + weeklyAVGRange*2
shortLevel= sAverage(myClose,39,curBar,1) - weeklyAVGRange*2
# print(myDate[curBar-1]," ",myClose[curBar-1]," ",shortLevel," ",sAverage(myClose,39,curBar,1)," ",weeklyAVGRange)
shortExit = 999999
longExit = 0
if mp == 1 :
longExit = entryPrice[-1] - 3 *dailyATR
longExit = max(longExit,entryPrice[-1] - 5000/myBPV)
if mp ==-1 :
shortExit = entryPrice[-1] + 3 *dailyATR
shortExit = min(shortExit,entryPrice[-1]+ 5000/myBPV)
posSize = 1
# Long Entry
# Okay Let's put in some logic to create a long position
if crosses(myClose,buyLevel,1,curBar-1) and mp !=1 :
price = myOpen[curBar]
tradeName = "TF_Sys1:B"
numShares = posSize
enterLongPosition(price,posSize,tradeName,sysMarkDict)
unPackDict(sysMarkDict)
# Long Exit
if mp == 1 and myClose[curBar-1] <= longExit and barsSinceEntry > 0:
price = myOpen[curBar]
tradeName = "Lxit"
numShares = curShares
exitPosition(price, curShares, tradeName, sysMarkDict)
unPackDict(sysMarkDict)
# Short Entry
# Okay Let's put in some logic to create a short position
if crosses(myClose,shortLevel,-1,curBar-1) and mp !=-1:
price = myOpen[curBar]
tradeName = "TF_Sys1:S"
numShares = posSize
enterShortPosition(price, numShares, tradeName,sysMarkDict)
unPackDict(sysMarkDict)
# Short Exit
if mp == -1 and myClose[curBar-1] >= shortExit and barsSinceEntry > 0:
price = myOpen[curBar]
tradeName = "Sxit"
numShares = curShares
exitPosition(price, curShares, tradeName,sysMarkDict)
unPackDict(sysMarkDict)
Refactored Trade Directives from TFS #1
All pertinent information concerning a trade is dumped into a dictionary and then regurgitated when needed. Packing the information into a dictionary cleans up the code nicely IMHO. I will break down how I did this in the next post. And will let you know when this version will be available. I am also working on a very simple charting application that I will post as well.
Thanks to all my readers.
George