Announcement

Collapse
No announcement yet.

upperDonchian

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • upperDonchian

    I apply the following script to a chart of type $tick,1

    PHP Code:
    function preMain() {
        
    setStudyTitle("MikeTest");
    }

    var 
    upD null;
    var 
    lowD null;
    var 
    count 0;

    function 
    main() 
    {
    var 
    tempref ref(-1);
        if (
    count == 0)
        {
            
    count++;
            
    upD upperDonchian(3"high"sym("ES #F, 1"));
            
    lowD lowerDonchian(3"low"sym("ES #F, 1"));
        }

        if (
    getBarState() == BARSTATE_NEWBAR)
        {
            
    debugPrintln("upd: " upD.getValue(0) + " lowD: " lowD.getValue(0));
        }

    I am returned with the 3 period channel for $tick, not es #f. Any help is appreciated, this is a neat feature.

  • #2
    Hello cashcarewins,

    You were not using proper parameters for the built-in Donchian functions. The source parameter needs to be a data series function such as high() vs. a string of "high". This is one of the main differences between the built-in studies from EFS1 vs. EFS2. You were also passing the sym() function for the bar index parameter. The second parameter can be another data source, sym(), inv(), or a combination of these three things as a single parameter. The third bar index parameter is expected to be a number. So to get the high of ES #F for the data source you would pass sym("ES #F, 1") to the high() data series (i.e high(sym("ES #F, 1")) ). The way your code was set up was forcing the function to use default values because it didn't recognize your optional parameters. This is why it was returning values for $Tick. Try the modified code below.

    PHP Code:
    function preMain() {
        
    setStudyTitle("MikeTest");
    }

    var 
    upD null;
    var 
    lowD null;
    var 
    count 0;

    function 
    main() {
        var 
    tempref ref(-1);

        if (
    upD == nullupD upperDonchian(3high(sym("ES #F, 1")));
        if (
    lowD == nulllowD lowerDonchian(3low(sym("ES #F, 1")));
        
        if (
    count == 0) {
            
    count++;
        }

        if (
    getBarState() == BARSTATE_NEWBAR) {
            
    debugPrintln("upd: " upD.getValue(0) + " lowD: " lowD.getValue(0));
        }
        
        return new Array(
    getSeries(upD), getSeries(lowD));

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment

    Working...
    X