Announcement

Collapse
No announcement yet.

close() above or below VWAP

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • close() above or below VWAP

    Hello,

    I'm trying to write the script to say:

    If close(0) > VWAP, then BUY
    OR
    If close(0) < VWAP, then SELL

    I'm using the amVWAP2.efs script from the amStudies Libarary.

    I have the BUY and SELL conditions and PostMain statements down fine, but the actual way to state the logic for amVWAP is getting me. It should be pretty straight forward and what I figured it would look like would be:

    close() > amVWAP2("930", 15)
    OR
    close() < amVWAP2("930", 15)

    However, I keep getting the error:
    ReferenceError: amVWAP2 is not defined.

    Do I need to create a variable for amVWAP2 and then use that variable in the condition set? Or is there a way to directly access the amVWAP2 value without having to use a variable?

    Or is there a much simpler way to state this and I'm just missing it completely?

  • #2
    Also, is there a way to have an event only happen the first time and not every time the conditions are met.

    For example: If I am taking profit when close() is > 5pts from the low(), I ONLY want to take profit the first time that condition is met, not every single bar where close() > 2pts from the low(). Because the close() price may stay above 5pts from the low() and i don't want to cover my entire position, jsut take a piece of it off the first time the condition of the close() > 5pts from the low().


    Any help would be greatly appreciated. Thanks in advance.

    Comment

    Working...
    X