Page 1 of 1

How to calculate ATR by each contract and count contracts?

Posted: Thu Jan 23, 2014 4:06 pm
by 872251950
Hello everyone,

I want to compare each instrument's ATR(20Bars) with its forward 30 bars ATR(20Bars) to see whether ATR(20Bars) is increasing or decreasing and then count those contracts with increasing ATR. I wonder if it is doable in portfolio manager of tradingblox in order to filter trades?

Appreciate!

Posted: Thu Jan 23, 2014 4:09 pm
by Jake Carriker
Sure it is, although you have to look backwards into the past, not forward into the future, since that has not happened yet. You can always compare today's ATR with the ATR on any date in the past.

Posted: Thu Jan 23, 2014 4:13 pm
by 872251950
Thank you for your reply Jake,

Here is my logic in coding this and I wonder if my logic is right.

variables: InstrumentCount, x type: Integer
InstrumentCount=system.totalinstruments

' Set the instrument to deny trades by default
instrument.DenyAllTrades


ATR_ROC= RateOfChange ( ATR, Forward_Count)

for x = 1 to InstrumentCount step 1


if ATR_ROC>0 then

VDI_Count=VDI_Count+1

Endif

next