Home
Discussions
Files
Register
Login
Welcome Guest! To enable all features please
Login
or
Register
.
Forum
Active Topics
Search
Help
Login
Register
Search
Notification
Error
OK
Discussions
»
Special Interest Groups
»
Advanced Coding Techniques
»
Breakout-sensitive EMA (BEMA)
Breakout-sensitive EMA (BEMA) -
Breakout-sensitive EMA (BEMA)
Options
Email this topic
Watch this topic
Print this topic
» Normal
Threaded
Previous Topic
Next Topic
Jose
#1
Posted :
Sunday, November 13, 2005 11:44:08 PM(UTC)
Rank: Advanced Member
Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
Below is a Breakout-sensitive Exponential Moving Average indicator (BEMA for short). It reacts quicker (tightens) on price breakouts, and loosens back to normal progressively thereafter. Perhaps it should do the opposite, i.e. loosen on breakouts and tighten progressively thereafter instead. Anyway, maybe there is some usefulness in this variable-period EMA. MetaStock -> Tools -> Indicator Builder -> New -> Copy and paste complete formulae between "---8<---" lines. [code:1:ecb062053d] ============================== EMA - Breakout-sensitive (BEMA) ============================== ---8<------------------------------------- { [B]reakout-sensitive [E]xp [M]ov [A]vg v1.0 } { BEMA based on bars since price breakouts. Options: [1] Composite BEMA: (Upper+Lower)/2; [2] Upper BEMA band based on upside breaks; Lower BEMA band based on downside breaks; [3] BEMA shifts to Upper/Lower on crossovers} { ©Copyright 2005 Jose Silva. The grant of this license is for personal use only - no resale or repackaging allowed. All code remains the property of Jose Silva. http://www.metastocktools.com } { User inputs } pds:=Input("BEMA and HHV/LLV lookback periods", 1,2520,21); plot:=Input("BEMA: [1]Composite, [2]Upper+Lower, [3]Long/Short",1,4,1); spread:=Input("Upper/Lower BEMA bands shift %", 0,100,2)/200; x:=Input("Breakouts, use: [1]Close, [2]High/Low",1,2,1); { Upside breakouts } xup:=If(x=1,C,H); up:=xup=HHV(xup,pds); { Downside breakouts } xdw:=If(x=1,C,L); dw:=xdw=LLV(xdw,pds); { Remove ghost breakout signals } init:=Cum(IsDefined(up+dw))=1; bin:=ValueWhen(1,up-dw<>0 OR init,up); up:=bin AND (Alert(bin=0,2) OR init); dw:=bin=0 AND (Alert(bin,2) OR init); NullZone:=Cum(up)>0 AND Cum(dw)<1 OR Cum(up)<1 AND Cum(dw)>0; { Periods since breakouts } upPds:=BarsSince(up OR Cum(1)=pds)+2; upPds:=If(upPds>pds,pds,upPds); dwPds:=BarsSince(dw OR Cum(1)=pds)+2; dwPds:=If(dwPds>pds,pds,dwPds); { Upside breakout-based EMA } upEma:=xup*2/(upPds+1)+PREV*(1-2/(upPds+1)); upEma:=If(NullZone,Mov(xup,pds,E),upEma); upEma:=upEma*(1+spread); { Downside breakout-based EMA } dwEma:=xdw*2/(dwPds+1)+PREV*(1-2/(dwPds+1)); dwEma:=If(NullZone,Mov(xdw,pds,E),dwEma); dwEma:=dwEma*(1-spread); { Composite BEMA } BEMA:=(upEma+dwEma)/2; LngSht:=If(C>=BEMA,dwEma,upEma); { Plot on price chart } If(plot=1,BEMA,If(plot=2,dwEma, If(plot=3,LngSht,up))); If(plot=1,BEMA,If(plot=2,upEma, If(plot=3,LngSht,-dw))) ---8<------------------------------------- [/code:1:ecb062053d] jose '-)
User Profile
View All Posts by User
View Thanks
Wanna join the discussion?!
Login to your Discussions forum account
or Register a new forum account
.
Jose
#2
Posted :
Sunday, November 13, 2005 11:46:54 PM(UTC)
Rank: Advanced Member
Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
[code:1:f5c7103ea5] ========================= EMA - (BEMA), dll version ========================= ---8<------------------------------------- { [B]reakout-sensitive [E]xp [M]ov [A]vg v.dll - Plots much faster than PREV-based version.} { BEMA based on bars since price breakouts. Options: [1] Composite BEMA: (Upper+Lower)/2; [2] Upper BEMA band based on upside breaks; Lower BEMA band based on downside breaks; [3] BEMA shifts to Upper/Lower on crossovers} { Forum.dll from http://forum.equis.com or ASI.dll from http://www.thedml.com must be in: ...\\MetaStock\\External Function DLLs\\ folder.} { ©Copyright 2005 Jose Silva. The grant of this license is for personal use only - no resale or repackaging allowed. All code remains the property of Jose Silva. http://www.metastocktools.com } { User inputs } pds:=Input("BEMA and HHV/LLV lookback periods", 1,2520,21); plot:=Input("BEMA: [1]Composite, [2]Upper+Lower, [3]Long/Short",1,4,1); spread:=Input("Upper/Lower BEMA bands shift %", 0,100,2)/200; x:=Input("Breakouts, use: [1]Close, [2]High/Low",1,2,1); { Upside breakouts } xup:=If(x=1,C,H); up:=xup=HHV(xup,pds); { Downside breakouts } xdw:=If(x=1,C,L); dw:=xdw=LLV(xdw,pds); { Remove ghost breakout signals } init:=Cum(IsDefined(up+dw))=1; bin:=ValueWhen(1,up-dw<>0 OR init,up); up:=bin AND (Alert(bin=0,2) OR init); dw:=bin=0 AND (Alert(bin,2) OR init); NullZone:=Cum(up)>0 AND Cum(dw)<1 OR Cum(up)<1 AND Cum(dw)>0; { Periods since breakouts } upPds:=BarsSince(up OR Cum(1)=pds)+2; upPds:=If(upPds>pds,pds,upPds); dwPds:=BarsSince(dw OR Cum(1)=pds)+2; dwPds:=If(dwPds>pds,pds,dwPds); { Upside breakout-based EMA } {upEma:=ExtFml("Forum.VarMOV",xup,upPds,e);} upEma:=ExtFml("ASI.EMA",xup,upPds); upEma:=If(NullZone,Mov(xup,pds,E),upEma); upEma:=upEma*(1+spread); { Downside breakout-based EMA } {dwEma:=ExtFml("Forum.VarMOV",xdw,dwPds,e);} dwEma:=ExtFml("ASI.EMA",xdw,dwPds); dwEma:=If(NullZone,Mov(xdw,pds,E),dwEma); dwEma:=dwEma*(1-spread); { Composite BEMA } BEMA:=(upEma+dwEma)/2; LngSht:=If(C>=BEMA,dwEma,upEma); { Plot on price chart } If(plot=1,BEMA,If(plot=2,dwEma, If(plot=3,LngSht,up))); If(plot=1,BEMA,If(plot=2,upEma, If(plot=3,LngSht,-dw))) ---8<------------------------------------- [/code:1:f5c7103ea5] jose '-)
User Profile
View All Posts by User
View Thanks
Users browsing this topic
Guest
(Hidden)
Discussions
»
Special Interest Groups
»
Advanced Coding Techniques
»
Breakout-sensitive EMA (BEMA)
Forum Jump
Discussions
Innovative Market Analysis
- Forum Feedback
- Online Help
--- MetaStock FAQ
--- MetaStock.com Website FAQ
- Welcome!
Product and Service Development
- Product Alerts
- Data Related Questions
- Error Messages
- Exchange Changes
- Formula Assistance
- LCI Toolkit
- MetaStock
- MetaStock Product Updates
- Product Wish List
- Testimonials
Special Interest Groups
- MetaStock Developer's Kit (MDK) Assistance
- Basic Coding Techniques
- Plugins & Addons
- Tips & Tricks
- Advanced Coding Techniques
Resource Library
- MetaStock Monitor Articles
- MetaStock U
--- Candlestick Forum
--- Tech Talk
--- Technical Guides to Energy Trading
--- TechniTrader
--- The Inside Technician
--- The Naked Trader
--- Traders State of Mind
- Press Releases
- Product Awards
--- MetaStock Data
--- MetaStock Products
--- Third Party Add-Ons
- Technical Analysis from A to Z
--- PART ONE
--- PART TWO
- Trader's Tips from TASC Magazine
--- 1999
--- 2000
--- 2001
--- 2002
--- 2003
--- 2004
--- 2005
--- 2006
--- 2007
--- 2008
--- 2009
--- 2010
--- 2011
--- 2012
--- 2013
--- 2014
--- 2015
--- 2016
--- 2017
--- 2018
--- 2019
--- 2020
--- 2021
--- 2022
--- 2023
--- 2024
- User Groups
- Video Instruction and Webinar Sessions
--- MetaStock Online User Group Archives
--- MetaStock Webinar Series
- VIP Interviews
Community Forums
- 3rd Party Advertisements
- General Chat
- MetaStock Advertisements
- Technical Chat
Administrative Forums
- MetaStock Partners
- Web Content
--- Archive
--- Beta Web Content
--- Bios
--- Events
----- MetaStock Conferences
----- Online Traders Summit
--- kb
----- Frequently Asked Questions
------- Legacy MetaStock FAQs
--------- Custom Formulas
--------- MetaStock Add-Ons
--------- MetaStock Data Feeds
----------- DataLink
----------- XENITH
--------- MetaStock Products.
----------- MetaStock RT and DC
--- MetaStock Spotlight
--- MS User Groups
----- USA
----- Caribbean
----- Australia
----- New Zealand
----- Online
--- Products
----- FAQs
--- mktg
----- summit
------- archive
------- sessions
----- home
----- Singapore
------- sessions
----- HongKong
------- sessions
----- KualaLumpur
------- sessions
----- Jakarta
------- sessions
----- Bangkok
------- sessions
----- seminar
------- sessions
----- Zurich
------- sessions
----- Amsterdam
------- sessions
--- support
----- downloads
------- mseod
------- msrt
Files
- MetaStock
--- MetaStock Files
--- Next big thing
- Programming
--- Programming Files
You
cannot
post new topics in this forum.
You
cannot
reply to topics in this forum.
You
cannot
delete your posts in this forum.
You
cannot
edit your posts in this forum.
You
cannot
create polls in this forum.
You
cannot
vote in polls in this forum.
Powered by YAF.NET
|
YAF.NET © 2003-2024, Yet Another Forum.NET