How to denote the close of the first bar/candle in afl

#1
Hi friends, please answer this,

How to denote the close of the first bar/candle in afl ?

Suppose on a 5 mt time chart where each bar is equal to 5 mts, the values of the first bar of the day ( 9.55 to 10.00) are,

open = 820
High = 828
Low = 814
close = 826

Now how to denote this close of the first bar ( 826 ) in afl.

If my Buy signal = present close > close of first bar (826), how to represent that in syntax.


Thankyou
psn.
 

asnavale

Well-Known Member
#2
Hi friends, please answer this,

How to denote the close of the first bar/candle in afl ?

Suppose on a 5 mt time chart where each bar is equal to 5 mts, the values of the first bar of the day ( 9.55 to 10.00) are,

open = 820
High = 828
Low = 814
close = 826

Now how to denote this close of the first bar ( 826 ) in afl.

If my Buy signal = present close > close of first bar (826), how to represent that in syntax.


Thankyou
psn.
Close of first bar is denoted by C[0]. Close of any bar is denoted by C where i is the index of the bar. For first bar i=0, for second bar i=1, third is i=2 and so on. For the last (latest)bar ypu can denote by C[BarCount - 1]

For your signal at a bar number x will be signal = C[x+1] > C[0]


-Anant
 
#3
Dear Anant,

How to denote the current Bar and previous Bar in afl syntax.

If Buy = Current day close > close of previous day, How to denote that.

According to what u said above current Bar = C[BarCount - 1]

Hence Current bar or Latest bar > Previous bar should be like this: C[BarCount - 1] > C[BarCount - 2];

But its not working. When scanned its picking every bar, both positive and negative closes. Please suggest.

Thanks.
 

zunayed

New Member
#4
Dear Anant,

How to denote the current Bar and previous Bar in afl syntax.

If Buy = Current day close > close of previous day, How to denote that.

According to what u said above current Bar = C[BarCount - 1]

Hence Current bar or Latest bar > Previous bar should be like this: C[BarCount - 1] > C[BarCount - 2];

But its not working. When scanned its picking every bar, both positive and negative closes. Please suggest.

Thanks.
Buy = close>Ref(close,-1);