AMIBroker AFL variable managment

Discussion in 'Trading' started by banaro, Sep 28, 2011.

  1. banaro



    I am currently porting my trading systems from Fcharts to AMIbroker, so I can take advantage of the additional flexibility / power , but have run into a problem I cannot so far find references to resolve.

    I started with my short system, and in code attempting to resolve Cover, I require to access the position Opening price for calculations, this price is a bar Close, so I have been using the following "ValueWhen(Short,Close,1)", this works fine until a new Short True is received on a later bar but prior to a Cover,
    ExRem will NOT resolve the issue as it needs Short and Cover available first.
    I have tried resolving by looking back, but seem unable to get around the fact that Variables need to be initialised for the current pass before a can look back, chicken before the egg.
    It is probably obvious to AFL users, any help would be good.