Skip to content

Commit

Permalink
NOVA-663: upd fastSearchTimeIndex func
Browse files Browse the repository at this point in the history
  • Loading branch information
stimofeev-tv committed Dec 19, 2024
1 parent 42aa760 commit b714127
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 171 deletions.
14 changes: 8 additions & 6 deletions links/high_and_low.pine.link
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// first bar's timestamp in pine history
var first_bar_time = time / 1000
plot(first_bar_time, title='first_bar_time')

// high & low
var ath = high
var ath_date = time/1000
Expand Down Expand Up @@ -66,10 +70,12 @@ fastSearchTimeIndex(x, maxbarsback) =>
mid = 0 * time[maxbarsback]
right = math.min(bar_index, maxbarsback)
left = 0
if time < x
if x/1000 <= first_bar_time
bar_index
else if time < x
0
else
for i = 0 to 9 by 1
for i = 0 to 10
mid := math.ceil((left + right) / 2)
if left == right
break
Expand Down Expand Up @@ -154,7 +160,3 @@ volatility(bb) =>
plot(volatility(countOfBarsWeekAgoThisBar), title='Volatility.W')
plot(volatility(countOfBars1MonthAgoThisBar), title='Volatility.M')
plot(ta.tr(true) * 100 / math.abs(low), title='Volatility.D')

// first bar's timestamp in pine history
var first_bar_time = time / 1000
plot(first_bar_time, title='first_bar_time')
66 changes: 33 additions & 33 deletions scanner.data.bonds.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"id": "text",
"type": "text",
"defval": "i:#1+1~low@$0*time@$0~s2:ifelif_(#0==0){na():f+$1!na():f}elif(#0==1){low!time/1000}_{#0~#0+1~v:if(!na(low@$7):s_b){$6=$6-1~}~0~v:for(0;$6;1){v:if(low@$10\u003clow@$9){$9=$10~}~}~low@$9!time@$9/1000};i:#1+1~high@$0*time@$0~s2:ifelif_(#0==0){na():f+$1!na():f}elif(#0==1){high!time/1000}_{#0~#0+1~v:if(!na(high@$7):s_b){$6=$6-1~}~0~v:for(0;$6;1){v:if(high@$10\u003ehigh@$9){$9=$10~}~}~high@$9!time@$9/1000};0*time@#1~min(n,#1)~0~if_(time\u003c#0){i:0}_{v:for(0;9;1){$0=ceil(($2+$1)/2)~v:ifelif_($2==$1){break~}elif(time@$0\u003c#0){$1=$0~continue~}elif(time@$0\u003e#0){$2=$0~continue~}_{break~}~}~$0};#0~v:if(n==0){$0=365~}~if_($0==0){na():f}_{sum(((high-low)/abs(low))*100/$0,$0)~if_(#0==0){na():f}_{$3}};if_(#0\u003c0\u0026\u0026close\u003e0){na():f}_{(close-#0)*100/abs(#0)};open@#1*0+#0==0?na():f:$4(open@#0);v^open~year~v:if(year\u003e$1@1){$0=open~}~$4($0);close~$0;$7();v^high~v^time/1000~v^low~v:if(high\u003e$0){$0=high~$1=time/1000~$2=low~}~v:if(low\u003c$2){$2=low~}~$0~$1~$0~$1~$2~v^low~v^time/1000~v:if(low\u003c$10){$10=low~$11=time/1000~}~$10~$11~$10~$11~v^open~timenow-315532800000~$2($18,i:3652)~timenow-157766400000~$2($20,i:1826)~timenow-94608000000~$2($22,i:1095)~timenow-31449600000~$2($24,i:364)~s2:$0($25,i:364):s2~s2:$1($25,i:364):s2~timenow-15552000000~$2($30,i:180)~s2:$0($31,i:180):s2~s2:$1($31,i:180):s2~timenow-7776000000~$2($36,i:90)~s2:$0($37,i:90):s2~s2:$1($37,i:90):s2~time-2592000000~timenow-2592000000~$2($43,i:30)~$2($42,i:30)~s2:$0($44,i:30):s2~s2:$1($44,i:30):s2~timenow-604800000~time-604800000~$2($50,i:7)~$2($51,i:7)~s2:$0($52,i:7):s2~s2:$1($52,i:7):s2~$3($53)~$3($45)~tr(b:true)*100/abs(low)~v^time/1000~timenow-31536000000~$2($62,i:365)~$6()~((close-open@4)/open@4)*100~$5($52,i:7)~$5($44,i:30)~$5($37,i:90)~$5($31,i:180)~$5($63,i:365)~$5($23,i:1095)~$5($21,i:1826)~$5($19,i:3652)~time_tradingday/1000~#0~$75~$76-$76@1~na():f~v:if(!($76@1\u003c0)\u0026\u0026!($76\u003c0)){$78=($77/$76@1)*100~}~$78~timenow-86400000~$2($81,i:1)~v:max_bars_back(close,365):v~close@$82~close@$44~close@$63~$5!$6!$7!$8!$9!$13!$14!$15!$16!$17!$26!$27!$28!$29!$32!$33!$34!$35!$38!$39!$40!$41!$46!$47!$48!$49!$54!$56!$58!$59!$60!$61!$65!$66!$67!$68!$69!$70!$71!$72!$73!$64!$74!$76!$77!$80!$84!$85!$86;t:str.substring(ticker,0,str.length(ticker):i-1):t~t:sc(t:syminfo.prefix,t:':',t:$10):t~i:na():f~sym($11,period,period,false,false,true,'NONE',false,false,$12)|$8()|s49:$9($14):s49~$16!$17!$18!$19!$20!$21!$22!$23!$24!$25!$26!$27!$28!$29!$30!$31!$32!$33!$34!$35!$36!$37!$38!$39!$40!$41!$42!$43!$44!$45!$46!$47!$48!$49!$50!$51!$52!$53!$54!$55!$56!$57!$58!$59!$60!$61!$62!$63!$64",
"defval": "i:#1+1~low@$0*time@$0~s2:ifelif_(#0==0){na():f+$1!na():f}elif(#0==1){low!time/1000}_{#0~#0+1~v:if(!na(low@$7):s_b){$6=$6-1~}~0~v:for(0;$6;1){v:if(low@$10\u003clow@$9){$9=$10~}~}~low@$9!time@$9/1000};i:#1+1~high@$0*time@$0~s2:ifelif_(#0==0){na():f+$1!na():f}elif(#0==1){high!time/1000}_{#0~#0+1~v:if(!na(high@$7):s_b){$6=$6-1~}~0~v:for(0;$6;1){v:if(high@$10\u003ehigh@$9){$9=$10~}~}~high@$9!time@$9/1000};0*time@#1~min(n,#1)~0~ifelif_(#0/1000\u003c=#2){n}elif(time\u003c#0){i:0}_{v:for(0;10;1){$0=ceil(($2+$1)/2)~v:ifelif_($2==$1){break~}elif(time@$0\u003c#0){$1=$0~continue~}elif(time@$0\u003e#0){$2=$0~continue~}_{break~}~}~$0};#0~v:if(n==0){$0=365~}~if_($0==0){na():f}_{sum(((high-low)/abs(low))*100/$0,$0)~if_(#0==0){na():f}_{$3}};if_(#0\u003c0\u0026\u0026close\u003e0){na():f}_{(close-#0)*100/abs(#0)};open@#1*0+#0==0?na():f:$4(open@#0);v^open~year~v:if(year\u003e$1@1){$0=open~}~$4($0);close~$0;$7();v^time/1000~v^high~v^time/1000~v^low~v:if(high\u003e$1){$1=high~$2=time/1000~$3=low~}~v:if(low\u003c$3){$3=low~}~$1~$2~$1~$2~$3~v^low~v^time/1000~v:if(low\u003c$11){$11=low~$12=time/1000~}~$11~$12~$11~$12~v^open~timenow-315532800000~$2($19,i:3652,$0)~timenow-157766400000~$2($21,i:1826,$0)~timenow-94608000000~$2($23,i:1095,$0)~timenow-31449600000~$2($25,i:364,$0)~s2:$0($26,i:364):s2~s2:$1($26,i:364):s2~timenow-15552000000~$2($31,i:180,$0)~s2:$0($32,i:180):s2~s2:$1($32,i:180):s2~timenow-7776000000~$2($37,i:90,$0)~s2:$0($38,i:90):s2~s2:$1($38,i:90):s2~time-2592000000~timenow-2592000000~$2($44,i:30,$0)~$2($43,i:30,$0)~s2:$0($45,i:30):s2~s2:$1($45,i:30):s2~timenow-604800000~time-604800000~$2($51,i:7,$0)~$2($52,i:7,$0)~s2:$0($53,i:7):s2~s2:$1($53,i:7):s2~$3($54)~$3($46)~tr(b:true)*100/abs(low)~timenow-31536000000~$2($62,i:365,$0)~$6()~((close-open@4)/open@4)*100~$5($53,i:7)~$5($45,i:30)~$5($38,i:90)~$5($32,i:180)~$5($63,i:365)~$5($24,i:1095)~$5($22,i:1826)~$5($20,i:3652)~time_tradingday/1000~#0~$75~$76-$76@1~na():f~v:if(!($76@1\u003c0)\u0026\u0026!($76\u003c0)){$78=($77/$76@1)*100~}~$78~timenow-86400000~$2($81,i:1,$0)~v:max_bars_back(close,365):v~close@$82~close@$45~close@$63~$0!$6!$7!$8!$9!$10!$14!$15!$16!$17!$18!$27!$28!$29!$30!$33!$34!$35!$36!$39!$40!$41!$42!$47!$48!$49!$50!$55!$57!$59!$60!$61!$65!$66!$67!$68!$69!$70!$71!$72!$73!$64!$74!$76!$77!$80!$84!$85!$86;t:str.substring(ticker,0,str.length(ticker):i-1):t~t:sc(t:syminfo.prefix,t:':',t:$10):t~i:na():f~sym($11,period,period,false,false,true,'NONE',false,false,$12)|$8()|s49:$9($14):s49~$16!$17!$18!$19!$20!$21!$22!$23!$24!$25!$26!$27!$28!$29!$30!$31!$32!$33!$34!$35!$36!$37!$38!$39!$40!$41!$42!$43!$44!$45!$46!$47!$48!$49!$50!$51!$52!$53!$54!$55!$56!$57!$58!$59!$60!$61!$62!$63!$64",
"isFake": false
},
{
Expand Down Expand Up @@ -227,107 +227,107 @@
"fullId": "",
"styles": {
"plot_0": {
"title": "High.All",
"title": "first_bar_time",
"isHidden": false
},
"plot_1": {
"title": "High.All.Date",
"title": "High.All",
"isHidden": false
},
"plot_10": {
"title": "price_52_week_low",
"title": "Open.All.Calc",
"isHidden": false
},
"plot_11": {
"title": "price_52_week_low_date",
"title": "price_52_week_low",
"isHidden": false
},
"plot_12": {
"title": "price_52_week_high",
"title": "price_52_week_low_date",
"isHidden": false
},
"plot_13": {
"title": "price_52_week_high_date",
"title": "price_52_week_high",
"isHidden": false
},
"plot_14": {
"title": "Low.6M",
"title": "price_52_week_high_date",
"isHidden": false
},
"plot_15": {
"title": "Low.6M.Date",
"title": "Low.6M",
"isHidden": false
},
"plot_16": {
"title": "High.6M",
"title": "Low.6M.Date",
"isHidden": false
},
"plot_17": {
"title": "High.6M.Date",
"title": "High.6M",
"isHidden": false
},
"plot_18": {
"title": "Low.3M",
"title": "High.6M.Date",
"isHidden": false
},
"plot_19": {
"title": "Low.3M.Date",
"title": "Low.3M",
"isHidden": false
},
"plot_2": {
"title": "High.All.Calc",
"title": "High.All.Date",
"isHidden": false
},
"plot_20": {
"title": "High.3M",
"title": "Low.3M.Date",
"isHidden": false
},
"plot_21": {
"title": "High.3M.Date",
"title": "High.3M",
"isHidden": false
},
"plot_22": {
"title": "Low.1M",
"title": "High.3M.Date",
"isHidden": false
},
"plot_23": {
"title": "Low.1M.Date",
"title": "Low.1M",
"isHidden": false
},
"plot_24": {
"title": "High.1M",
"title": "Low.1M.Date",
"isHidden": false
},
"plot_25": {
"title": "High.1M.Date",
"title": "High.1M",
"isHidden": false
},
"plot_26": {
"title": "Low.5D",
"title": "High.1M.Date",
"isHidden": false
},
"plot_27": {
"title": "High.5D",
"title": "Low.5D",
"isHidden": false
},
"plot_28": {
"title": "Volatility.W",
"title": "High.5D",
"isHidden": false
},
"plot_29": {
"title": "Volatility.M",
"title": "Volatility.W",
"isHidden": false
},
"plot_3": {
"title": "High.All.Calc.Date",
"title": "High.All.Calc",
"isHidden": false
},
"plot_30": {
"title": "Volatility.D",
"title": "Volatility.M",
"isHidden": false
},
"plot_31": {
"title": "first_bar_time",
"title": "Volatility.D",
"isHidden": false
},
"plot_32": {
Expand Down Expand Up @@ -363,7 +363,7 @@
"isHidden": false
},
"plot_4": {
"title": "Low.After.High.All",
"title": "High.All.Calc.Date",
"isHidden": false
},
"plot_40": {
Expand Down Expand Up @@ -403,23 +403,23 @@
"isHidden": false
},
"plot_5": {
"title": "Low.All",
"title": "Low.After.High.All",
"isHidden": false
},
"plot_6": {
"title": "Low.All.Date",
"title": "Low.All",
"isHidden": false
},
"plot_7": {
"title": "Low.All.Calc",
"title": "Low.All.Date",
"isHidden": false
},
"plot_8": {
"title": "Low.All.Calc.Date",
"title": "Low.All.Calc",
"isHidden": false
},
"plot_9": {
"title": "Open.All.Calc",
"title": "Low.All.Calc.Date",
"isHidden": false
}
}
Expand Down
Loading

0 comments on commit b714127

Please sign in to comment.