NexusFi: Find Your Edge


Home Menu

 





Random Walk by Poulos


Discussion in TradeStation

Updated
      Top Posters
    1. looks_one SMCJB with 7 posts (3 thanks)
    2. looks_two Shaban with 4 posts (3 thanks)
    3. looks_3 Mucho20 with 4 posts (1 thanks)
    4. looks_4 kevinkdog with 3 posts (1 thanks)
      Best Posters
    1. looks_one Shaban with 0.8 thanks per post
    2. looks_two SMCJB with 0.4 thanks per post
    3. looks_3 kevinkdog with 0.3 thanks per post
    4. looks_4 Mucho20 with 0.3 thanks per post
    1. trending_up 3,668 views
    2. thumb_up 8 thanks given
    3. group 4 followers
    1. forum 18 posts
    2. attach_file 5 attachments




 
Search this Thread

Random Walk by Poulos

  #1 (permalink)
 Mucho20 
Chesterton, IN /USA
 
Experience: Intermediate
Platform: TradeStation
Trading: 2 Year Treasury Notes
Posts: 5 since Mar 2020
Thanks Given: 2
Thanks Received: 1

Can someone provide the code for Poulos' Random Walk indicator? I need it to be written for TradeStation's EasyLanguage. For some reason TS does not provide this indicator. Thanks!!

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Futures True Range Report
The Elite Circle
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Exit Strategy
NinjaTrader
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 johnnymustard 
Las Vegas, NV
 
Experience: Intermediate
Platform: NT 8
Broker: NT Brokerage, IQFeed
Trading: ES, 6E & CL
Posts: 71 since Aug 2013
Thanks Given: 9
Thanks Received: 40

Here is the formula and the brief article where I found it.
https://tradingsim.com/blog/random-walk-index/?print=pdf

So if you can find someone that can write TS code, you're all set.
Hopefully this will get you a little closer, good luck. JM

Random Walk Index Formula
The random walk index determines if a security is in an
uptrend or downtrend.

For each period the RWI is computed
by calculating the maximum of the following values for high
periodsHI – LO.n) / (ATR.1(n) * SQRT(n))

For each period the RWI is computed by calculating the
maximum of the following values for low periods:
(HI.n – LO) / (ATR.1(n) * SQRT(n))

Attached Files
Elite Membership required to download: RandomWalkIndex.pdf
Reply With Quote
  #3 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129


Here is an article that explains well the characteristics of the indicator: Random Walk Index:

https://www.technicalindicators.net/indicators-technical-analysis/168-rwi-random-walk-index

and this is the original formula for the indicator, written by E. Michael Poulos:

https://postimg.cc/VJfPNXd9

hope someone can translate it into easylanguage.

Reply With Quote
  #4 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

Here's the formula:

// Random Walk Index

input:Len(14);

Vars:RWIH(0),
RWIL(0),
ERW(0);

ERW=AvgTrueRange(Len)*SquareRoot(Len);

if ERW <> 0 then Begin
RWIH = (High - Low[Len])/ERW;
RWIL = (High[Len] - Low)/ERW;
end;

Plot1(RWIH , "HRWI") ;
Plot2(RWIL , "LRWI") ;

Plot3(1) ;

Reply With Quote
Thanked by:
  #5 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,041 since Dec 2013
Thanks Given: 4,375
Thanks Received: 10,192

Interesting subject @Mucho20 and thanks for the input @Shaban.

I will say though that whats explained here...

Shaban View Post
Here is an article that explains well the characteristics of the indicator: Random Walk Index:

https://www.technicalindicators.net/indicators-technical-analysis/168-rwi-random-walk-index

and this is the original formula for the indicator, written by E. Michael Poulos:

https://postimg.cc/VJfPNXd9

hope someone can translate it into easylanguage.

does not match this code here...


Shaban View Post
Here's the formula:

// Random Walk Index

input:Len(14);

Vars:RWIH(0),
RWIL(0),
ERW(0);

ERW=AvgTrueRange(Len)*SquareRoot(Len);

if ERW <> 0 then Begin
RWIH = (High - Low[Len])/ERW;
RWIL = (High[Len] - Low)/ERW;
end;

Plot1(RWIH , "HRWI") ;
Plot2(RWIL , "LRWI") ;

Plot3(1) ;

The key point/difference seems to be ...



So it's not as simple as comparing High vs Low[Len]. You need to do it for all value of Len from 1 to Len and then take the max value.

Busy now but might try my hand at this if I have time later.

Reply With Quote
  #6 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,041 since Dec 2013
Thanks Given: 4,375
Thanks Received: 10,192

edit2 this is wrong. see next post.

Thinking about this a little more, I believe the following holds true

Which would mean the code becomes

 
Code
// Random Walk Index

input:Len(14);

Vars:RWIH(0), 
     RWIL(0), 
     ERW(0); 
 
ERW=AvgTrueRange(Len)*SquareRoot(Len);
 
if ERW <> 0 then Begin
   RWIH = (High - Lowest(Low, Len))/ERW;
   RWIL = ((Highest(High, Len) - Low)/ERW;
end;

Reply With Quote
Thanked by:
  #7 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,041 since Dec 2013
Thanks Given: 4,375
Thanks Received: 10,192

While it is true that

It does NOT hold for

so you can't make that simple substitution.

Reply With Quote
  #8 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,041 since Dec 2013
Thanks Given: 4,375
Thanks Received: 10,192

I like the theory around this (how expected volatility increases relative to the square root of time) but not sure I like the actual implementation as much. The dynamic nature of the lookup is that when you have a single day, counter trend, the indicator in the direction of the trend is using a high n, looking at the longer term trend, and is not effected by the single day counter. The indicator in the opposite direction of the trend though will often take the value when n=1 and hence spike to high numbers for short periods of time despite the ongoing trend in the other direction. ie you get days where both the up and down indicator are both significantly above 1!

Anyway this code works properly.
 
Code
Input:
	Length(14);

Vars:
	Loop(1),
	RWIH(0),
	RWIL(0),
	ERW(0);

For Loop = 1 To Length Begin
	ERW = (AvgTrueRange(Loop) * SquareRoot(Loop));
	If Loop = 1 then begin
		RWIH = (High - Low[1])/ERW;
		RWIL = (High[1] - Low)/ERW;
	End;
	If Loop > 1 then begin
		RWIH = maxlist(RWIH, (High - Low[Loop])/ERW);
		RWIL = maxlist(RWIL, (High[Loop] - Low)/ERW);
	End;
End;

Plot1(RWIH , "HRWI") ;
Plot2(RWIL , "LRWI") ;

Plot3(1) ;

Reply With Quote
  #9 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129


SMCJB View Post
;[/CODE]


Hi SMCJB,

compliments for your observations; if you want, here you can download the formulas for Metastock of the Random Walk Index, and I believe that they are in line with your specifications (there are Short Term and Long Term versions):

https://www.mediafire.com/error.php?errno=320&origin=download

I believe that you can easily transform the formulas into Easylanguage, I have also added explanations of Metastock terms, moreover there is also another original article by E. Michael Poulos.

If they can be useful, here are two Functions of the Random Walk Index, in easylanguage, and from here, you could create the indicator:

https://www.multicharts.com/discussion/viewtopic.php?t=11125

Thank you very much.

Reply With Quote
  #10 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,041 since Dec 2013
Thanks Given: 4,375
Thanks Received: 10,192


Thanks. That code uses an array to store the values, and then running a second loop to check for the max value in the array. I have to think that would be both slower and more memory intensive than what I posted. Suspect its probably the original code from the early 90s and at this point is 30 years old! Wish I had a time machine and could go back with modern computers to the early 90s!

Reply With Quote




Last Updated on May 11, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts