Forums › ProRealTime English forum › ProBuilder support › CalculateOnLastBars range? › Reply To: CalculateOnLastBars range?
If you want to use this indicator in a system, you need to add values in the RETURN instruction, otherwise nothing are present when you are CALLing in a strategy. Seems obvious, just say .. 🙂
Of course you’ll always get the last values of the indicator, not the last X supports and resistances because we can’t build arrays, we need to define first of much variables must be defined. Not a problem when we plot them with a persistent line on a chart, but a real one when we want to store them in memory to retrieve them later..
So, in order to get the last values of your S/R:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
// Parameters Period = 20 length = 13 // Donchian Upper = HIGHEST[Period](HIGH[1]) Lower = LOWEST[Period](LOW[1]) // Draw the lines for shorts IF Upper[length] = Upper THEN //DRAWHLINE(Upper)coloured(255,51,51) res = upper ENDIF // Draw the lines for longs IF Lower[length] = Lower THEN //DRAWHLINE(Lower)coloured(0,201,57) sup = lower ENDIF RETURN res as "resistance", sup as "support" |
Now you only have to call this indi into your proorder strategy. To get previous support / resistance, you can also make a loop in the past in the strategy itself:
1 2 3 4 5 6 7 8 9 10 11 12 |
//we CALL the sup/res indi sup,res = CALL "sup res indi"[20,13] //we make a loop in the past to find previous support and resistance for i = 1 to 100 if sup[i]<>sup then previoussup = sup[i] endif if res[i]<>res then previousres = res[i] endif next |