EasyLanguage EL VWAP exit

Discussion in 'Strategy Building' started by DRL, Apr 2, 2024.

  1. DRL

    DRL

    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
     
  2. 2rosy

    2rosy

    are you calculating vwap or is it builtin? I dont see any volume used in your post
    vwap = dotproduct(prices[], volumes[])/sum(volumes[])
     
  3. DRL

    DRL

    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?
     
  4. RStrauss

    RStrauss

    Use their built-in function namely VWAPResettable