Hi, I'm trying to write a simple EL exit strategy to sell or buytoclose when the price comes back to VWAP I have a code that is functional but when it is employed it seems to actually sell or buy at at a 20MA, not VWAP. Inputs and variables below: inputs: VWAPLength(20); variables: VWAPValue(0); VWAPValue = Average(close, VWAPLength); if close crosses above VWAPValue then sell next bar at market; else if close crosses below VWAPValue then buy to cover next bar at market; Any ideas as to why this would be happening? Thanks Dan
are you calculating vwap or is it builtin? I dont see any volume used in your post vwap = dotproduct(prices[], volumes[])/sum(volumes[])
I thought it was built-in, but maybe that’s where the problem is. VWAP turns blue as a reserved word in EL but maybe for the purpose of strategy it needs to be separately calculated?