array variables availability in ProRealTime – examples and discussions
Forums › ProRealTime English forum › ProBuilder support › array variables availability in ProRealTime – examples and discussions
- This topic has 201 replies, 44 voices, and was last updated 1 month ago by Aragorna.
02/26/2020 at 9:09 AM #120534
English only in the English forums!
Thank you 🙂02/26/2020 at 10:45 AM #120538
Nicolas is out of office today and asked me to inform that ARRAY support is already available to all users having PRT accounts!
🙂02/26/2020 at 1:33 PM #12056402/26/2020 at 1:49 PM #120571
Nicolas’ code at https://www.prorealcode.com/topic/array-variables-availability-in-prorealtime/#post-118817, works fine, did you try?02/26/2020 at 2:23 PM #12057602/26/2020 at 3:03 PM #12057902/26/2020 at 4:37 PM #120584
The new version will be pushed for PRT trading accounts (with IB) during the next week or so. In the mean time you can try building new amazing things with a free EOD account @ https://www.prorealtime.com02/26/2020 at 6:25 PM #120597
The probability cone now compiles correctly.
I enclose an attachment.
You mention VolTyp as a possible parameter instead of vol = 0.025.
I cannot find that in the function list. How would that be calculated?
Thank you for useful addition to the indicators.
Rory.02/26/2020 at 6:34 PM #12059902/26/2020 at 8:09 PM #120605
Thank you Nicolas. That would be much appreciated!02/27/2020 at 11:16 AM #120663
Example #5: tag exact time and price of an event (2 MA cross over) in real time, during the same bar
With variable array we are now capable of record events that occurred during a bar and not only at bar closure. In this example the code is checking on each new tick if 2 MA are crossing and therefore record the exact price and time when it happens.
For convenient reading I made the text plotted as an oscillator at 0 value. I also had blue and red arrows on the price coordinate to mark the bullish and bearish signals events.12345678910111213141516171819202122232425262728293031323334353637// https://www.prorealcode.com/topic/array-variables-availability-in-prorealtime/// (please do not remove the link above for future reference)// Example #5: tag exact time and price of an event (2 MA cross over) in real time, during the same bar//declare the moving averagesf=averages=average//declare the events (trading signals)bullish = (f > s and f < s)bearish = (f < s and f > s)if islastbarupdate then//check and store the signalif (bullish or bearish) and lastset($crosstime)<barindex then //if no signal already occurred on that bar then ..$crosstime[barindex]=time //store the time of event$crossprice[barindex]=close //store the price of eventif bullish then$signal[barindex]=1 //store the signal directionelsif bearish then$signal[barindex]=-1endifendif//draw the graphic componentif isset($signal[barindex]) then //if an event occurred on that bar then do somethingif $signal[barindex]=1 then //bullish casedrawarrowup(barindex,$crossprice[barindex]) coloured(0,255,255)else //bearish casedrawarrowdown(barindex,$crossprice[barindex]) coloured(0,255,255)endifitime=$crosstime[barindex] //create time readable variable for drawtextiprice=$crossprice[barindex] //create price readable variable for drawtextdrawtext("time=#itime#",barindex,0,serif,bold,20) //plot the time of the eventdrawtext("price=#iprice#",barindex,0.4,serif,bold,20) //plot the price of the eventendifendifreturn02/27/2020 at 1:00 PM #120677
Thanks for that last example Nicolas. I learnt from it that we have to convert our array variable into a non array variable to use in drawtext. That might save me a lot of time scratching my head in the future when first trying to draw an array value!02/27/2020 at 4:43 PM #120690
Good evening Nicolas,
I took the code as it was, I understood its coding
and however I have no results on the graph.
I can’t understand why.
I’m version 11
an idea about the possible problem
Thank you02/27/2020 at 5:24 PM #120692
This topic is in English, please respect other people reading it. I suppose you are talking about the last example (number 5). Are you trying to use it on a prorealtime.com software account? That indicator will not show anything in history at first load, the event must be found in realtime during the candlestick forming.02/28/2020 at 10:19 AM #120721
Example #6: Flat base triangle aka double top/bottom
This example is using the similar framework than in the first one, by storing the tops and bottoms fractals we can easily find some graphical patterns in the chart. The code is looking 2 recent points (tops or bottoms, peaks or valleys), check if they are almost flat (price change percent less than the percent setting), draw a segment between the 2 points. Then it finds the lowest or highest price between the twos and draw the flat base triangle. Note that the 3rd point of the triangle is plotted at mid way between the 2 points of the base and not at the exact bar that created the highest or lowest.
This snippet could be modded/extended to many more interesting things, I count on you to give back some useful codes! 🙂12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667// https://www.prorealcode.com/topic/array-variables-availability-in-prorealtime/// (please do not remove the link above for future reference)// Example #6: flat base triangle or double top/bottomdefparam drawonlastbaronly=true// --- settingsfractalP = 10 //fractal periodpercent = 0.05 //maximum percent change between the 2 pointsbarlimit = 100 //maximum bars between 2 pointsshowTriangle = 1 //show the triangle between the 2 points (1=yes,0=no)// --- end of settings//fractalscp=fractalPif high[cp] >= highest[(cp)*2+1](high) then //new fractal high found$TOPy[lastset($TOPy)+1] = high[cp] //store fractal value$TOPx[lastset($TOPx)+1] = barindex[cp] //store fractal barindexendifif low[cp] <= lowest[(cp)*2+1](low) then //new fractal low found$BOTy[lastset($BOTy)+1] = low[cp] //store fractal value$BOTx[lastset($BOTx)+1] = barindex[cp] //stire fractal barindexendifif(islastbarupdate and isset($topy) and isset($boty)) then//check points in a range of X percentfor i = 0 to lastset($TOPy) do //loop through the topsfor y = 0 to lastset($TOPy) do //check first top with other topschange=abs(($topy[y]-$topy[i])/$topy[i]) //percent range between the 2 topsbardiff=abs($TOPx[i]-$TOPx[y]) //how many bars between the 2 points?if change<=percent/100 and bardiff<barlimit and bardiff>=fractalP and $topx[i]<>$topx[y] then//plot points at each topDRAWPOINT($topx[i],$topy[i],5) COLOURED (0,255,0,25) BORDERCOLOR (0,200,0)DRAWPOINT($topx[y],$topy[y],5) COLOURED (0,255,0,25) BORDERCOLOR (0,200,0)//plot the flat basedrawsegment($topx[i],$topy[i],$topx[y],$topy[y]) style(dottedline,2)if(showTriangle) then//find the lowest point between the 2 topsll = lowest[bardiff](low)[barindex-max($topx[i],$topx[y])]//plot the triangledrawtriangle($topx[i],$topy[i],$topx[y],$topy[y],max($topx[i],$topx[y])-bardiff/2,ll) COLOURED (0,255,0,20) BORDERCOLOR (0,200,0,0)endifendifnextnextfor i = 0 to lastset($BOTy) do //loop through the bottomsfor y = 0 to lastset($BOTy) do //check first bottom with other bottomschange=abs(($boty[y]-$boty[i])/$boty[i]) //percent range between the 2 bottomsbardiff=abs($botx[i]-$botx[y]) //how many bars between the 2 points?if change<=percent/100 and bardiff<barlimit and bardiff>=fractalP and $BOTx[i]<>$BOTx[y] then//plot points at each bottomDRAWPOINT($botx[i],$boty[i],5) COLOURED (255,0,0,25) BORDERCOLOR (200,0,0)DRAWPOINT($botx[y],$boty[y],5) COLOURED (255,0,0,25) BORDERCOLOR (200,0,0)//plot the flat basedrawsegment($botx[i],$boty[i],$botx[y],$boty[y]) style(dottedline,2)if(showTriangle) then//find the lowest point between the 2 topshh = highest[bardiff](high)[barindex-max($botx[i],$botx[y])]//plot the triangledrawtriangle($botx[i],$boty[i],$botx[y],$boty[y],max($botx[i],$botx[y])-bardiff/2,hh) COLOURED (255,0,0,20) BORDERCOLOR (200,0,0,0)endifendifnextnextendifreturn
3 users thanked author for this post.
Find exclusive trading pro-tools on