OmniTrader Forum OmniTrader Forum
forums calendars search
today this week
 
register logon control panel Forum Rules
You are currently browsing as a guest.
You should logon to access more features
A Self-Moderated Community - ALL MEMBERS, PLEASE READ!
Vote for Members who contribute the most to your trading, and help us moderate content within the Forums.


  Current location        Thread information  
OmniTrader 2017 Upgrade Forums
OmniScan
How to write a rule for monthly ema and price?
Last Activity 10/10/2018 1:23 PM
11 replies, 666 viewings

Jump to page : 1
Now viewing page 1 [25 messages per page]
 
back reply
Printer friendly version

^ Top
kmcintyre

Legend
100100100
Posts: 300

Joined: 8/30/2007
Location: Valley Center, CA

User Profile
 
Subject : How to write a rule for monthly ema and price?
Posted : 11/20/2016 9:20 PM
Post #38441

I'm writing a custom scan for daily charts and want to check that

monthly(c) > monthly(ema(20))

if you get my drift.

What is the proper syntax for accessing other time periods?

Thanks

Keith

^ Top
Jim Dean

Idol
2000500100100100252525
Posts: 2884

Joined: 9/21/2006
Location: L'ville, GA

User Profile
 
Subject : RE: How to write a rule for monthly ema and price?
Posted : 11/21/2016 5:17 AM
Post #38444 - In reply to #38441

The hard way. No internal function call avail. You have to:

1. Identify the bar that starts the month using barmonth()
2. Write out the ema calc manually using ema formula
3. Construct logic so ema only updates occasionally.

The "catch" is that for 1% accuracy you need 3x ema periods - so a 20 month ema needs 20 x 21b/mo x 3 = 660 daily bars to warm up the monthly ema(20)
^ Top
Mel

Veteran
10010025
Posts: 233

Joined: 12/30/2003
Location: Kensington

User Profile
 
Subject : RE: How to write a rule for monthly ema and price?
Posted : 11/21/2016 7:49 AM
Post #38445 - In reply to #38444

What you are probably looking for can be simulated by using ema(100). Even though you don't get the same numbers you would on a monthly chart, they will likely be more accurate on the HRE since the monthly bars cause a delay in the calculation unless you usin forming bar values. There is nothing on a monthly chart that is not on a daily chart - it is just summarized and delayed a bit.
^ Top
Mel

Veteran
10010025
Posts: 233

Joined: 12/30/2003
Location: Kensington

User Profile
 
Subject : RE: How to write a rule for monthly ema and price?
Posted : 11/21/2016 8:03 AM
Post #38447 - In reply to #38445

Actually, ema (100) is weekly - use ema(400). Or if you care about the excessive lag in EMAs, use an Ehlers filter like the Super Smoother Filter or the Decycler.
^ Top
Jim Dean

Idol
2000500100100100252525
Posts: 2884

Joined: 9/21/2006
Location: L'ville, GA

User Profile
 
Subject : RE: How to write a rule for monthly ema and price?
Posted : 11/21/2016 8:23 AM
Post #38448 - In reply to #38447

I agree with Mel's comments ... IF you don't care about how "accurate" the monthly-equiv EMA is compared to a "true" monthly EMA. Daily EMA(400) produces a different curve than monthly EMA(20) on a daily chart ... but both represent a "longer term viewpoint". My initial response presumed that the reason for your post was that you *wanted* a "precise" monthly EMA.
^ Top
kmcintyre

Legend
100100100
Posts: 300

Joined: 8/30/2007
Location: Valley Center, CA

User Profile
 
Subject : RE: How to write a rule for monthly ema and price?
Posted : 11/21/2016 8:58 AM
Post #38449 - In reply to #38441

Great responses!

So I'm wanting to confirm a system that uses the monthly chart to confirm daily trend. Certainly ema(400) would give me an approximation of looking at a monthly chart with a ema(20) plotted, but it would (might) render different signals.

Jim, is their a way to reference different time series in OmniLanguage? Could I write a custom indicator that returned 1 iff the monthly close was above the monthly ema(20)?

Thanks

Keith

^ Top
Jim Dean

Idol
2000500100100100252525
Posts: 2884

Joined: 9/21/2006
Location: L'ville, GA

User Profile
 
Subject : RE: How to write a rule for monthly ema and price?
Posted : 11/21/2016 9:19 AM
Post #38451 - In reply to #38449

My initial response already answered that.

There is NO easy internal OLang "call" for monthly from daily, etc.

There IS a way to manually code it in OLang but nontrivial, per what I suggested.
^ Top
kmcintyre

Legend
100100100
Posts: 300

Joined: 8/30/2007
Location: Valley Center, CA

User Profile
 
Subject : RE: How to write a rule for monthly ema and price?
Posted : 11/21/2016 9:38 AM
Post #38454 - In reply to #38441

Jim,

So if I create a custom indicator (CI) that grabs off the close of every month, which seems easy enough being as the indicator script is called for each daily bar, how could I save (return, publish, export, etc) the resultant array to access it from another custom indicator?

Can a CI return an output array of a different length?

Can a CI be called less frequently than for each daily bar?

Keith

^ Top
Jim Dean

Idol
2000500100100100252525
Posts: 2884

Joined: 9/21/2006
Location: L'ville, GA

User Profile
 
Subject : RE: How to write a rule for monthly ema and price?
Posted : 11/21/2016 9:43 AM
Post #38455 - In reply to #38454

"How could I save (return, publish, export, etc) the resultant array to access it from another custom indicator?"
Answer ... use the Return statement with the array as its argument ... presumably the daily values of the monthly ema would either remain constant for intermediate bars or would be zero unless its the EOM bar.

"Can a CI return an output array of a different length?"
Answer ... no - OLang/Script arrays dim's are dictated by #bars loaded in current timeframe. Period.

"Can a CI be called less frequently than for each daily bar?"
Answer ... of course ... the "call" of the CI by another CI or Sys or Exit or Script can be controlled by an IF/THEN (or IIF() for Script)

[Edited by Jim Dean on 11/21/2016 9:44 AM]

^ Top
Jim Dean

Idol
2000500100100100252525
Posts: 2884

Joined: 9/21/2006
Location: L'ville, GA

User Profile
 
Subject : RE: How to write a rule for monthly ema and price?
Posted : 11/21/2016 9:46 AM
Post #38456 - In reply to #38455

Exporting values to a text file requires "unsupported" and sometimes tricky OLang ... use VBA writeline stmts etc ... but file control must be manual. I've used that extensively, but it took a lot of cut and try to get it to work. Reading and parsing a file is 10x worse than writing, btw.
^ Top
kmcintyre

Legend
100100100
Posts: 300

Joined: 8/30/2007
Location: Valley Center, CA

User Profile
 
Subject : RE: How to write a rule for monthly ema and price?
Posted : 11/21/2016 10:39 AM
Post #38457 - In reply to #38441

Jim,

Thanks for the answers. What a shame. I think I'd rather be programming in assembly language.

Keith

^ Top
Stumpy

Veteran
100100
Posts: 210

Joined: 5/25/2004
Location: Australia

User Profile
 
Subject : RE: How to write a rule for monthly ema and price?
Posted : 11/27/2016 9:46 PM
Post #38468 - In reply to #38441

Is it possible to put a filter in the trade plan to only have stocks above certain ema if so how please????
Jump to page : 1
Now viewing page 1 [25 messages per page]
back reply

Legend    Action      Notification  
Administrator
Forum Moderator
Registered User
Unregistered User
E-Mail this thread to a friend
Toggle e-mail notification


Nirvana Systems
For any problems or issues please contact our Webmaster at webmaster@nirvsys.com.