Announcement

Collapse
No announcement yet.

Plotted Line (Hull MA) Not Changing Color Correctly

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

  • Plotted Line (Hull MA) Not Changing Color Correctly

    Here is an example of Chris Kryza's recent excellent Hull MA display, available from your efs File Share which can
    optionally change color for up and down moves.




    I have been using this excellent study for a few weeks now, However, I have become increasingly concerned the
    Hull MA line changes color usually one bar too late and decided to investigate this.

    Chris' code seems correct and the logic is certainly in the code to accommodate a change in line color, live,
    while the current price bar is forming. Having watched this closely over many price bars when, IMO, the
    line should have changed color, it never did. It did not change color even when the Hull MA current value in the
    right hand price scale changed color during the formation of the current price bar.

    PHP Code:
    nPlot nStudy2.getValue(0);
         
    if ( 
    nPlot>nPlot_1 ) {
         
    setBarFgColorUpColor); 
         
    setDefaultBarFgColorUpColor);
    }

    if ( 
    nPlot<=nPlot_1 ) {
         
    setBarFgColorDnColor);
         
    setDefaultBarFgColorDnColor);

    So I then added some code of my own to display a text diamond just offset underneath the Hull MA. I used the same logic
    as Chris for changing the color of the diamond while the bar was forming.

    PHP Code:
    nPlot nStudy2.getValue(0);

    if ( 
    nPlot>nPlot_1 ) {
         
    setBarFgColorUpColor); 
         
    setDefaultBarFgColorUpColor);
         
    vPaintBarColor PaintBarColorUp;
    }

    if ( 
    nPlot<=nPlot_1 ) {
         
    setBarFgColorDnColor);
         
    setDefaultBarFgColorDnColor);
         
    vPaintBarColor PaintBarColorDn;
    }

    if (
    PaintBarsYesNo == "Yes") {
         
    removeText("AUp"+vPaintBarCount);
         
    drawTextRelative(0,nPlot-vPaintBarDistance,"u",vPaintBarColor,null,
         
    Text.VCENTER|Text.CENTER|Text.BOLD|Text.ONTOP,"Wingdings",PaintBarSize,"AUp"+vPaintBarCount);

    In testing, the text diamond does indeed change color while the current bar is forming - under the appropriate
    circumstances - but the Hull MA line does not change color. See in the chart below how at both recent lows the
    Hull MA goes up but remains red while my text diamond has corrently changed to green, and at the recent highs
    the Hull MA is still green while my text diamond has correctly changed to red. At these 4 "trend change points" my text
    diamond had originally been displayed in the opposite color at the beginning of the time interval - similar in color
    to the eSignal plotted line - and then changed color at some point during the bar's time interval while the eSignal
    plotted line did not change color. It seems the eSignal plotted line stays the color it is originally displayed no matter
    what occurs during the rest of the bar time interval.



    So my question is simply why does the eSignal plotted line not change color live as it should while the bar is being
    formed, yet I can easily display a text symbol that changes color correctly using the same logic?

    How is it possible to make the eSignal plotted line change color correctly like my text diamond please?

    Regards,
    Rob

  • #2
    Rob
    The plot actually is changing colors according to the direction of the Hull moving average. What happens though is that in a continuous plot the lines joining the data points are colored according to the last data point going forward. To verify this add a setPlotType(PLOTTYPE_DOT) statement in preMain. Notice that the dots are colored appropriately. Now using the Line Segment tool draw a line that joins going forward each of those points that is in the same color of the point from which the line begins and you will see that you will end up with some up lines that are in red and down lines in green.
    If you want the color of the lines to be based on the current end point rather than the last end point add a
    setPlotType(PLOTTYPE_INSTANTCOLORLINE)
    statement in preMain
    Alex

    Comment


    • #3
      Excellent, thank you Alexis. I do indeed want the second of your two examples where the color of the lines is based on the end point rather than the start point of the line. I tried your suggestion - with a direct coded statement as you suggested - and it worked fine:



      However, it introduced another little problem. The study has a "Line Type" user input parameter with options for the regular "Solid", "Dot", "Dash" etc. Then there is a statement in the efs that converts these options to a valid eSignal Plot Type:

      PHP Code:
      setPlotType( eval( "PS_"+Type.toUpperCase() ), ); 
      In the user input parameter list, I tried options for "INSTANTCOLORLINE" and "InstantColorLine" but neither worked with the above eval statement giving a formula error.

      Is there a valid option for InstantColorLine to work with the eval statement or must I do a manual "setPlotType(PLOTTYPE_INSTANTCOLORLINE);" statement please?

      Thanks
      Rob

      Comment


      • #4
        Rob
        The command you are referring to is for the Line Style not the Plot Type. Add the statement I suggested in preMain and that will be applied to any of the Line Styles available in the "Plot Type" user defined parameter
        Alex

        Comment


        • #5
          Alexis

          Mea culpa!

          I was indeed confusing the statements SetPlotType and SetDefaultBarStyle such that I had them the wrong way around in my modified code and hence the efs error. Having corrected them, everything works fine. Thank you again.

          Regards
          Rob

          Comment


          • #6
            Rob
            You are most welcome
            Alex

            Comment


            • #7
              I still have a question on this study for you please Alexis.

              Before, without the setPlotType(PLOTTYPE_INSTANTCOLORLINE) statement in my code, the current Hull MA value was displayed on the right hand price axis as lime when ascending and red when falling.

              With the setPlotType(PLOTTYPE_INSTANTCOLORLINE) statement operational, and only that change, the current Hull MA value is always displayed in the right hand price axis as blue when both ascending or declining, yet I have no statement to color it blue anywhere in my code - I did a "find" on "blue" to double check!

              You can indeed see this from my chart images below and also from my sample code I showed. If I comment out the setPlotType statement, the Hull MA axis value goes back to displaying in lime and red colors as before. Is there a way to continue to display that current Hull MA value in the Up and Down colors while using the InstantColorLine PlotType? I noticed your image did not change the color of the displayed Hull MA value in the margin but cannot find anything about displaying that color in the efs study documentation.

              Regards,
              Rob

              Comment


              • #8
                Rob
                See this thread for the explanation and solution. By the way I found the thread by searching the forums for instantcolorline
                Alex

                Comment

                Working...
                X