Indicator on the last 100 bars ?
Forums › ProRealTime English forum › ProBuilder support › Indicator on the last 100 bars ?
- This topic has 7 replies, 2 voices, and was last updated 2 years ago by JC_Bywan.
-
-
03/09/2022 at 3:13 PM #189690
hi all,
I want to know how to make an indicator but only on the 100 last bar ?
this can working ?
123456FOR MyBars = 100 DownTO 0 Do// and here I can execute my indicator and draw for exemple//but only on the last 100 bars ?NextBest Reguards
03/09/2022 at 3:18 PM #189691Hi,
https://www.prorealcode.com/documentation/calculateonlastbars/
1 user thanked author for this post.
03/09/2022 at 3:32 PM #189693JC_Bywan
tks you to your quick answer, so if I use the DEFPARAM CalculateOnLastBars for for exemple 20 bars, and I use For boucle from 0 to 100 bars, my For boucle can’t go more then 0 to 10 ?
123456789DEFPARAM CalculateOnLastBars = 20For X = 0 to 100 Do// check somethink like onMyCondition = Condition[X]// I will be able to check only until the Condition[10]// even the for For going to 100I hope my question is clear
Best Reguards
03/09/2022 at 3:46 PM #189694On the description it said only on the indicators but is it valid for the screener ?
03/09/2022 at 4:00 PM #189695The question is clear only if you meant to write defparam calculateonlastbars=10 (instead of 20)
And no, in this case x still goes from 0 to 100 in its “for to next” loop, because it could be used for something else than condition[x] not related to a bar number… but the whole indicator including the loop is calculated only for the last 10 bars.
Then, if left to run live over more candles, values from “return” line are still only for last 10 bars, and graphic objects history (drawtext, drawsegment etc…) remain on all bars since launch.
You can try all sorts of mini-codes in a fast timeframe to experiment with it and grasp what it does. For exemple, you can use this in a 10s timeframe to quickly illustrate above lines:
123456789defparam CALCULATEONLASTBARS=10for x=0 to 20text=barindex-xDRAWTEXT("#text#", barindex, text)nextDRAWVLINE(barindex)return barindex, text1 user thanked author for this post.
03/09/2022 at 4:56 PM #189707Actually, I think I just got what you meant with keeping =20… but the answer is the same: x still goes from 0 to 100 with the loop, because using it in a later line to recall a barindex won’t make this for/next loop stop. Your condition x bars ago at code launch is 0 when that’s more than 20 bars ago, and the calculated value it’s supposed to have if less than 20 bars ago, hence your split in 10 and 10 question I guess… but loop keeps going after 10 until 100. And if your code keeps running for more candles than candle launch, then conditions history gets populated candle by candle, and at some point you’ll have all 100 available.
The limit is: at launch, and after launch for values in “return” line as it keeps going. The rest (graphic objects, data history) is not deleted as it keeps going and more and more of it is available, unless relaunching the indicator therefore creating a new start point.
1 user thanked author for this post.
03/10/2022 at 9:22 AM #189732tks a lot for all your answer, I will try the mini programme and I think yes it’s the best way to learn,
I ask the question by any chance you never know, is there a page or a link with lots of mini program like that to test I think it is a very very good way to learn
03/10/2022 at 1:22 PM #189745Hi, probably not, I just make one up whenever I want to check something
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on