How to calculate ATR by each contract and count contracts?

Discussions about the testing and simulation of mechanical trading systems using historical data and other methods. Trading Blox Customers should post Trading Blox specific questions in the Customer Support forum.
Post Reply
872251950
Contributing Member
Contributing Member
Posts: 8
Joined: Wed Dec 11, 2013 2:09 pm

How to calculate ATR by each contract and count contracts?

Post 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!
Jake Carriker
Site Admin
Site Admin
Posts: 1493
Joined: Fri Sep 12, 2003 10:32 am
Location: Austin, Texas

Post 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.
872251950
Contributing Member
Contributing Member
Posts: 8
Joined: Wed Dec 11, 2013 2:09 pm

Post 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
Post Reply