I'm not able to run code in AFL where I need to satisfy 2 timeranges in short...please help ..

Discussion in 'App Development' started by Vaib12345, Sep 21, 2018.

  1. Vaib12345

    Vaib12345

    Below is snapshot what I have created :

    Timerange = TimeNum() > 091500 AND TimeNum() < 094500 ;
    Timerange1 = TimeNum() > 133000 AND TimeNum() < 143000 ;
    Timeout = TimeNum() > 151500;
    Range = LLV(L,5) ;
    Range2 = HHV(H,5) ;

    X = one of the resistance level
    Y = one of the support level

    Trend = Timerange AND Ref(Range,-1) > X ;
    Trend2 = (Timerange AND Ref(Range,-1) > X) and (Timerange1 and Ref(Range2,-1) < Y) ;


    Buy = Trend ;
    Sell = Timeout OR Trend2;
    Short = Trend2 ;
    Cover = Timeout ;

    Buy = ExRem(Buy,Sell) ;
    Short = ExRem(short,Cover) ;
    Sell = ExRem(Sell,Buy) ;
    Cover = ExRem(Cover,Short) ;

    The issue is that Trend 2 is only reading "Timerange" array and is not reading "Timerange1" array.
     
  2. SunTrader

    SunTrader

    AFL is "Greek" to me but why are you referencing Trend characteristics again in Trend2 when breaking support and resistance are two different events?
     
  3. Vaib12345

    Vaib12345

    This is because.."Trend" is a buy indicator
    and Trend2 is for shorting only those stocks which were buy earlier..
    so..my expression for short is that is stock was trading above x in "timerange" and later on in "timrange1" it came below Y then it should shortsell my stock.

    As it will shortsell...it will also square off my buy position..

    Hope I'm able to make it clear..let me know your doubts
     
  4. themickey

    themickey

    Just guessing here, have you tried......?

    Trend = Timerange AND Ref(Range,-1) > X ;
    Trend1 = Timerange1 AND Ref(Range2,-1) < Y ;
    Trend2 = Trend + Trend1 ;
     
  5. Vaib12345

    Vaib12345

    No ..This is also not working...

    I think the issue is that system is getting confused while reading 2 timeranges..
    I mean..whether it should read Timerange first and then Timerange1 or the other way round..

    Can we tell system to read the timerange on current day only..it might be reading one "timerange1" from previous day and "Timerange" from current day..just a thought
     
  6. Vaib12345

    Vaib12345

    I also tried this "Day()!=Ref(Day(), -1)" with Trend2...but still not working