How to build a generic indicator?
Forums › ProRealTime English forum › ProBuilder support › How to build a generic indicator?
- This topic has 5 replies, 3 voices, and was last updated 7 years ago by pieroim.
-
-
10/17/2017 at 8:54 AM #49640
How can I make an indicator that can be applied to the price rather than to other indicators? For example, if I realize a Moving Average indicator and want it to be applied to other indicators or to the price, as is the case in the Prorealtime series indicators, at what should I refer in to the instructions?
Thank’s
Piero
10/17/2017 at 9:37 AM #496441 – you started asking how to make an indicator to be applied to the price rather than to other indicators, all indicators are applied to the price, Moving Averages, Macd…..
2 – you said “For example, if I realize a Moving Average indicator and want it to be applied to other indicators”, is the contrary of what you asked before; do you want an indicator applied to price (like all, normally, do) or to other indicators? In this latter case you may write
1RETURN Average[5](Macd[12,26,9](close))as an example of a very stupid indicator just to explain basic building syntax; it’s a Moving Average, applied to another indicator (MACD in this case). You can make almost all you want.
Unless what you wanted to ask is how to apply an indicator to the price chart, instead of the indicators area below it. In this case you can see the four attached pics:
1 – click on the price Wrench icon (next to price tab) in the upper left corner of your chart
2 – when the property box opens, select Price and then click on Add an Indicator, then choose one that can be applied to price
3 – you will see the price of the chosen indicator in the property box
4 – there you go (this example is an indicator in this forum to print candlestick labels on the price chart)
If all the above is NOT what you asked for… ask again, with more details please.
Roberto
10/17/2017 at 9:57 AM #49649I’m realizing an indicator that can be applied on others indicator and on the price if I want this too.
I’m not using the indicators coded in PRT, like Average for example.
If I use Average[5](Macd[12,26,9](close)) for example, the indicator use exclusively MACD data output to calculate the Average.
So is not possible to use the same indicator programmed from me on others indicators than the MACD without changing the code.
I hope to have been clear..
Thank’s
10/17/2017 at 10:53 AM #49661I understand, it can be done, but it’s not as straightforward as if PRT language had arrays and pointers, example:
123456789DEFPARAM CalculateOnLastBars = 1000IF Selection = 1 THENx = Average[Periods, AvgType](Macd[m1,m2,m3](close)) //MacdELSIF Selection = 2 THENx = Average[Periods, AvgType](Rsi[RsiNum](close)) //RsiELSEx = 0ENDIFRTURN xyou must set variables Selection, Periods, m1, m2, m3, RsiNum and AvgType as modifiable by the user, so that you can assign them different values when CALLing the indicator.
For the range of values to be assigned to AvgType, see https://www.prorealcode.com/documentation/average/.
Of course you may add as many indicators as you want, but be aware that CALLing external indicators is a slow process, the slower the more complex it is!
You want to call it this way:
1indicator1 = CALL "My Indicator"[1, 20, 12, 26, 9, 14, 0]parameters must be written in the same order as you wrote your variables in the variable box (see pic).
10/17/2017 at 11:14 AM #49669You are my hero. Thanks a lot for all your detailed answers! 😀
10/17/2017 at 11:18 AM #49671 -
AuthorPosts
Find exclusive trading pro-tools on