Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=3
- study("RelStr Multitime, Multistatement V0.95")
- // Resolution Setting
- // Inputs for alternate resolutions. tp_res_custom1 for High / Low sources and tp_res_custom2 for Mixed source.
- rtprice = input(title="realtime price source", defval = hl2)
- tp_res_custom1 = input(title="High TP and Low TP Source Resolution", type=string, defval="2")
- tp_res_custom2 = input(title="Mixed TP Source Resolution", type=string, defval="15")
- tp_res_custom3 = input(title="Fractal Timeframe", type=string, defval="30")
- //res_pri = primary_pricet
- res_tp1 = tp_res_custom1
- res_tp2 = tp_res_custom2
- res_fract = tp_res_custom3
- // TP Delta-V Sources
- //primary_price_src = input(defval = hlc3, title = 'Primary Source')
- tp_pricesrc1 = input(defval = high, title = 'High TP Source')
- tp_pricesrc2 = input(defval = low, title = 'Low TP Source')
- tp_pricesrc3 = input(defval = hl2, title = 'Mixed TP Source')
- tp_pricesrc4 = input(defval = open, title = 'Open Price')
- tp_pricesrc5 = input(defval = close, title = 'Closed Price')
- // src3 Also used for Volume
- // TP Delta-V Sources for selected 'Take-Profit Resolution'
- //src_primary1 = security(tickerid, res_pri , tp_pricesrc1)
- tp_src0 = security(tickerid, res_tp1 , tp_pricesrc3)
- tp_src1 = security(tickerid, res_tp1 , tp_pricesrc1)
- tp_src2 = security(tickerid, res_tp1 , tp_pricesrc2)
- tp_src3 = security(tickerid, res_tp2 , tp_pricesrc3)
- fr_src_O = security(tickerid, res_fract , tp_pricesrc4)
- fr_src_H = security(tickerid, res_fract , tp_pricesrc1)
- fr_src_L = security(tickerid, res_fract , tp_pricesrc2)
- fr_src_C = security(tickerid, res_fract , tp_pricesrc5)
- //Volume for Selected Resolution
- tpvolume1= security(tickerid, res_tp1 , volume)
- tpvolume2= security(tickerid, res_tp2 , volume)
- //SHORT 'ZIPPY' SOURCES
- short_rsalm_1 = input (13, title = 'SHORT_HI_LO STRENGTH')
- //
- short_almawin_1 = input (9, title = ' SHORT ALMA window/2')
- short_almaoffset_1 = input (0.85, title = 'SHORT ALMA offset ', step=0.05)
- short_almawindow_1 = input (6, title = 'SHORT ALMA sigma')
- //
- short_barschange_1 = input (7, title = 'SHORT bars of change High')
- short_barschange_2 = input (7, title = 'SHORT bars of change Low')
- //
- short_tphimax = input (5.5, title = 'SHORTtphi max change', step=0.5)
- short_tphimin = input (-5.5, title = 'SHORTtphi min change', step=0.5)
- //
- //END
- // LONG SOURCES
- rsalm_1 = input (20, title = 'STRENGTH')
- rsalm_2 = input (14, title = 'Hi_LOW STRENGTH')
- //
- almawin_1 = input (135, title = ' ALMA window')
- //
- //
- almawin_2 = input (20, title = ' ALMA window for HI_LO') // <THIS SHITS IMPORTANT!
- //
- //
- almaoffset_1 = input (1.15, title = ' ALMA offset ', step=0.05)
- almawindow_1 = input (20, title = 'ALMA sigma')
- //
- barschange_1 = input (105, title = ' bars of change MixTP')
- barschange_2 = input (7, title = ' bars of change High Low')
- //
- tphimax = input (3.5, title = 'tphi max change', step=0.5)
- tphimin = input (-3.5, title = 'tphi min change', step=0.5)
- //
- rsmovethresh = input (40, title = 'TP HI_LO change threshold')
- //
- ifchangeamnt = input (20, title = 'TP HI_LO change Bars for Threshold Meet')
- //
- //
- //Fractal MA and TSI of Fractal MA inputs
- //Fract Input sources
- FractInputSrc = input (1)
- //
- f1_len = input(defval=16,minval=1, title = 'Fractal MA Length' )
- f1_FC = input(defval=1,minval=1, title = 'Fractal MA f1_FC' )
- f1_SC = input(defval=198,minval=1, title = 'Fractal MA f1_SC')
- //
- f2_len = input(defval=16,minval=1, title = 'Fractal MA Length' )
- f2_FC = input(defval=1,minval=1, title = 'Fractal MA f1_FC' )
- f2_SC = input(defval=198,minval=1, title = 'Fractal MA f1_SC')
- //
- len = input(defval=16,minval=1, title = 'long Fractal MA Length' )
- FC = input(defval=1,minval=1, title = 'long Fractal MA FC' )
- SC = input(defval=198,minval=1, title = 'long Fractal MA SC')
- //
- //
- fractsi_short = input (7, title = 'Fractal TSI Short Length')
- fractsi_long = input (41, title = 'Fractal TSI Long Length')
- // and Mult *
- fractsimult = input (defval=21, title = 'Fractal TSI Multiplier')
- centerprice_mult = input (defval = 12.5, step = 0.5, title = ' Price Action Mult')
- roc_length = input(20, title = 'roc_barsback')
- prcminmax = input(.012, title = "Precentage Up Down for trigger from last", step = 0.001 )
- tuneoffset = input(0.694, title = 'multX', step = .001)
- //
- // END INPUTS
- price = fr_src_L
- len1 = f1_len/2
- w = log(2/(f1_SC+1))
- H1 = highest(fr_src_H,len1)
- L1 = lowest(fr_src_L,len1)
- N1 = (H1-L1)/len1
- H2 = highest(fr_src_H,f1_len)[len1]
- L2 = lowest(fr_src_L,f1_len)[len1]
- N2 = (H2-L2)/len1
- H3 = highest(fr_src_H,f1_len)
- L3 = lowest(fr_src_L,f1_len)
- N3 = (H3-L3)/f1_len
- dimen1 = (log(N1+N2)-log(N3))/log(2)
- dimen = iff(N1>0 and N2>0 and N3>0,dimen1,nz(dimen1[1]))
- alpha1 = exp(w*(dimen-1))
- oldalpha = alpha1>1?1:(alpha1<0.01?0.01:alpha1)
- oldN = (2-oldalpha)/oldalpha
- N = (((f1_SC-f1_FC)*(oldN-1))/(f1_SC-1))+f1_FC
- alpha_ = 2/(N+1)
- alpha = alpha_<2/(f1_SC+1)?2/(f1_SC+1):(alpha_>1?1:alpha_)
- out = na
- out := (1-alpha)*nz(out[1]) + alpha*price
- lowfract = out
- //(longfract[7] > shortprice_upper) ? 30 : (longfract[7] < shortprice_lower) ? -30 : 0
- ///
- f1_price = fr_src_H
- f1_len1 = f1_len/2
- f1_w = log(2/(f1_SC+1))
- f1_H1 = highest(fr_src_H,f1_len1)
- f1_L1 = lowest(fr_src_L,f1_len1)
- f1_N1 = (f1_H1-f1_L1)/f1_len1
- f1_H2 = highest(fr_src_H,f1_len)[f1_len1]
- f1_L2 = lowest(fr_src_L,f1_len)[f1_len1]
- f1_N2 = (f1_H2-f1_L2)/f1_len1
- f1_H3 = highest(fr_src_H,f1_len)
- f1_L3 = lowest(fr_src_L,f1_len)
- f1_N3 = (f1_H3-f1_L3)/f1_len
- f1_dimen1 = (log(f1_N1+f1_N2)-log(f1_N3))/log(2)
- f1_dimen = iff(f1_N1>0 and f1_N2>0 and f1_N3>0,f1_dimen1,nz(f1_dimen1[1]))
- f1_alpha1 = exp(f1_w*(f1_dimen-1))
- f1_oldalpha = f1_alpha1>1?1:(f1_alpha1<0.01?0.01:f1_alpha1)
- f1_oldN = (2-f1_oldalpha)/f1_oldalpha
- f1_N = (((f1_SC-f1_FC)*(f1_oldN-1))/(f1_SC-1))+f1_FC
- f1_alpha_ = 2/(f1_N+1)
- f1_alpha = f1_alpha_<2/(f1_SC+1)?2/(f1_SC+1):(f1_alpha_>1?1:f1_alpha_)
- f1_out = na
- f1_out := (1-f1_alpha)*nz(f1_out[1]) + f1_alpha*f1_price
- highfract = (f1_out)
- fratsi = ((tsi(f1_out, fractsi_short, fractsi_long))*fractsimult)
- //
- f2_price = input(hl2)
- f2_len1 = f2_len/2
- f2_w = log(2/(f2_SC+1))
- f2_H1 = highest(high,f2_len1)
- f2_L1 = lowest(low,f2_len1)
- f2_N1 = (f2_H1-f2_L1)/f2_len1
- f2_H2 = highest(high,f2_len)[f2_len1]
- f2_L2 = lowest(low,f2_len)[f2_len1]
- f2_N2 = (f2_H2-f2_L2)/f2_len1
- f2_H3 = highest(high,f2_len)
- f2_L3 = lowest(low,f2_len)
- f2_N3 = (f2_H3-f2_L3)/f2_len
- f2_dimen1 = (log(f2_N1+f2_N2)-log(f2_N3))/log(2)
- f2_dimen = iff(f2_N1>0 and f2_N2>0 and f2_N3>0,f2_dimen1,nz(f2_dimen1[1]))
- f2_alpha1 = exp(f2_w*(f2_dimen-1))
- f2_oldalpha = f2_alpha1>1?1:(f2_alpha1<0.01?0.01:f2_alpha1)
- f2_oldN = (2-f2_oldalpha)/f2_oldalpha
- f2_N = (((f2_SC-f2_FC)*(f2_oldN-1))/(f2_SC-1))+f2_FC
- f2_alpha_ = 2/(f2_N+1)
- f2_alpha = f2_alpha_<2/(f2_SC+1)?2/(f2_SC+1):(f2_alpha_>1?1:f2_alpha_)
- f2_out = na
- f2_out := (1-f2_alpha)*nz(f2_out[1]) + f2_alpha*f2_price
- realtimefract = f2_out
- fractdeviation = realtimefract - ((lowfract+highfract)/2)
- pricerangeprecent = alma(ema((((lowfract/highfract)-1)*500),26),9,0.85,6)
- pricerangeprecentl = alma(ema((((highfract/lowfract)-1)*500),26),9,0.85,6)
- /// Reversal Zone
- //
- //
- //highs
- rzh1 = (sma(close,3) > highfract) ? (sma(close,3) - highfract) : 0
- rzh2 = (realtimefract > highfract) ? (realtimefract - highfract) : 0
- rzh3 = (sma(close,3) > realtimefract) ? (sma(close,3) - realtimefract) : 0
- //
- //
- //lows
- rzl1 = (sma(close,3) < lowfract) ? (sma(close,3) - lowfract) : 0
- rzl2 = (realtimefract < lowfract) ? (realtimefract - lowfract) : 0
- rzl3 = (sma(close,3) < realtimefract) ? (sma(close,3) - realtimefract) : 0
- ///
- ///
- ///
- ///
- //Mixed Signal on longer TF
- mixed_tp_singal = change(alma((rsi(tp_src3,(rsalm_1*2))),almawin_1,almaoffset_1,almawindow_1),barschange_1)
- // Long Zippy Args
- //
- //LongHigh
- RelStr_tphi = max((change(alma((rsi(tp_src1,(rsalm_2*2))),almawin_2,almaoffset_1,almawindow_1),(barschange_2))),tphimax)
- //
- //RelStrMove_tphi = if(change(RelStr_tphi,ifchangeamnt))>(rsmovethresh/10)
- // 4
- //else
- // 0
- //
- //LongLow
- RelStr_tplo = min((change(alma((rsi(tp_src2,(rsalm_2*2))),almawin_2,almaoffset_1,almawindow_1),(barschange_2))),tphimin)
- // Short Zippy Args
- //
- //ShortHigh
- short_RelStr_tphi = max((change(alma((rsi(tp_src1,((short_rsalm_1)))),(short_almawin_1)/2,short_almaoffset_1,short_almawindow_1),(short_barschange_1))),short_tphimax)
- //
- //Shortlow
- short_RelStr_tplo = min((change(alma((rsi(tp_src2,((short_rsalm_1)))),(short_almawin_1)/2,short_almaoffset_1,short_almawindow_1),(short_barschange_2))),short_tphimin)
- //
- //Order Placement Logic, revision 0.1
- //
- /////////////////// ALOT OF WORK TO DO HERE WITH ROC's N SHIT
- //scalplonga = if ((roc(short_RelStr_tphi,6)) > roc(short_tphimax,6)) and (roc(RelStr_tphi,6)) > roc(short_tphimax,6) //and (fractdeviation>fractdeviation[1])
- scalplonga = if (short_RelStr_tphi>short_tphimax) and (RelStr_tphi > tphimax) //and (fractdeviation>fractdeviation[1])
- 40
- else
- 0
- //scalpshorta = if ((roc(short_RelStr_tplo,6))< roc(short_tphimin,6)) and (roc(RelStr_tplo,6)) < roc(tphimin,6) //and (fractdeviation<fractdeviation[1])
- scalpshorta = if (short_RelStr_tplo<short_tphimin) and (RelStr_tplo < tphimin) //and (fractdeviation<fractdeviation[1])
- -40
- else
- 0
- trnkscalplong = scalplonga
- trnkscalpshort = scalpshorta
- pricedirection = if ((valuewhen(trnkscalpshort,(hl2), 2))) > ((valuewhen(trnkscalplong,(hl2*(1+(prcminmax*tuneoffset))), 2)) + (valuewhen(trnkscalplong,(hl2*(1+(-1*prcminmax))), 2)) / 2)
- scalpshorta
- else
- scalplonga
- ma1 = if(change(scalplonga,1)>0)
- 40
- else
- 0
- ma2 = if(change(scalpshorta,1)<0)
- -40
- else
- 0
- ////
- ////
- ////
- ////
- //isTP =
- //tp = input(0, "Take Profit") / qty
- //long_tp = isTP and crossover(high, last_open_longCondition + tp) and longCondition == 0
- //short_tp = isTP and crossunder(low, last_open_shortCondition - tp) and shortCondition == 0
- //plot (rtprice, title = 'price', color = blue)
- //plot (mixed_tp_singal, title = "TP Mixed" , color = blue )
- //plot (RelStr_tphi, title = "TP Hi" , color = purple)
- //plot (RelStr_tplo, title = "TP Low" , color = red)
- //plot (short_RelStr_tphi, title = "Short TP Hi" , color = green)
- //plot (short_RelStr_tplo, title = "Short TP Low" , color = red)
- //plot (fratsi, title = "fractal tsi" , color = orange)
- //plot (lowfract, title = "lowfract" , color = purple)
- //plot (highfract, title = "highfract" , color = purple)
- //plot (realtimefract, title = "realtimefract" , color = purple)
- //plot (ishighfract, title = ' ishighfract ' , color = purple)
- //plot (scalpshorta, title = 'scalplong' , color = green, style = line, linewidth = 1 )
- //plot (scalplonga, title = 'scalpshort' , color = purple, style = line, linewidth = 1 )
- //plot (ma1, title = 'longblip' , color = ma2 < 0 ? green : na, style = cross, linewidth = 4)
- //plot (ma2, title = 'shortblip' , color = ma1 > 0 ? red : na, style = cross, linewidth = 4 )
- //plot (scalplongz, title = 'scalplongz' , color = black, style = line, linewidth = 1 )
- //plot (scalpshortz, title = 'scalpshortz' , color = blue, style = line, linewidth = 1 )
- //plot (fractdeviation, title = ' fractdeviation ' , color = red)
- //plot (pricerangeprecentl, title = "pricerangeprecent" , color = purple)
- //plot (pricerangeprecent, title = "pricerangeprecent" , color = purple)
- plot (rzh1, title = "rzh1" , color = purple)
- plot (rzh2, title = "rzh2" , color = red)
- plot (rzh3, title = "rzh3" , color = blue)
- plot (rzl1, title = "rzh1" , color = purple)
- plot (rzl2, title = "rzh2" , color = red)
- plot (rzl3, title = "rzh3" , color = blue)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement