#!/home/hoogca/virtualenv/bri/3.7/bin/python ###!/home/debian/miniconda3/bin/python3 #print("Incl wyckoff") import sys, os, math global n, nRecords, Records sideBorder=20 PriceBarpx=100 candleWidth=10 canvasW=(sideBorder+PriceBarpx)+(nRecords*candleWidth) canvasH=850 VolumeBarHeight=100 topBorder=50 HL=HighestHigh-LowestLow PriceRange=HL+(2*(HL*0.05)) PriceWindowPx=canvasH-VolumeBarHeight#-(2*topBorder) basePrice=(2*topBorder)+PriceWindowPx baseVolume=basePrice+VolumeBarHeight #print(HighestHigh) svg=f""" """ barWidth=candleWidth-2 wickWith=4 if candleWidth>14: wickWith=6 if candleWidth<16: wickWith=2 slope=0.5 direction25="up" direction5="up" closeMAdirection="up" prevX5=0 global NewHigh10,NewLow10 NewHigh10=[0 for i in range(nRecords)] NewLow10=[0 for i in range(nRecords)] def checkHL(n,m): nNewHigh=n nNewLow=n for z in reversed(range(n-m,n)): if z>m: if Records['high'][z]>Records['high'][nNewHigh] and Records['high'][z+1]<=Records['high'][z]: nNewHigh=z if Records['low'][z] =Records['low'][z]: nNewLow=z if NewHigh10[nNewHigh]>0 and Records['high'][NewHigh10[nNewHigh]]>Records['high'][nNewHigh]: nNewHigh=NewHigh10[nNewHigh] if NewLow10[nNewLow]>0 and Records['low'][NewLow10[nNewLow]]\n""" if debug: svg+=f""" \n""" nlX=(sideBorder)+(NewLow10[n]*candleWidth) lY=round((PriceWindowPx)-( ((Records['low'][n]-LowestLow)*PriceWindowPx) / PriceRange )) nlY=round((PriceWindowPx)-( ((Records['low'][NewLow10[n]]-LowestLow)*PriceWindowPx) / PriceRange )) #svg+=f""" \n""" if debug: svg+=f""" \n""" cY=round((PriceWindowPx)-( ((Records['close'][n]-LowestLow)*PriceWindowPx) / PriceRange )) #oY=cY+( ((openX-close)*PriceWindowPx) / PriceRange ) #oY=(PriceWindowPx)-( ((openX-LowestLow)*PriceWindowPx) / PriceRange ) hY=round((PriceWindowPx)-( ((Records['high'][n]-LowestLow)*PriceWindowPx) / PriceRange )) lY=round((PriceWindowPx)-( ((Records['low'][n]-LowestLow)*PriceWindowPx) / PriceRange )) svg+=f""" \n"""#100,0,0 svg+=f""" \n"""#0,100,0 svg+=f""" \n""" if n>2: zY=round((PriceWindowPx)-( ((Records['lowMA'][n]-LowestLow)*PriceWindowPx) / PriceRange )) pzY=round((PriceWindowPx)-( ((Records['lowMA'][n-1]-LowestLow)*PriceWindowPx) / PriceRange )) if Records['pcChange_lowMA'][n]>slope: clr="0,200,0" elif Records['pcChange_lowMA'][n]<-slope: clr="200,0,0" else: clr="0,0,200" #svg+=f""" \n""" #zY=round((PriceWindowPx)-( ((Records['pZZMA5'][n]-LowestLow)*PriceWindowPx) / PriceRange )) #pzY=round((PriceWindowPx)-( ((Records['pZZMA5'][n-1]-LowestLow)*PriceWindowPx) / PriceRange )) #if Records['pcChange_pZZMA5'][n]>slope: clr="0,200,0" #elif Records['pcChange_pZZMA5'][n]<-slope: clr="200,0,0" #else: clr="0,0,200" #svg+=f""" \n""" zY=round((PriceWindowPx)-( ((Records['pZZMA5'][n]-LowestLow)*PriceWindowPx) / PriceRange )) pzY=round((PriceWindowPx)-( ((Records['pZZMA5'][n-1]-LowestLow)*PriceWindowPx) / PriceRange )) sumChange=Records['pcChange_pZZMA5'][n]#+Records['pcChange_lZZMA5'][n]+Records['pcChange_hZZMA5'][n] if sumChange>0.5: clr="0,200,0" elif sumChange<-0.5: clr="200,0,0" else: clr="0,0,200" #svg+=f""" \n""" zY=round((PriceWindowPx)-( ((Records['closeMA'][n]-LowestLow)*PriceWindowPx) / PriceRange )) pzY=round((PriceWindowPx)-( ((Records['closeMA'][n-1]-LowestLow)*PriceWindowPx) / PriceRange )) if Records['pcChange_closeMA'][n]>0.40: if closeMAdirection=="dn": nlX=(sideBorder)+(NewLow10[n]*candleWidth) lY=round((PriceWindowPx)-( ((Records['low'][n]-LowestLow)*PriceWindowPx) / PriceRange )) nlY=round((PriceWindowPx)-( ((Records['low'][NewLow10[n]]-LowestLow)*PriceWindowPx) / PriceRange )) if debug: svg+=f""" \n""" #svg+=f""" \n""" if not NewLow10[n] in LowPeaks: LowPeaks.append(NewLow10[n]) nPrevLow=NewLow10[n] peaks+=f"L{NewLow10[n]}," else: LowPeaks.append(n) nPrevLow=n peaks+=f"L{n}," closeMAdirection="up" clr="0,200,0" elif Records['pcChange_closeMA'][n]<-0.40: if closeMAdirection=="up": nhX=(sideBorder)+(NewHigh10[n]*candleWidth) hY=round((PriceWindowPx)-( ((Records['high'][n]-LowestLow)*PriceWindowPx) / PriceRange )) nhY=round((PriceWindowPx)-( ((Records['high'][NewHigh10[n]]-LowestLow)*PriceWindowPx) / PriceRange )) if debug: svg+=f""" \n""" #svg+=f""" \n""" if not NewHigh10[n] in HighPeaks: HighPeaks.append(NewHigh10[n]) nPrevHigh=NewHigh10[n] peaks+=f"H{NewHigh10[n]}," else: HighPeaks.append(n) nPrevHigh=n peaks+=f"H{n}," closeMAdirection="dn" clr="200,0,0" else: if closeMAdirection=="up": clr="0,200,0" else: clr="200,0,0" #clr="0,0,200" if debug: svg+=f""" \n""" zY15=round((PriceWindowPx)-( ((Records['pZZMA15'][n]-LowestLow)*PriceWindowPx) / PriceRange )) pzY15=round((PriceWindowPx)-( ((Records['pZZMA15'][n-1]-LowestLow)*PriceWindowPx) / PriceRange )) if Records['pcChange_pZZMA15'][n]>0.1: direction25="up" clr15="0,200,0" zY=round((PriceWindowPx)-( ((Records['hZZMA5'][n]-LowestLow)*PriceWindowPx) / PriceRange )) #pzY=round((PriceWindowPx)-( ((Records['hZZMA5'][n-1]-LowestLow)*PriceWindowPx) / PriceRange )) if Records['pcChange_hZZMA5'][n]>slope: clr="0,200,0" direction5="up" elif Records['pcChange_hZZMA5'][n]<-slope: clr="200,0,0" direction5="dn" else: if direction5=="up": clr="0,200,0" else: clr="200,0,0" #if prevX5>0: svg+=f""" \n""" prevX5=zY elif Records['pcChange_pZZMA15'][n]<-0.1: direction25="dn" clr15="200,0,0" zY=round((PriceWindowPx)-( ((Records['lZZMA5'][n]-LowestLow)*PriceWindowPx) / PriceRange )) #pzY=round((PriceWindowPx)-( ((Records['lZZMA5'][n-1]-LowestLow)*PriceWindowPx) / PriceRange )) if Records['pcChange_lZZMA5'][n]>slope: clr="0,200,0" direction5="up" elif Records['pcChange_lZZMA5'][n]<-slope: clr="200,0,0" direction5="dn" else: if direction5=="up": clr="0,200,0" else: clr="200,0,0" #if prevX5>0: svg+=f""" \n""" prevX5=zY else: clr15="0,0,200" if direction25=="up": clr15="0,200,0" zY=round((PriceWindowPx)-( ((Records['hZZMA5'][n]-LowestLow)*PriceWindowPx) / PriceRange )) #pzY=round((PriceWindowPx)-( ((Records['hZZMA5'][n-1]-LowestLow)*PriceWindowPx) / PriceRange )) if Records['pcChange_hZZMA5'][n]>slope: clr="0,200,0" direction5="up" elif Records['pcChange_hZZMA5'][n]<-slope: clr="200,0,0" direction5="dn" else: if direction5=="up": clr="0,200,0" else: clr="200,0,0" #if prevX5>0: svg+=f""" \n""" prevX5=zY else: clr15="200,0,0" zY=round((PriceWindowPx)-( ((Records['lZZMA5'][n]-LowestLow)*PriceWindowPx) / PriceRange )) #pzY=round((PriceWindowPx)-( ((Records['lZZMA5'][n-1]-LowestLow)*PriceWindowPx) / PriceRange )) if Records['pcChange_lZZMA5'][n]>slope: clr="0,200,0" elif Records['pcChange_lZZMA5'][n]<-slope: clr="200,0,0" else: if direction5=="up": clr="0,200,0" else: clr="200,0,0" #if prevX5>0: svg+=f""" \n""" prevX5=zY if direction25=="up": zY=round((PriceWindowPx)-( ((Records['high'][n]-Records['pZZMA15'][n])*PriceWindowPx) / PriceRange )) #if prevX5>0: svg+=f""" \n""" else: zY=round((PriceWindowPx)-( ((Records['low'][n]-Records['pZZMA15'][n])*PriceWindowPx) / PriceRange )) #if prevX5>0: svg+=f""" \n""" # svg+=f""" \n""" #hprint(len(HighPeaks)) #hprint(len(LowPeaks)) peaks=peaks.rstrip(",") #hprint(peaks) peakArr=peaks.split(",") for npeak in range(0,len(peakArr)): if npeak>0: FROM=peakArr[npeak-1] if FROM.find("H")==0: nFROM=int(FROM.replace("H","")) FROMprice=Records['high'][nFROM] else: nFROM=int(FROM.replace("L","")) FROMprice=Records['low'][nFROM] TO=peakArr[npeak] if TO.find("H")==0: nTO=int(TO.replace("H","")) TOprice=Records['high'][nTO] else: nTO=int(TO.replace("L","")) TOprice=Records['low'][nTO] #hprint(f"{nFROM}|{FROMprice} .. {nTO}|{TOprice}") XF=(sideBorder)+(nFROM*candleWidth) XT=(sideBorder)+(nTO*candleWidth) YF=round((PriceWindowPx)-( ((FROMprice-LowestLow)*PriceWindowPx) / PriceRange )) YT=round((PriceWindowPx)-( ((TOprice-LowestLow)*PriceWindowPx) / PriceRange )) svg+=f""" \n""" #svg+=f""" \n""" Overalldirection="up" for n in (range(1,nRecords)):#reversed X=(sideBorder)+(n*candleWidth) if n>2 and nslope: if Records['avgPcChange'][n+1]>slope: # Filter out single-bar trand changes Overalldirection="up" elif Records['avgPcChange'][n]<-slope: if Records['avgPcChange'][n+1]<-slope: # Filter out single-bar trand changes Overalldirection="dn" if Overalldirection=="up": trendclr="0,200,0" else: trendclr="200,0,0" zhY=round((PriceWindowPx)-( ((Records['hZZMA5'][n]-LowestLow)*PriceWindowPx) / PriceRange )) pzhY=round((PriceWindowPx)-( ((Records['hZZMA5'][n-1]-LowestLow)*PriceWindowPx) / PriceRange )) if Records['pcChange_hZZMA5'][n]>slope: clr="0,200,0" directionH="up" elif Records['pcChange_hZZMA5'][n]<-slope: clr="200,0,0" directionH="dn" else: if directionH=="up": clr="0,200,0" else: clr="200,0,0" svg+=f""" \n""" zlY=round((PriceWindowPx)-( ((Records['lZZMA5'][n]-LowestLow)*PriceWindowPx) / PriceRange )) pzlY=round((PriceWindowPx)-( ((Records['lZZMA5'][n-1]-LowestLow)*PriceWindowPx) / PriceRange )) if Records['pcChange_lZZMA5'][n]>slope: clr="0,200,0" directionL="up" elif Records['pcChange_lZZMA5'][n]<-slope: clr="200,0,0" directionL="dn" else: if directionH=="up": clr="0,200,0" else: clr="200,0,0" svg+=f""" \n""" svg+=f"""""" print(svg)