range trading session and days (Range SD)
Forums › ProRealTime English forum › ProBuilder support › range trading session and days (Range SD)
- This topic has 5 replies, 3 voices, and was last updated 2 weeks ago by
Iván.
-
-
05/22/2025 at 1:44 PM #247493
I want to make an indicator for Pro real time based on range of the London session the New York session and the Tokyo session from the opening and closes of their trading days and then I want to look at the previous 14 of those trading ranges so we look back at the London open and close 14 times in the past then give me the average range and then display it on the chart on over a daily 4 hour or one hour chart in a box in over the left or right hand corner showing the figures not only do I want the indicator to do that I also wanted to show me the range of the days so the last 14 Mondays average Range and then display that as a figure on the chart as well as the rest of the days of the week from Monday to Friday I want to be able to change the. I’ve looked back of those ranges from 14 to 20 to let’s say eight whatever I want to put in
I have had a try code with AI help lots of errors
Range SD123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121// === INPUT PARAMETERS === Range SDrangeLength = 14 // Lookback period (e.g., 14, 20, or 8 days)showTopLeft = 1 // 1 = top-left corner, 0 = top-right// === INITIALIZATION ===once dayRangeMonday[] = 0once dayRangeTuesday[] = 0once dayRangeWednesday[] = 0once dayRangeThursday[] = 0once dayRangeFriday[] = 0once tyoRanges[] = 0once ldnRanges[] = 0once nycRanges[] = 0// === TIME FILTERS FOR SESSIONS (GMT) ===// Tokyo: 00:00 - 09:00 GMTinTokyoSession = (time >= 000000 and time < 090000)// London: 07:00 - 16:00 GMTinLondonSession = (time >= 070000 and time < 160000)// New York: 12:00 - 21:00 GMTinNewYorkSession = (time >= 120000 and time < 210000)// === SESSION RANGE CALCULATION ===if barindex > rangeLength * 24 then// Store daily high/low per sessionif inTokyoSession thentyoHigh = max(tyoHigh, high)tyoLow = min(tyoLow, low)endifif inLondonSession thenldnHigh = max(ldnHigh, high)ldnLow = min(ldnLow, low)endifif inNewYorkSession thennycHigh = max(nycHigh, high)nycLow = min(nycLow, low)endif// End of day (at 23:00 GMT) – commit range and resetif time = 230000 then// Session Rangesif tyoHigh <> 0 and tyoLow <> 0 thentyoRanges.append(tyoHigh - tyoLow)endifif ldnHigh <> 0 and ldnLow <> 0 thenldnRanges.append(ldnHigh - ldnLow)endifif nycHigh <> 0 and nycLow <> 0 thennycRanges.append(nycHigh - nycLow)endif// Weekday RangesdayRange = high - lowselect dayofweekcase 1dayRangeMonday.append(dayRange)case 2dayRangeTuesday.append(dayRange)case 3dayRangeWednesday.append(dayRange)case 4dayRangeThursday.append(dayRange)case 5dayRangeFriday.append(dayRange)endselect// Reset session high/lowtyoHigh = 0tyoLow = 999999ldnHigh = 0ldnLow = 999999nycHigh = 0nycLow = 999999endifendif// === AVERAGE RANGE CALCULATION FUNCTION ===def calcAverage(array, length)sum = 0count = min(length, array.size)for i = 0 to count - 1 dosum = sum + array[i]nextif count > 0 thenresult = sum / countelseresult = 0endifreturn resultenddef// === COMPUTE AVERAGES ===avgTyo = calcAverage(tyoRanges, rangeLength)avgLdn = calcAverage(ldnRanges, rangeLength)avgNyc = calcAverage(nycRanges, rangeLength)avgMon = calcAverage(dayRangeMonday, rangeLength)avgTue = calcAverage(dayRangeTuesday, rangeLength)avgWed = calcAverage(dayRangeWednesday, rangeLength)avgThu = calcAverage(dayRangeThursday, rangeLength)avgFri = calcAverage(dayRangeFriday, rangeLength)// === DISPLAY TEXT OUTPUT ===xOffset = 10yOffset = 20if showTopLeft thenposX = barindex - xOffsetelseposX = barindex + xOffsetendifdrawtext("TYO R " + round(avgTyo), posX, high + yOffset, dialog, "Arial", 12, standard, showTopLeft)drawtext("LND R " + round(avgLdn), posX, high + yOffset - 10, dialog, "Arial", 12, standard, showTopLeft)drawtext("NYC R " + round(avgNyc), posX, high + yOffset - 20, dialog, "Arial", 12, standard, showTopLeft)drawtext("M " + round(avgMon), posX, high + yOffset - 40, dialog, "Arial", 12, standard, showTopLeft)drawtext("T " + round(avgTue), posX, high + yOffset - 50, dialog, "Arial", 12, standard, showTopLeft)drawtext("W " + round(avgWed), posX, high + yOffset - 60, dialog, "Arial", 12, standard, showTopLeft)drawtext("T " + round(avgThu), posX, high + yOffset - 70, dialog, "Arial", 12, standard, showTopLeft)drawtext("F " + round(avgFri), posX, high + yOffset - 80, dialog, "Arial", 12, standard, showTopLeft)05/22/2025 at 3:31 PM #247506I just deleted the other topic in the wrong forum 🙂
1 user thanked author for this post.
05/23/2025 at 9:16 AM #247550Hello Roberto Just wondering,,, trying not to be rude and being patience is virtue is there a long waiting time at the moment sorry to ask
05/23/2025 at 10:13 AM #247553Hi. I think the best way is working with arrays. You can start working with this example (London):
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768defparam drawonlastbaronly=true//----------------------------------------------////-----INPUTS-----------------------------------////----------------------------------------------//openLO=080000closeLO=110000limitday=180000rangelookback=5atr=averagetruerange[14](close)if gettimeframe<=3600 then//----------------------------------------------////-----London Zone------------------------------////----------------------------------------------//once maxHighLO=highonce minLowLO=lowif opentime>=openLO and opentime<=closeLO thenbarLO=barLO+1if high>=maxHighLO thenmaxHighLO=highelsemaxHighLO=maxHighLOendifif low<=minLowLO thenminLowLO=lowelseminLowLO=minLowLOendifendifif opentime=closeLO then//---------------------------------------//// Create Arrays to store information//---------------------------------------//$minLowLO[n+1]=minLowLO$maxhighLo[n+1]=maxHighLO$dailyrange[n+1]=maxHighLO-minLowLO$barStart[n+1]=barindex[barLO]$barEnd[n+1]=barindexn=n+1//---------------------------------------//prevLowLO=minLowLOprevHighLO=maxHighLOprevidxLO=barindexbarLO=0minLowLO=high*100maxHighLO=0endif//---------------------------------------//// Use information stored in Arrays//---------------------------------------//if islastbarupdate thencumrange=0numrange=0for i=n downto n-rangelookback documrange=cumrange+$dailyrange[i]numrange=numrange+1dailyRange=$dailyrange[i]drawtext("Range:#dailyRange#",$barStart[i],$maxhighLo[i]+atr)drawrectangle($barStart[i],$minLowLO[i],$barEnd[i],$maxhighLo[i])coloured("red")fillcolor("red",30)nextavgrange=round(cumrange/numrange,3)drawtext("AvgRange=#avgrange#",-100,-100)anchor(topright,xshift,yshift)endifelsedrawtext("Change timeframe to 1hr or less",0,0,SansSerif,bold,34)anchor(middle,xshift,yshift)endifreturn05/23/2025 at 2:31 PM #247564Ok thank you very very much I have been playing about with it playing with the settings working out what does what and it’s perfect it’s exactly correct and from this I can go do some war stuff that would do like the Monday Tuesday Wednesday Thursday Friday bars might need your help with that though I’ll give it a now the question is when I do the other New York Times do I add that into the same coding or do I do it separately and have it as a separate indicator or put it all together as one what would be better thank you thank you
05/26/2025 at 9:33 AM #247600Hi. You can code in the same indicator. Just changing the name for the variables.
You can take as an example this indicator: https://www.prorealcode.com/prorealtime-indicators/ict-killzones-and-pivots/ -
AuthorPosts
Find exclusive trading pro-tools on