spacer esignallogo
 |  Contact Us   


User CPRegisterMember Listcalendar




eSignal Forums eSignal Forums » EFS / API Development » EFS Library - Discussion Board » Stocks & Commodities Magazine » 2009 Mar: MACD Reversed Crossover Strategy, by Donald W. Pendergast Jr.
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply

2009 Mar: MACD Reversed Crossover Strategy, by Donald W. Pendergast Jr. - Posted: 02-23-2009 08:11 AM Old PostReport | IP: Logged

eSignal

Registered: Aug 2003
Location:
Posts: 221
Status: OFFLINE


Reply with QuoteEdit/Delete Message

File Name: MACD_RevCrossover.efs

Description:
MACD Reversed Crossover Strategy, by Donald W. Pendergast Jr.

Formula Parameters:
Fast Length : 12
Slow Length : 26
Smoothing : 9



Notes:
The related article is copyrighted material. If you are not
a subscriber of Stocks & Commodities, please visit www.traders.com.


Download File:
MACD_RevCrossover.efs



EFS Code:
PHP:


/*********************************
Provided By:  
    eSignal (Copyright c eSignal), a division of Interactive Data 
    Corporation. 2009. All rights reserved. This sample eSignal 
    Formula Script (EFS) is for educational purposes only and may be 
    modified and saved under a new file name.  eSignal is not responsible
    for the functionality once modified.  eSignal reserves the right 
    to modify and overwrite this EFS file with each new release.

Description:        
    MACD Reversed Crossover Strategy, by Donald W. Pendergast Jr.

Version:            1.0  01/08/2009

Formula Parameters:                     Default:
    Fast Length                         12
    Slow Length                         26
    Smoothing                           9

Notes: 
    The related article is copyrighted material. If you are not
    a subscriber of Stocks & Commodities, please visit <a href="http://www.traders.com." target="_blank">www.traders.com.</a>

**********************************/

var fpArray = new Array();
var 
bInit false;
var 
bVersion null;

function 
preMain() {
    
setPriceStudy(false);
    
setShowTitleParametersfalse );
    
setStudyTitle("MACD Reversed Crossover Strategy");
    
setColorPriceBars(true);
    
setDefaultPriceBarColor(Color.black);
    
setCursorLabelName("MACD"0);
    
setCursorLabelName("Signal"1);
    
setDefaultBarFgColor(Color.green0);
    
setDefaultBarFgColor(Color.red1);
    
setDefaultBarThickness(20);
    
setDefaultBarThickness(21);
    

    var 
x=0;
    
fpArray[x] = new FunctionParameter("FastLength"FunctionParameter.NUMBER);
    
with(fpArray[x++]){
        
setName("Fast Length");
        
setLowerLimit(1);        
        
setDefault(12);
    }
    
fpArray[x] = new FunctionParameter("SlowLength"FunctionParameter.NUMBER);
    
with(fpArray[x++]){
        
setName("Slow Length");
        
setLowerLimit(1);        
        
setDefault(26);
    }
    
fpArray[x] = new FunctionParameter("Smoothing"FunctionParameter.NUMBER);
    
with(fpArray[x++]){
        
setName("Smoothing");
        
setLowerLimit(0);        
        
setDefault(9);
    }
}

var 
xMACD null;
var 
xSignal null;

function 
main(FastLengthSlowLength Smoothing) {

    if (
bVersion == nullbVersion verify();
    if (
bVersion == false) return;   

    if (
getCurrentBarIndex() == 0) return;

    if ( 
bInit == false ) { 
        
xMACD macd(FastLengthSlowLengthSmoothing);
        
xSignal macdSignal(FastLengthSlowLengthSmoothing);
        
bInit true
    } 

    if (
xSignal.getValue(-1) == null) return;
    
    if(
xSignal.getValue(-2) >= xMACD.getValue(-2) && 
       
xSignal.getValue(-1) < xMACD.getValue(-1) && !Strategy.isLong()) {
        
Strategy.doLong("Long"Strategy.MARKETStrategy.THISBAR);
    }    

    if(
xSignal.getValue(-1) > xMACD.getValue(-1) && Strategy.isLong()) {
        
Strategy.doSell("Exit Long"Strategy.MARKETStrategy.THISBAR);
    }    

    if(
Strategy.isLong())
        
setPriceBarColor(Color.lime);
    else 
setPriceBarColor(Color.black);
    
    return new Array(
xMACD.getValue(0), xSignal.getValue(0));
}

function 
verify() {
    var 
false;
    if (
getBuildNumber() < 779) {
        
drawTextAbsolute(535"This study requires version 8.0 or later."
            
Color.whiteColor.blueText.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            
null13"error");
        
drawTextAbsolute(520"Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp"
            
Color.whiteColor.blueText.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
            
null13"upgrade");
        return 
b;
    } else {
        
true;
    }
    return 
b;
}

View eSignal's profile Visit eSignal's website Search for posts by eSignal Add eSignal to your buddy list


All times are GMT. The time now is 12:21 AM. Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread

Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF