Announcement

Collapse
No announcement yet.

parabolic

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

  • parabolic

    I wrote an *.EFS for parabolic, so that I can get sell/buy signals, if the parabolic crosses.

    But the parabolic is not shown in my chart, and also the *efs donĀ“t work.

    I will get my first signal, when the parabilc crosses the first time, and the additional signals, if crosses.

    can anybody help me?


    var study = new ParabolicStudy(0.06, 0.06, 0.2);

    var thisTrade = 0; //-1 SHORT, 1 LONG,
    var onTrade = 0; //0 NO, 1 YES

    var nNewTrade; //New Trade Trigger 0 = OFF , 1 = ON
    var nsignal; //returns the direction of the trading signal


    function preMain() {
    setPriceStudy(true);
    setPlotType(PLOTTYPE_LINE)
    setDefaultBarThickness(1);
    }

    function main() {

    var value = study.getValue(ParabolicStudy.STOP);

    /*if(value == null)
    return;*/

    if(value >= open()) { //Buy Condition
    nNewTrade = 1; //New Trade Triger
    nsignal = +1; //Buy Signal
    }

    if(value <= close()) { //Sell Condition
    nNewTrade = 1; //New Trade Triger
    nSignal = -1; //Sell Signal
    }


    // execute trades only if nNewTrade is triggered

    if (nNewTrade == 1) { //Execute new Trade, new or reversed trade position
    if (Strategy.isInTrade() == true) {
    if ((nsignal > 0) && (Strategy.isShort() == true)) {
    Strategy.doCOVER("EXIT", Strategy.CLOSE, Strategy.THISBAR);
    Strategy.doLONG("ReversLONG", Strategy.CLOSE, Strategy.THISBAR);
    drawTextRelative(0, low(), "B", Color.black, Color.lime, Text.FRAME | Text.ONTOP | Text.BOLD, null, 9);
    }

    if ((nsignal < 0) && (Strategy.isLong() == true)) {
    Strategy.doSELL("EXIT" , Strategy.CLOSE, Strategy.THISBAR);
    Strategy.doSHORT("ReversSHORT", Strategy.CLOSE,Strategy.THISBAR);
    drawTextRelative(0, high(), "S", Color.black, Color.red, Text.FRAME | Text.ONTOP | Text.BOLD, null, 9);
    }

    } else { // not in trade now
    if ((nsignal > 0)) {
    Strategy.doLONG("GoLONG", Strategy.CLOSE, Strategy.THISBAR);
    }

    if ((nsignal < 0)) {
    Strategy.doSHORT("GoSHORT", Strategy.CLOSE, Strategy.THISBAR);
    }
    } // end if IN TRADE

    nNewTrade = 0; // Turn off NEW TRADE switch
    } // End execute Trade



    return value;
    }


    best wishes, Torso
    Last edited by Torso; 05-24-2003, 10:32 AM.

  • #2
    Here's the issues I see...

    1) There is no study object being setup, thus there is no study data. You will need a line like var study = new ParabolicStudy(0.02, 0.02, 0.2); outside of main.

    2) Strategy. functions are not in capital letters. For a reference of all backtesting functions please visit the EFs Help Center and select "EFS Function Reference" and "Back Testing/Strategy".

    Attached is an EFS that is similar to yours, that should give you a good start.
    Attached Files
    Regards,
    Jay F.
    Product Manager
    _____________________________________
    Have a suggestion to improve our products?
    Click Support --> Request a Feature in eSignal 11

    Comment


    • #3
      It looks as if I missed the first line of code containing the parabolic study object declaration... It is likely #2 was the cause of the formula not functioning correctly.
      Regards,
      Jay F.
      Product Manager
      _____________________________________
      Have a suggestion to improve our products?
      Click Support --> Request a Feature in eSignal 11

      Comment


      • #4
        Hello Torso,

        Jay already mentioned the case sensitivity issue with your Strategy commands. There was also the variable, nsignal, which was referred to as nSignal in a couple of places. JavaScript sees those as different variables. Another thing to point out is the usages of the braces, { and }. If you only need one line of code to execute after an If() statement becomes true, you don't need the braces. However, if you need more than one line of code to execute after an If() statement or you have a set of nested If() statements, you'll need to use the braces. I made the necessary corrections to your formula for you. I'm not sure it performs as you intended, but it should be enough to get you going.

        ParabolicCross.efs
        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