Hi,
I got a question.
I create a custom indicator name IBDRS and use it as the sorting criteria of another screener TrendTemplate
The screener works fine, but the sorting criteria seems does not work. From the screener window, the criteria column has value of 0 for all stock. Seems the sorting not work. Could you help?
Indicator code —>
// relative strength IBD style
rs3m=2*(close/close[63])
rs6m=1*(close/close[126])
rs9m=1*(close/close[189])
rs12m=1*(close/close[252])
RETURN(rs3m + rs6m + rs9m + rs12m)
Screener code —>
//PRC_Trend Template | screener
//13.04.2017
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
ma50=average[50]
ma150=average[150]
ma200=average[200]
//rsi14 = rsi[14](close)
ibdrs = IBDRS
ONCE PercentAboveLow = 0.3
ONCE PercentBelowHigh = 0.25
ONCE PeriodMaUp = 20
ONCE PerCentMaUp = 1
//ONCE PeriodsRsUp = 20
//ONCE PerCentRsiUp = 0.8
c1 = Close > ma50
c2 = ma50>ma150
c3 = ma150>ma200
c4 = summation[PeriodMaUp](ma200>ma200[1])>=PeriodMaUp*PerCentMaUp
c5 = Close/lowest[252](low)>1+PercentAboveLow
c6 = Close/highest[252](high)>1-PercentBelowHigh
//c7 = summation[PeriodsRsUp](rsi14 > rsi14[1])>=PeriodsRsUp*PerCentRsiUp
TrendTemplate = c1 and c2 and c3 and c4 and c5 and c6
//and c7
screener[TrendTemplate]SORT BY ibdrs
Result —>
That’s normal since your screener’s code doesn’t know what is IBDRS.
I assume you have named your indicator “IBDRS”, so you can call it from your screener with a CALL instruction:
ibrds = CALL "ibrds"
or change “ibrds” with the proper name of your indicator.
You can also have a look on how to call external program in any code: CALL Instruction