Announcement

Collapse
No announcement yet.

Viewing percent change in Y-axis possible?

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

  • Viewing percent change in Y-axis possible?

    Can the Y axis of an Adv chart be set to view percent change? Or maybe an efs has been written to allow this (on an intraday chart)?

    Thanks
    shaeffer

  • #2
    shaeffer
    AFAIK you cannot set the price scale to percent change.
    The enclosed script will calculate the percent change on an intraday chart
    Alex

    PHP Code:
    function preMain() {
        
    setPriceStudy(false);
        
    setStudyTitle("Percent Change");
        
    setCursorLabelName("%Chng");
        
    addBand(0,PS_SOLID,1,Color.black);
    }

    var 
    vClose null;

    function 
    main(Time,Price) {

        
    vClose call("/OHLC/getPrevOHLC.efs","Close");

        if(
    vClose==null) return;
        
        var 
    vPerChng= ((close()-vClose)/vClose)*100;

        return 
    vPerChng;

    Comment


    • #3
      Hi Alex

      The link below allows comparison of relative strength of major Nasdaq sectors, on a daily basis.
      http://stockcharts.com/webcgi/perf.html?$SOX,$COMPQ,$BTK,$DOT,$NWX,$GHA,$GSO,$DRG,$RLX,$IX TC

      I wanted to plot the Nas, BTK, SOX and DOT indexes on a one day only, intraday basis with % change, to see their relative strengths as the trading day progressed.

      As opposed to the simple % change in a quote list, this would provide equity (and ETF) traders with a much better picture of sector strength.

      If I overlayed those symbols in a chart, with your efs, do you think I could achieve this?

      Thanks
      shaeffer

      Comment


      • #4
        shaeffer
        In that case you may want to look at PerformanceComp.efs in this thread
        Alex

        Comment


        • #5
          Thanks Alex,

          That's almost exactly what I wanted! I like it even better after dragging the % performance curves up into the main chart window.

          I'll look at this closer, but hopefully there are no technical reasons I shouldn't be able to view 5 or 6 % Performance curves (asssuming I can make the correct changes to the efs)?

          I've set my chart window to one day only, 9:30 - 4:00 EST, so I assume the start point will include any gaps (i.e. it won't start from the close of the day before)?

          Thanks again
          shaeffer

          Comment


          • #6
            Hello shaeffer,

            You could also apply the formula to a chart multiple times instead of trying to modify the code. Then just change the symbols used through Edit Studies. If you do modify the code, you'll be able to use up to 7 different symbols.
            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


            • #7
              Hi Jason,

              7 symbols would be plenty in one efs (or chart).

              Using the efs multiple times is an interesting idea. But the main chart symbol would get recalculated each time - kind of a waste. Hopefully each efs would recognize the same '0' line if dragged into the main window?

              In my reply to Alex, I commented that dragging the % change curves up into the chart together with the reference symbol gave an improved perspective, I'm now thinking that a non-study version of this efs (where all values are returned to the main chart window, with no real-price plot of the reference symbol) might also be useful.

              Gotta think about this some more, but my gut feel is one efs with 7 symbols is the way to go. Thanks for the ideas.

              Cheers
              shaeffer

              Comment


              • #8
                Hi Jason, Alex,

                I got the 7 symbols into one efs, per the pic below.

                The cursor window colors identify which curve is which sector, but I don't need the % value shown, just the sector name. Can the name only appear in the cursor window?
                Or can I color each sector name in the EFS study title so I don't need the cursor window colors at all?

                I know what sectors I want to see. Where can I input them directly to the efs? (so I don't need to re-input them via edit studies each time I tweek the efs)?

                I tried to eliminate the $Comp actual-price curve by inserting 'setPriceStudy(true):' under premain(), but that didn't work. I guess the $Comp actual-price curve has to stay?

                Thanks
                shaeffer
                Attached Files

                Comment


                • #9
                  Hello shaeffer,

                  The cursor window colors identify which curve is which sector, but I don't need the % value shown, just the sector name. Can the name only appear in the cursor window?
                  Or can I color each sector name in the EFS study title so I don't need the cursor window colors at all?
                  You won't be able to hide the % values in the cursor window or set individual colors for the names in the title. You could turn off the cursor label off all together and draw text labels on the chart for each sector name. Use drawTextRelative() with Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM flags.

                  I know what sectors I want to see. Where can I input them directly to the efs? (so I don't need to re-input them via edit studies each time I tweek the efs)?
                  Perform a series of null checks for the symbol input parameters and set them to your desired defaults if they are null. Add the follow just before the preMain() call inside main().

                  PHP Code:
                  if (Symbol1 == nullSymbol1 "$SOX";
                  if (
                  Symbol2 == nullSymbol2 "$BTK";
                  if (
                  Symbol3 == nullSymbol3 "$DOT";
                  if (
                  Symbol4 == nullSymbol4 "$GHA";
                  if (
                  Symbol5 == nullSymbol5 "$GSO";
                  if (
                  Symbol6 == nullSymbol6 "$RLX";
                  if (
                  Symbol7 == nullSymbol7 "$COMPQ";
                  preMain(); 
                  I tried to eliminate the $Comp actual-price curve by inserting 'setPriceStudy(true):' under premain(), but that didn't work. I guess the $Comp actual-price curve has to stay?
                  You can eliminate it. You'll notice at the top of main the variable, cSym. This is setting the first symbol in your array with the main chart symbol. You can remove the following two lines and the reference to cSym in preMain().

                  PHP Code:
                  cSym getSymbol();
                  vSymbols[0] = cSym
                  Then change any for loops that start with 1 to start with 0 instead.
                  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


                  • #10
                    shaeffer,

                    One more thing. If you remove the cSym stuff, you'll need to change the symbol input parameters to start with Symbol0 to Symbol6 so that they will work with the first for loop in main.
                    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


                    • #11
                      Hi Jason,

                      I tried to use the drawTextRelative command last night with no luck. Do you happen to know of an efs that uses that command so I can see how/where it fits in?

                      Thanks
                      shaeffer

                      Comment


                      • #12
                        shaeffer
                        Use the enclosed script as an example
                        For more information on the syntax of drawTextRelative click here
                        Alex

                        PHP Code:
                        function preMain() {
                            
                        setPriceStudy(true);
                            
                        setStudyTitle("text");
                            
                        setCursorLabelName("N/A"0);
                        }

                        function 
                        main() {
                         
                            
                        drawTextRelative(25,0,"Sector1",Color.white,Color.blue,Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.BOLD,
                                            
                        "Arial",10,"Sector1");
                            
                        drawTextRelative(35,0,"Sector2",Color.white,Color.red,Text.RELATIVETOLEFT|Text.RELATIVETOBOTTOM|Text.BOLD,
                                            
                        "Arial",10,"Sector2");
                            
                            return;

                        Comment


                        • #13
                          Hello,

                          I'm making progress on the 3 changes I'm trying to make.
                          -------------------------------------------
                          1. Adding text labels.

                          I input (some of) the lines you suggested Alex, and it works great. I guess I didn't need the premain commands 'cause I inserted them into an existing efs. I'm not sure what the main parameters were for, but it seems to work without them.

                          But for my own understanding, I was equating use of the "new function parameter" commands as the way to make variables appear in the Edit Studies window. Yet without any "new function paramenter" commands in this efs, variables still appear in the Edit Studies window. What command is causing this?
                          -------------------------------------------
                          2. Defining specific symbols

                          I inserted the commands you suggested before premain Jason, but am getting an error, and can't figure out why.

                          With the symbols defined, and not wanting cursor label names, can I remove the if, else statements in premain (and leave the setDefaultBarFgColor statements in premain with no conditions)?

                          Almost the same question... can I remove the vLoaded variable and lines 99-114?
                          ---------------------------------------------
                          3. Removing the $Comp actual price curve

                          No action, I'm still deciding if I want to do that, as it can be useful, though I guess that affects changes to achieve 2. above

                          Thanks for your help
                          shaeffer
                          Attached Files

                          Comment


                          • #14
                            shaeffer
                            1. You only needed to copy the drawTextRelative() commands. The rest of the script was there so that you could run it as an efs.
                            Input parameters can be listed in Edit Studies even without the use of the Function Parameter class.
                            The sample efs enclosed below will list Length in Edit Studies
                            Alex

                            PHP Code:
                            function preMain(){
                                
                            setStudyTitle("test");
                            }
                            function 
                            main(Length){
                                if(
                            Length==null)
                                    
                            Length=10;
                                    
                            return;

                            Comment


                            • #15
                              Y-axis scale updating

                              I've been using the attached % change EFS for a while now. I drag the EFS study up to overlay the Nasdaq price plot, and then view 1 minute, then 2, then 3... 5 minute charts as the day progresses, so I can see the entire day within the window.

                              When I change to a new time interval, I get good plots. But as time progresses, the updates don't plot correctly - the curves flatten. The vertical scaling doesn't adjust correctly. I have to re-enter the same time interval, or a new time, to get an accurate plot.

                              I've tried turning on/off the Scale Right and No Scale toggles in Edit Studies, with no luck. Is there any tweak can be done to this EFS so the vertical scaling updates correctly?

                              Thanks
                              shaeffer
                              Attached Files

                              Comment

                              Working...
                              X