Announcement

Collapse
No announcement yet.

Need help on a short script from you pros.

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

  • Need help on a short script from you pros.

    Hi..

    I was wondering if someone could tell me why this script is not doing what it should...

    Basically, I am just trying to plot two things in a study.

    1. THe difference between two issues (in this case the Euro dollar spot and the Euro CME contract).

    2. a 10 period MA of the above.

    I have gone over it 50 times and don't know why it doesn't plot.

    Help!!

    vSym = "6E M4";
    vSymC = "EUR A0-FX";

    function preMain() {
    setPriceStudy(false);
    setDefaultBarFgColor(Color.teal, 0);
    setDefaultBarThickness(3, 0);
    setDefaultBarFgColor(Color.blue, 1);
    setDefaultBarThickness(2, 1);
    setDefaultBarStyle(PS_DASH,1)
    setStudyTitle("EURO FUT v. EURO CASH");
    setCursorLabelName(vSym, 0);
    setCursorLabelName(vSymC, 1);
    }

    function main() {
    var a = close(0, 1, vSymC);
    var b = close(0, 1, vSym);
    var c = a - b;
    var nLength = 10;
    var i;
    var vSum = 0.0;
    var vValue;
    vValue = close(0, -nLength, vSymC) - close(0, -nLength, vSym);
    for(i = 0; i < nLength; i++) {
    vSum += vValue[i];
    } debugPrintln(a, " : ", b, " : ", c);
    return new Array (c, Math.round(vSum/nLength));
    }

    Parker
    Parker

  • #2
    Parker
    I think the attached efs does what you want
    Alex
    Attached Files

    Comment


    • #3
      Can you plot these symbols on a normal chart? They take special entitlement...

      If so, then the next question is, have you tried to specify an interval along with the symbol?

      vSym = "6E M4,60";

      I am not entitled to the symbols you are using, but chaning them to ones I can get, and adding an interval I do get a plot.

      G
      Garth

      Comment


      • #4
        Thank you! I will go through that code to learn from it.

        Question: My idea for writing this code was to notice the offset between the two. However, given that this is currency, the offset is very small at any one time....usually increments of .00001.

        How can I get these small increments plotted?

        Thank you...
        Parker

        Comment


        • #5
          gspiker:

          wow...that works with my script perfectly....two solution inside of 5 minutes....that's what I call service!

          Alexis: is there any difference between using an interval of one as gspiker suggested, and your script??

          Thanks!
          Parker

          Comment


          • #6
            Parker

            How can I get these small increments plotted?

            One way would be to apply a weight to each symbol in the efs. In the image below the A and B variables in the efs were both multiplied by 10000.
            As an aside you can also plot the spread on a chart and apply the average to that (see image). The advantage of this method is that discrepancies in trading times are always resolved by the application.



            Note than when creating a spread with symbols that begin with a number you need to precede these with an apostrophe.

            Alexis: is there any difference between using an interval of one as gspiker suggested, and your script??

            I don't think so but you may want to confirm this with Garth

            Alex

            Comment

            Working...
            X