I’m trying to code a screener for demand and supply levels. I have successfully made indicators and I now want to screen markets.
I have made two functions that I call and each of them works separately in separate screeners. However. When I try to merge these two screeners into one I get a circular reference.
I have attached the code that works. But as soon as I uncomment the code underneath it gives me circular reference. I can’t figure out why.
MaxCandleIterations = 200
CurrentCandleIndex = 1
ValueToReturn = -1
WHILE CurrentCandleIndex < MaxCandleIterations
// Check for demand.
IF (OPEN > CLOSE) THEN
Demand, DemandBottom, DemandTop = CALL "Demand zone"[CurrentCandleIndex]
// Buy signal here.
IF (Demand = 1 AND LOW < DemandTop AND LOW > DemandBottom) THEN
ValueToReturn = 1
BREAK
ENDIF
// Check for supply.
ELSE
Supply, SupplyBottom, SupplyTop = CALL "Supply zone"[CurrentCandleIndex]
// Sell signal here.
IF (Supply = 1 AND HIGH > SupplyBottom AND HIGH < SupplyTop) THEN
ValueToReturn = 0
BREAK
ENDIF
//IF (Supply = 0 AND HIGH > SupplyBottom AND HIGH < SupplyTop) THEN
// Just iterate one more candle to make sure demand isn't hiding behind.
//Supply, SupplyBottom, SupplyTop = CALL "Supply zone"[CurrentCandleIndex + 1]
//IF (Supply = 0) THEN
//BREAK
//ENDIF
//ENDIF
ENDIF
CurrentCandleIndex = CurrentCandleIndex + 1
WEND
IF (ValueToReturn > -1) THEN
SCREENER (ValueToReturn AS "Zone")
ENDIF
Let’s see if I can clarify something 🙂
I have functions that I have created that both works fine and return 3 different values.
I have no idea why this gives me circle reference as soon as I uncomment the row: //Supply, SupplyBottom, SupplyTop = CALL “Supply zone”[CurrentCandleIndex + 1]
Anyone have any ideas at all?
What do you mean by getting circular reference with the code please?