Announcement

Collapse
No announcement yet.

Multi timeframe Moving Averages.

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

  • Multi timeframe Moving Averages.

    I’m unsure if it’s at all possible so asking those who know more about programming efs files then I do… is it possible to have on one chart the direction of a simple moving average of multiple timeframes? I don’t actually want the moving average up on my charts but rather as a bar on the bottom, blue for pointing up and red for pointing down. I want to be able to pick my own timeframes. For example if I trade the ES e-minis I may want to use 1,3,5 and 15 timeframes. But if I were to trade forex I would probably use 5,15, 30 and 60 minute timeframes. That’s why I would like the efs file to allow me to change the timeframes wanted depending on the market I want to trade. I know that I can easily do this using multiple charts but it makes it a lot easier for back testing if it were up on same chart. So for example, if I want to go long only if the 10MA is rising on all four timeframes it’s easier to back test it on one chart. I’ve included a picture of what I mean.

    Is it possible?
    Attached Files

  • #2
    lazzie,

    Sounds like an excellent idea and useful EFS to have available. Would "try" and code it myself it for you but somewhat overwhelmed with work myself.

    I thought I saw a multiple time interval moving average in JasonK fileshare. The EFS as I recall does plot the various ma's on the chart.

    Essentially the EFS already contains the functionality you are looking for with a different graphical representation and although not exactly to spec may be a good starting point for what you are looking to accomplish.

    You may want to take a look and give it a try, it may be easier then you realize.

    If you encounter problems or have specific question, by posting the code with the problem/question you will have an excellent chance of finding competent assistance.

    Hope it helps, do a search on fileshare for information if you are unfamiliar. If you have any difficulty accessing the fileshare let me know.

    Glen

    ps. The EFS name couldn't be more more descriptively named
    : MultipleIntervalMa.efs.....
    Last edited by demarcog; 10-22-2007, 01:10 PM.
    Glen Demarco
    [email protected]

    Comment


    • #3
      Hi Glen,

      Like you, I also trade the e-minis, mainly the S&P but also the NQ and the YM. So unfortunately the 200 period MA isn’t much good for me. If I were able to change the parameters to a 10 period simple moving average and change the timeframe to 1,3,5 and 15 minutes then that would be perfect. I now use multiple charts and would have liked if possible to have up only my one minute chart but always know the direction the 10ma was pointing on the 3, 5 and 15 minute charts. Using the 1 minute chart as my entry and having the 10ma on all timeframes as my guide I find quite successful for scalping a couple of points here and there. I also use the Hull MA for an earlier entry, but again only take when it turns in the direction of the main trend.

      Thanks for your help,
      Lazzie.

      Comment


      • #4
        Originally posted by lazzie
        Hi Glen,

        Like you, I also trade the e-minis, mainly the S&P but also the NQ and the YM. So unfortunately the 200 period MA isn’t much good for me. If I were able to change the parameters to a 10 period simple moving average and change the timeframe to 1,3,5 and 15 minutes then that would be perfect. I now use multiple charts and would have liked if possible to have up only my one minute chart but always know the direction the 10ma was pointing on the 3, 5 and 15 minute charts. Using the 1 minute chart as my entry and having the 10ma on all timeframes as my guide I find quite successful for scalping a couple of points here and there. I also use the Hull MA for an earlier entry, but again only take when it turns in the direction of the main trend.

        Thanks for your help,
        Lazzie.
        Lazzie,

        That's not a big deal to change, I'm in the middle of a few trades right now and I have a bug in a EFS that is closing out my positions prematurly and I haven't a clue why.

        I did look at it quickly, if you want to give it a shot try changing lines 110 112 115 117 120 122 125 and 127 from the 10 20 60 and 120 minute intervals to whatever intervals you want and see if it works and post the code. Go to go.

        Glen
        Glen Demarco
        [email protected]

        Comment


        • #5
          Glen,

          I've done a search on JasonK fileshare and search in forums.

          Can't find this
          Hope it helps, do a search on fileshare for information if you are unfamiliar. If you have any difficulty accessing the fileshare let me know.

          Glen

          ps. The EFS name couldn't be more more descriptively named
          : MultipleIntervalMa.efs.....
          Do you have a copy you could attach?

          TIA
          Kirk

          Comment


          • #6
            Hi Lazzie,

            Sorry for the delay got sidetracked.

            It was in Jasonk Fileshare, you need to actually do a seperate login via the File Sharing option in the upper left of this screen?

            Anyway here's what it looks like. Now you want a 10 period SMA on the intervals you mentioned for a single symbol?

            I need to get ready to start trading now. I made some changes but getting a syntax error and not sure if I caused it (probably) so you may want to download the origional and see if you can load it into a chart?

            BTW, I'm not a real developer so may not be the best person to guide you thorough this but I'll give it a shot. Programming is the most detailed and precise activity imaginable, requiring alot of prepatory design work before programming. We can try a quick and dirty modification but no guarantees.


            You may want to familiarize yourself with the extensive amount of excellent material: videos, documents, knowledge base etc.

            If you want to give it a shot, first make sure the EFS work. I highly doubt Jason would have a syntax in his file share but sometimes new versions bring incompatabilities. Actually the error on line 68 is in the getAbsoluteValue function which I've never used. You may want to search on it.

            You would need to change all the numeric only occurances you see of the number 200 or -200 to 10 or -10. Don't change any variable names that contain 200 yet.

            Then you need to replace the intervals you see on the lines I mentioned in an earlier post with your values 1,3 ,5,15. He is using 5 different time periods so it may be easier to just use 1,3,5,15,60 rather then chopping sections of code right now.

            Then try to load it.

            BTW, is this something you use for trading the indices. I played around with it and it certainly has a high percentage of successful trades when they are all lined up, but there were alot of time periods when they would not be.

            Have you considered using 1 or 2 ma's across different symbols, ie, S&P, NQ, YM, etc. Because I trades the indices for a few years exclusively, (not successful enough) but that occurs much more often and when those ducks are all lined up that was a significant predictor as I recall.

            Glen


            PHP Code:

            /*****************************************************************
            Provided By : eSignal. (c) Copyright 2003
            ******************************************************************

            This formula demonstrates how to have multiple simple moving averages of different 
            intervals (2hour, 1hour, 20min, 10min and 5min) drawn on a 5 minute chart.

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


            function preMain() {
                
            setPriceStudy(true);
                
            setStudyTitle("Multiple Interval Moving Averages ");

                
            setDefaultBarFgColor(Color.blue0);
                
            setDefaultBarFgColor(Color.navy1);
                
            setDefaultBarFgColor(Color.purple2);
                
            setDefaultBarFgColor(Color.green3);
                
            setDefaultBarFgColor(Color.red4);

                
            setCursorLabelName("5min MA"0);
                
            setCursorLabelName("10min MA"1);
                
            setCursorLabelName("20min MA"2);
                
            setCursorLabelName("60min MA"3);
                
            setCursorLabelName("120min MA"4);
            }

            var 
            vPrimed false;
            var 
            study = new MAStudy(2000"Close"MAStudy.SIMPLE);
            var 
            a10 = new Array(200);
            var 
            a20 = new Array(200);
            var 
            a60 = new Array(200);
            var 
            a120 = new Array(200);
            var 
            v10index 0;
            var 
            v10index1 0;
            var 
            v20index 0;
            var 
            v20index1 0;
            var 
            v60index 0;
            var 
            v60index1 0;
            var 
            v120index 0;
            var 
            v120index1 0;
            var 
            vPrice10 null;
            var 
            vPrice20 null;
            var 
            vPrice60 null;
            var 
            vPrice120 null;

            function 
            main() {
                var 
            vI getInterval();
                if (
            vI != 5) return;
                
                var 
            nState getBarState();
                var 
            vIndex getCurrentBarIndex();
                var 
            vTime getValue("time");
                var 
            vSym getSymbol();

                var 
            vPrices null;
                var 
            dSum 0;
                var 
            ratio 1;

                var 
            v5index getFirstBarIndexOfDay(vTimevSym+",5");
                
                var 
            v5 study.getValue(MAStudy.MA);
                if (
            v5 == null) return;
                
                if (
            vPrimed == false) { // priming arrays
                    
            v10index getFirstBarIndexOfDay(vTimevSym+",10");
                    
            v10index Math.round(vIndex/(Math.round(v5index/v10index)));    
                    
            a10 getValueAbsolute("Close"v10index, -200vSym+",10");
                    if (
            a10 == null) return;
                
                    
            v20index getFirstBarIndexOfDay(vTimevSym+",20");
                    
            v20index Math.round(vIndex/(Math.round(v5index/v20index)));    
                    
            a20 getValueAbsolute("Close"v20index, -200vSym+",20");
                    if (
            a20 == null) return;
                
                    
            v60index getFirstBarIndexOfDay(vTimevSym+",60");
                    
            v60index Math.round(vIndex/(Math.round(v5index/v60index)));    
                    
            a60 getValueAbsolute("Close"v60index, -200vSym+",60");
                    if (
            a60 == null) return;

                    
            v120index getFirstBarIndexOfDay(vTimevSym+",120");
                    
            v120index Math.round(vIndex/(Math.round(v5index/v120index)));    
                    
            a120 getValueAbsolute("Close"v120index, -200vSym+",120");
                    if (
            a120 == null) return;
             
                    var 
            dSum10 0;
                    var 
            dSum20 0;
                    var 
            dSum60 0;
                    var 
            dSum120 0;
                    for (
            0200; ++i) {
                        
            dSum10 += a10[i];
                        
            dSum20 += a20[i];
                        
            dSum60 += a60[i];
                        
            dSum120 += a120[i];
                    }
                    var 
            v10 dSum10/200;
                    var 
            v20 dSum20/200;
                    var 
            v60 dSum60/200;
                    var 
            v120 dSum120/200;
                    
                    
            vPrimed true;
                } else {  
            // real time
                    
            if (nState == BARSTATE_NEWBAR) {
                        
            v10index1 v10index;
                        
            v20index1 v20index;
                        
            v60index1 v60index;
                        
            v120index1 v120index;
                    }
                
                    
            v10index getFirstBarIndexOfDay(vTimevSym+",10");
                    
            v10index Math.round(vIndex/(Math.round(v5index/v10index)));    
                    
            vPrice10 getValueAbsolute("Close"v10indexvSym+",10");
                    if (
            vPrice10 == null) return;

                    
            v20index getFirstBarIndexOfDay(vTimevSym+",20");
                    
            v20index Math.round(vIndex/(Math.round(v5index/v20index)));    
                    
            vPrice20 getValueAbsolute("Close"v20indexvSym+",20");
                    if (
            vPrice20 == null) return;

                    
            v60index getFirstBarIndexOfDay(vTimevSym+",60");
                    
            v60index Math.round(vIndex/(Math.round(v5index/v60index)));    
                    
            vPrice60 getValueAbsolute("Close"v60indexvSym+",60");
                    if (
            vPrice60 == null) return;

                    
            v120index getFirstBarIndexOfDay(vTimevSym+",120");
                    
            v120index Math.round(vIndex/(Math.round(v5index/v120index)));    
                    
            vPrice120 getValueAbsolute("Close"v120indexvSym+",120");
                    if (
            vPrice120 == null) return;

                    if (
            nState == BARSTATE_NEWBAR) {
                        if (
            v10index != v10index1) {
                            
            a10.pop();
                            
            a10.unshift(vPrice10);
                        } else {
                            
            a10[0] = vPrice10;
                        }

                        if (
            v20index != v20index1) {
                            
            a20.pop();
                            
            a20.unshift(vPrice20);
                        } else {
                            
            a20[0] = vPrice20;
                        }

                        if (
            v60index != v60index1) {
                            
            a60.pop();
                            
            a60.unshift(vPrice60);
                        } else {
                            
            a60[0] = vPrice60;
                        }

                        if (
            v120index != v120index1) {
                            
            a120.pop();
                            
            a120.unshift(vPrice120);
                        } else {
                            
            a120[0] = vPrice120;
                        }
                    } else {
                        
            a10[0] = vPrice10;
                        
            a20[0] = vPrice20;
                        
            a60[0] = vPrice60;
                        
            a120[0] = vPrice120;
                    }

                    var 
            dSum10 0;
                    var 
            dSum20 0;
                    var 
            dSum60 0;
                    var 
            dSum120 0;
                    for (
            0200; ++i) {
                        
            dSum10 += a10[i];
                        
            dSum20 += a20[i];
                        
            dSum60 += a60[i];
                        
            dSum120 += a120[i];
                    }
                    var 
            v10 dSum10/200;
                    var 
            v20 dSum20/200;
                    var 
            v60 dSum60/200;
                    var 
            v120 dSum120/200;
                }
             
                
            drawTextRelative(1v5"   5 Min MA "Color.whiteColor.blue
                    
            Text.FRAME|Text.BOLD|Text.VCENTERnull10"5");
                
            drawTextRelative(1v10"  10 Min MA "Color.whiteColor.navy
                    
            Text.FRAME|Text.BOLD|Text.VCENTERnull10"10");
                
            drawTextRelative(1v20"  20 Min MA "Color.whiteColor.purple
                    
            Text.FRAME|Text.BOLD|Text.VCENTERnull10"20");
                
            drawTextRelative(1v60"  60 Min MA "Color.whiteColor.green
                    
            Text.FRAME|Text.BOLD|Text.VCENTERnull10"60");
                
            drawTextRelative(1v120" 120 Min MA "Color.whiteColor.red
                    
            Text.FRAME|Text.BOLD|Text.VCENTERnull10"120");

                return new Array(
            v5v10v20v60v120);

            Last edited by demarcog; 10-23-2007, 10:39 PM.
            Glen Demarco
            [email protected]

            Comment


            • #7
              Hi Glen.

              Thanks for the advice on what to do. Unfortunately programming is a bit beyond me but I have a friend who’s much more computer literate than I am so I will try get around to his place soon and see if we can work it out.


              Yes, I want all three markets (S&P, NQ and the YM) to be moving in the same direction for me to take a trade, and most of the time they are. I also want at least the 10ma on the 1,3, and 5 minute charts to be pointing the same way too. Preferably the 15 minute chart also. If however the 10ma on the 15 minute chart is falling rather then rising I would still take a long trade if the 10 period Hull MA on the 15 minute chart has started turning up. When the 10 period Hull starts turning you can normally scalp a couple of points on the S&P even if it’s only a pullback on the 15 minute chart and not a change of trend.

              I only trade the morning session and most days you can get at least two or three entry points and that’s more then enough for me. I just find that it’s much more successful when all four time charts are lined up.

              Again thanks for your advice.

              Lazzie.

              Comment


              • #8
                Originally posted by zeller4
                Glen,

                I've done a search on JasonK fileshare and search in forums.

                Can't find this


                Do you have a copy you could attach?

                TIA
                Kirk
                Kirk, here is that efs that Glen was talking about.
                Attached Files

                Comment


                • #9
                  Thanks Lazzie and Glen,

                  I'm not getting any output but I also don't have any syntax errors.

                  Will check later when I can.

                  Thanks,

                  kz

                  Comment


                  • #10
                    Originally posted by lazzie
                    Hi Glen.

                    Thanks for the advice on what to do. Unfortunately programming is a bit beyond me but I have a friend who’s much more computer literate than I am so I will try get around to his place soon and see if we can work it out.
                    Hey Lazzie,

                    Your welcome, happy to help out.

                    Programming is alot easier then pulling money out of those stock indices, but I understand if you aren't into it. However computer literate you friend, unless he's coded javascript/EFS recently I doubt he can knock it off quickly.

                    Anyway can't make any promises but I'll do what I can as I'm also interested as I got a little sidetracked from my index trading for currency system development and also got a little impatient waiting for the volatility to come back to historical levels. But things may be changing in that regard


                    Hopefully others may be interested. I will say this, I sat there for a year or more trading the indices and if people interested in learning to trade the S&P knew how valuable the information you already presented is, there would be 100 people jumping into offering to help but I doubt that will happen (can't make'em drink...).



                    Yes, I want all three markets (S&P, NQ and the YM) to be moving in the same direction for me to take a trade, and most of the time they are. I also want at least the 10ma on the 1,3, and 5 minute charts to be pointing the same way too. Preferably the 15 minute chart also. If however the 10ma on the 15 minute chart is falling rather then rising I would still take a long trade if the 10 period Hull MA on the 15 minute chart has started turning up. When the 10 period Hull starts turning you can normally scalp a couple of points on the S&P even if it’s only a pullback on the 15 minute chart and not a change of trend.


                    I only trade the morning session and most days you can get at least two or three entry points and that’s more then enough for me. I just find that it’s much more successful when all four time charts are lined up.

                    Again thanks for your advice.

                    Lazzie.

                    I need to give this a litle thought, it's an intersting and useful study so it may be worthwhile taking our time and doing it right.

                    I also need to refresh my memory on the Hull MA, iit rings a bell but that about it. f you have any links and can post them that would be helpful.post them, and we would need to search for an efs that calculated this.

                    What is the 4th chart?

                    What futures contract are you actually trading. The reason I ask, is if you are trading the russell and don't care about levels on the S&P or ND, but only the direction of the MA, then perhaps we can design the EFS to be loaded into the russell chart and plot the ma's not only for the other russell 2k moving averages but all the moving averages.

                    Might as well add the $ADD adn $UPVOL $DVOL for the s&p, and nd while we are at it...and throw in a ADX filter, ..just kidding for now...

                    I think you were talking about having four charts open with the 3-4 moving averages being plotted on each?

                    Maybe we can have one EFS that we have the option of deciding in the parameter settings what symbols and time periods to plot ut to some maximum combination of 25 or something like that.

                    Then you could do it either way, one chart with all averages plotted or several individual averages plotted?

                    Glen
                    Last edited by demarcog; 10-24-2007, 01:11 PM.
                    Glen Demarco
                    [email protected]

                    Comment

                    Working...
                    X