Wednesday, September 08, 2010     | Register
TradersStudio Forums
Subject: I need help with the ADX function

You are not authorized to post a reply.   
Author Messages
Bebop
Posts:8

06-06-2010 1:20 PM Alert 
I am writing a system to generate Forex trades using the ADX. I want to initiate a trade when today's ADX is greater than yesterday's ADX by some amount ADXGrowth. In testing the system generates trades, seemingly, without regard to the ADX. I added a Print statement and the values displayed do not match the values displayed on the chart of the Directional Movement System. Would you help me understand the differences in what I'm seeing? Thanks, Bob Sub BJ_DMI_ADX_ATR (ADXMinGrowth As Double, DMILen As Integer, DMISpread As Double) ' (0.5, 14, 0 ) Dim BuyAge As Integer Dim SellAge As Integer Dim ADXPrevious As Double Dim ADXToday As Double Dim ATR As Double Dim ATRStopFactor As Double Dim EntryPoint As Double Dim LastTrailingATR As Double Dim PrtDate As String Dim barTrailingATR As BarArray PrtDate = FormatDateTime(Date) ATR = Average(TrueRange, 20, 0) BuyAge = BarsSinceEntryPlus("LongEntry") SellAge = BarsSinceEntryPlus("ShortEntry") ADXToday = ADX(18, 0) ADXPrevious = ADX(18, 1) + ADXMinGrowth If BarNumber > 250 Then Print "2 Date=", PrtDate, " Today=", ADXToday, " Previous=", ADXPrevious If (BuyAge < 0) And (SellAge < 0) Then 'If no orders are open, see if we want to open one. If ADXToday > ADXPrevious Then 'Have we got a good, increasing ADX? If DMIPlus(DMILen, 0) > (DMIMinus(DMILen, 0) + DMISpread) Then 'Let's think about a Long Buy Buy("LongEntry",1,0,Market,Day) EntryPoint = Open 'Replace with GetEntryPrice function barTrailingATR = EntryPoint - (ATRStopFactor * ATR) ' Set Initial Trailing ATR stop loss End If If DMIMinus(DMILen, 0) > (DMIPlus(DMILen, 0) + DMISpread) Then 'Let's think about a Short Sell Sell("ShortEntry",1,0,Market,Day) EntryPoint = Open 'Replace with GetEntryPrice function barTrailingATR = EntryPoint + (ATRStopFactor * ATR) ' Set Initial Trailing ATR stop loss End If End If Else
murray
Posts:519

06-06-2010 9:11 PM Alert 
ADX, DMI match the TradeStation standard versions. You need to use. ADXOld,DMIPlusOld,DMIMinusOld from system script. Those match the ones in the chart and represent wilders orginal calculations.
Bebop
Posts:8

06-07-2010 2:53 AM Alert 
I appreciate your reply and am still having some problems. I found out when I tried to save my system that it only takes one parameter and it seems to want a length rather than an offset. In order to compare today's bar with yesterday's I am storing the ADX value each day in a bararray. Still, the values do not match those on the chart and the DMI values returned by the DMIPlusOld/DMIMinusOld functions do not match the chart either. My code is "barADX = ADXOld(18)", where barADX is a bararray. What can I do to fix this? Thanks, Bob (not a TradeStation user)
murray
Posts:519

06-07-2010 10:20 AM Alert 
I checked this and though they where within some rounding error. Are you using the chart as part of the system or a quick chart. If your using a quick chart then maxbar back difference can effect the startup. Send some output showing the issue to Steve at Steve@TradersStudio.com and I will have him look at it for you.
Bebop
Posts:8

06-09-2010 2:06 PM Alert 
I am not using Quick Charts but I took your hint about Max Bars Back and lowered it. I had previously set it to a higher number for a different strategy. This has solved my problem. Thanks, Bob
You are not authorized to post a reply.
Forums > TradersStudio 2.x > TradersStudio Basic > I need help with the ADX function



ActiveForums 3.6
TradersStudio® Copyright 2004-2010 All Rights Reserved   |  Privacy Statement  |  Terms Of Use