# rsiStudy = rsiClass() # stochStudy = stochClass() #--------------------------------------------------------------------------------- for i in range(len(myDate) - numBarsToGoBack, len(myDate)): D0 = i D1 = i - 1 D2 = i - 2 D3 = i - 3 D4 = i - 4 equItm += 1 tempDate = myDate[i] todaysCTE = todaysOTE = todaysEquity = 0 marketPosition[i] = marketPosition[i - 1] mp = marketPosition[i] # buyLevel,shortLevel,exitLevel = bollingerBands(myDate,myClose,60,2,i,1) atrVal = sAverage(trueRanges, 10, i, 0) # rsiVal = rsiStudy.calcRsi(myClose,10,i,0) stopAmt = 3000 / myBPV # fastKVal,fastDVal,slowDVal = stochStudy.calcStochastic(3,9,9,myHigh,myLow,myClose,i,1) # if (mp > 0 and maxPositionL < 3) : maxPositionL = mp # if (mp < 0 and maxPositionS < 3) : maxPositionS = mp avg1 = sAverage(myClose, 19, i, 0) avg2 = sAverage(myClose, 39, i, 0) avg3 = sAverage(myClose, 99, i, 0) #-------------------------------------------------------------------------------- #System Description can go here # This Triple Moving Average System currently utilize three moving averages # short, intermediate and longer term - lengths are 19,39,99 respectively # buy MOC when short crosses above intermediate and intermediate is above longer # sell MOC when short crosses below intermediate and intermediate is below longer # exit long MOC when close is $3000 below entry or when SMA crosess below IMA
#--------------------------------------------------------------------------------- for i in range(len(myDate) - numBarsToGoBack,len(myDate)): D0 = i D1 = i - 1 D2 = i - 2 D3 = i - 3 D4 = i - 4 equItm += 1 tempDate = myDate[i] todaysCTE = todaysOTE = todaysEquity = 0 marketPosition[i] = marketPosition[i-1] mp = marketPosition[i] buyLevel,shortLevel,exitLevel = bollingerBands(myDate,myClose,60,2,i,1) # keltUpChan,keltDnChan,keltAvg = keltnerChannels(myDate,multiPriceLists,40,2,i,0) atrVal = sAverage(trueRanges,10,i,0) # rsiVal = rsiStudy.calcRsi(myClose,14,i,0) fastKVal,slowKVal,slowDVal = stochStudy.calcStochastic(20,3,3,myHigh,myLow,myClose,i,1) # if (mp > 0 and maxPositionL < 3) : maxPositionL = mp # if (mp < 0 and maxPositionS < 3) : maxPositionS = mp avg1 = sAverage(myClose,199,i,0) # avg2 = sAverage(myClose,39,i,0) #-------------------------------------------------------------------------------- #System Description can go here # # Stochastic System :Buy when sloK > sloD and sloD < 20 # Short when sloK < sloD and sloD > 80 #-------------------------------------------------------------------------------- #Long Entry Logic
# rsiStudy = rsiClass() # stochStudy = stochClass() #--------------------------------------------------------------------------------- for i in range(len(myDate) - numBarsToGoBack,len(myDate)): D0 = i D1 = i - 1 D2 = i - 2 D3 = i - 3 D4 = i - 4 equItm += 1 tempDate = myDate[i] todaysCTE = todaysOTE = todaysEquity = 0 marketPosition[i] = marketPosition[i-1] mp = marketPosition[i] # buyLevel,shortLevel,exitLevel = bollingerBands(myDate,myClose,60,2,i,1) atrVal = sAverage(trueRanges,10,i,0) # rsiVal = rsiStudy.calcRsi(myClose,10,i,0) stopAmt = 3000/myBPV # fastKVal,fastDVal,slowDVal = stochStudy.calcStochastic(3,9,9,myHigh,myLow,myClose,i,1) # if (mp > 0 and maxPositionL < 3) : maxPositionL = mp # if (mp < 0 and maxPositionS < 3) : maxPositionS = mp avg1 = sAverage(myClose,19,i,0) avg2 = sAverage(myClose,39,i,0) avg3 = sAverage(myClose,99,i,0) #-------------------------------------------------------------------------------- #System Description can go here # This Triple Moving Average System currently utilize three moving averages # short, intermediate and longer term - lengths are 19,39,99 respectively # buy MOC when short crosses above intermediate and intermediate is above longer # sell MOC when short crosses below intermediate and intermediate is below longer # exit long MOC when close is $3000 below entry or when SMA crosess below IMA
for i in range(len(myDate) - numBarsToGoBack, len(myDate)): D0 = i D1 = i - 1 D2 = i - 2 D3 = i - 3 D4 = i - 4 equItm += 1 tempDate = myDate[i] todaysCTE = todaysOTE = todaysEquity = 0 marketPosition[i] = marketPosition[i - 1] mp = marketPosition[i] buyLevel, shortLevel, exitLevel = bollingerBands( myDate, myClose, 60, 2, i, 1) # keltUpChan,keltDnChan,keltAvg = keltnerChannels(myDate,multiPriceLists,40,2,i,0) atrVal = sAverage(trueRanges, 10, i, 0) # rsiVal = rsiStudy.calcRsi(myClose,14,i,0) fastKVal, slowKVal, slowDVal = stochStudy.calcStochastic( 20, 3, 3, myHigh, myLow, myClose, i, 1) # if (mp > 0 and maxPositionL < 3) : maxPositionL = mp # if (mp < 0 and maxPositionS < 3) : maxPositionS = mp avg1 = sAverage(myClose, 199, i, 0) # avg2 = sAverage(myClose,39,i,0) #-------------------------------------------------------------------------------- #System Description can go here # # Stochastic System :Buy when sloK > sloD and sloD < 20 # Short when sloK < sloD and sloD > 80 #--------------------------------------------------------------------------------
#//////// DO NOT CHANGE ABOVE ///////////////////////////////////////////////// #--------------------------------------------------------------------------------- #Instantiate Indicator Classes #--------------------------------------------------------------------------------- rsiStudy = rsiClass() stochStudy = stochClass() #--------------------------------------------------------------------------------- for i in range(len(myDate) - numBarsToGoBack,len(myDate)): equItm += 1 tempDate = myDate[i] todaysCTE = todaysOTE = todaysEquity = 0 marketPosition[i] = marketPosition[i-1] mp = marketPosition[i] # buyLevel,shortLevel,exitLevel = bollingerBands(myDate,myClose,60,2,i,1) prevAvg1 = sAverage(myClose,19,i,1) prevAvg2 = sAverage(myClose,39,i,1) avg1 = sAverage(myClose,19,i,0) avg2 = sAverage(myClose,39,i,0) atrVal = sAverage(trueRanges,10,i,0) # rsiVal = rsiStudy.calcRsi(myClose,10,i,0) stopAmt = 2000/myBPV profAmt = 3000/myBPV # print(myDate[i],"rsi ",rsiVal," atrVal ",atrVal*myBPV," ",myBPV) # fastKVal,fastDVal,slowDVal = stochStudy.calcStochastic(3,9,9,myHigh,myLow,myClose,i,1) # if (mp > 0 and maxPositionL < 3) : maxPositionL = mp # if (mp < 0 and maxPositionS < 3) : maxPositionS = mp #Long Entry Logic
#Instantiate Indicator Classes #--------------------------------------------------------------------------------- rsiStudy = rsiClass() stochStudy = stochClass() #--------------------------------------------------------------------------------- for i in range(len(myDate) - numBarsToGoBack,len(myDate)): equItm += 1 tempDate = myDate[i] todaysCTE = todaysOTE = todaysEquity = 0 marketPosition[i] = marketPosition[i-1] mp = marketPosition[i] buyLevel,shortLevel,exitLevel = bollingerBands(myDate,myClose,60,2,i,1) buyLevel = roundToNearestTick(buyLevel,1,myMinMove) shortLevel = roundToNearestTick(shortLevel,-1,myMinMove) # print(tempDate," avg ",exitLevel," ",buyLevel - exitLevel) atrVal = sAverage(trueRanges,10,i,0) rsiVal = rsiStudy.calcRsi(myClose,10,i,0) stopAmt = 2000/myBPV # print(myDate[i]," buyLevel ",buyLevel," high ",myHigh[i]," low ",myLow[i]) # fastKVal,fastDVal,slowDVal = stochStudy.calcStochastic(3,9,9,myHigh,myLow,myClose,i,1) # if (mp > 0 and maxPositionL < 3) : maxPositionL = mp # if (mp < 0 and maxPositionS < 3) : maxPositionS = mp #Long Entry Logic if (mp == 0 or mp == -1) and myHigh[i] >= buyLevel: profit = 0 price = max(myOpen[i],buyLevel) if mp <= -1: profit,trades,curShares = exitPos(price,myDate[i],"RevShrtLiq",curShares)
#//////// DO NOT CHANGE ABOVE ///////////////////////////////////////////////// #--------------------------------------------------------------------------------- #Instantiate Indicator Classes #--------------------------------------------------------------------------------- rsiStudy = rsiClass() stochStudy = stochClass() #--------------------------------------------------------------------------------- for i in range(len(myDate) - numBarsToGoBack, len(myDate)): equItm += 1 tempDate = myDate[i] todaysCTE = todaysOTE = todaysEquity = 0 marketPosition[i] = marketPosition[i - 1] mp = marketPosition[i] # buyLevel,shortLevel,exitLevel = bollingerBands(myDate,myClose,60,2,i,1) prevAvg1 = sAverage(myClose, 19, i, 1) prevAvg2 = sAverage(myClose, 39, i, 1) avg1 = sAverage(myClose, 19, i, 0) avg2 = sAverage(myClose, 39, i, 0) atrVal = sAverage(trueRanges, 10, i, 0) # rsiVal = rsiStudy.calcRsi(myClose,10,i,0) stopAmt = 2000 / myBPV profAmt = 3000 / myBPV # print(myDate[i],"rsi ",rsiVal," atrVal ",atrVal*myBPV," ",myBPV) # fastKVal,fastDVal,slowDVal = stochStudy.calcStochastic(3,9,9,myHigh,myLow,myClose,i,1) # if (mp > 0 and maxPositionL < 3) : maxPositionL = mp # if (mp < 0 and maxPositionS < 3) : maxPositionS = mp #Long Entry Logic if (mp != 1) and avg1 > avg2 and prevAvg1 < prevAvg2:
#--------------------------------------------------------------------------------- rsiStudy = rsiClass() stochStudy = stochClass() #--------------------------------------------------------------------------------- for i in range(len(myDate) - numBarsToGoBack, len(myDate)): equItm += 1 tempDate = myDate[i] todaysCTE = todaysOTE = todaysEquity = 0 marketPosition[i] = marketPosition[i - 1] mp = marketPosition[i] buyLevel, shortLevel, exitLevel = bollingerBands( myDate, myClose, 60, 2, i, 1) buyLevel = roundToNearestTick(buyLevel, 1, myMinMove) shortLevel = roundToNearestTick(shortLevel, -1, myMinMove) # print(tempDate," avg ",exitLevel," ",buyLevel - exitLevel) atrVal = sAverage(trueRanges, 10, i, 0) rsiVal = rsiStudy.calcRsi(myClose, 10, i, 0) stopAmt = 2000 / myBPV # print(myDate[i]," buyLevel ",buyLevel," high ",myHigh[i]," low ",myLow[i]) # fastKVal,fastDVal,slowDVal = stochStudy.calcStochastic(3,9,9,myHigh,myLow,myClose,i,1) # if (mp > 0 and maxPositionL < 3) : maxPositionL = mp # if (mp < 0 and maxPositionS < 3) : maxPositionS = mp #Long Entry Logic if (mp == 0 or mp == -1) and myHigh[i] >= buyLevel: profit = 0 price = max(myOpen[i], buyLevel) if mp <= -1: profit, trades, curShares = exitPos(price, myDate[i], "RevShrtLiq", curShares)