Referencing a value from an array (Amibroker AFL)

Discussion in 'App Development' started by hedron, May 20, 2015.

  1. hedron

    hedron

    targetprice = Ref ( alt , -BarsSince ( Buy ) ) ;

    alt is an array that constantly changes from bar to bar. I want targetprice to reference the specific value of the alt array at the bar when the buy signal occurred. The problem with the above solution, is that if another buy signal occurs before the price meets the original targetprice value, the value of targetprice changes.


    So, how do I reference the value of from the specific bar the buy signal occurred?


    Thanks.
     
  2. Try ExRem function for taking only the very first buy signal and ignore all until a sell comes.
     
  3. hedron

    hedron

    Thanks but, the variable targetprice is in the sell equation. I don't see how that could work.

    Maybe this is a better way of framing the question: How do I make the value of a variable independent of the array it's drawn from? Because it keeps updating every refresh. How do I stop it from refreshing the value until a specified event occurs?
     
  4. M.ST.

    M.ST.

    Seems like you've got a response with example in AB's official forum already.
    https://groups.yahoo.com/neo/groups/amibroker/conversations/messages/190684