Hello everyone,
I m having trouble creating a Supply & Demand indicator.
On the image below you see that the drawing is correct, but the values I m returning are not!
The values are assigned in the same for loop with the same values that are drawn.
But somehow it returns the values shifted.
Can someone help me?
Thanks Taklause
I did not look at the code, but if you return a value contained in a loop with RETURN, therefore the variable is returning the last value assigned in the loop (at the end of the loop or with a BREAK instruction).
ATR = AverageTrueRange[inspectingPeriods](close)
currentSupplyIndex = 0
IF searchDirection = -1 THEN
candleWidth = OPEN-CLOSE
supplyLevelCandleSize = HIGHEST[inspectingPeriods](candleWidth) // GET LAST N CANDLESIZE (RED ARE POSITIVE)
IF supplyLevelCandleSize > Filterthreshold*STD[inspectingPeriods](candleWidth) THEN // FILTER
for ind = 0 to inspectingPeriods-1 DO
IF supplyLevelCandleSize = OPEN[ind]-CLOSE[ind] THEN
currentSupplyIndex = BARINDEX - ind
DRAWARROWDOWN(currentSupplyIndex,OPEN[ind]) coloured(255,0,0)
DRAWRECTANGLE(currentSupplyIndex,OPEN[ind],currentSupplyIndex+resetCounter,OPEN[ind]-ATR)coloured(255,0,0)
eventCounter = 1 // START INCREMENTING
demandOrSupplyZoneStart = OPEN[ind] // RETURN VALUE AT THE END
demandOrSupplyZoneEnd = OPEN[ind]-ATR // RETURN VALUE AT THE END
supplyOrDemand = searchDirection // RETURN VALUE AT THE END
BREAK // conditions met, exit loop
ENDIF
NEXT
ENDIF
ENDIF
This is one for loop. The demandOrSupplyZoneStart,demandOrSupplyZoneEnd and the supplyOrDemand flag are returned. They are initialized as a “once” variable. Therefore I would expect if the correct drawings are made, the values are accordingly assigned ? Shouldnt they?
Try changing lines 15 and 16 with these two:
demandOrSupplyZoneEnd = OPEN[ind]-ATR[ind]
supplyOrDemand = searchDirection[ind]
and line 11 with:
DRAWRECTANGLE(currentSupplyIndex,OPEN[ind],currentSupplyIndex+resetCounter,OPEN[ind]-ATR[ind])coloured(255,0,0)