in Search

making an indicator look like a price oscillator

Last post 08-26-2009, 21:52 by johnl. 7 replies.
Sort Posts: Previous Next
  •  04-02-2009, 18:07 29324

    making an indicator look like a price oscillator

    Basically what I am trying to do is create an indicator, in this case the difference between the +DI and -DI, that is can be different colors when rising and falling. Much like a price oscillator, I would want the indicator to be able to be both colors while above and below zero (a bar that is rising but below zero could be green or a bar that is falling and below above zero could be red). Everything I've been trying so far hasn't worked and it is entirely possible that this can't be done with MetaStock, but if you guys have any suggestions or solutions I'd greatly appreciate it. Thanks a lot
  •  04-02-2009, 19:33 29326 in reply to 29324

    Re: making an indicator look like a price oscillator

    hi ehhitch,

    Welcome to the Forum.

    Please post the code you've been trying and I am sure someone will assist you to fix the problems to achieve your desired result.


    wabbit Big Smile [:D]


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  04-02-2009, 20:05 29329 in reply to 29326

    Re: making an indicator look like a price oscillator

    Sorry I should have posted that originally. Here's what I've got so far:

    x:= ROC( DI(), 1, $);
       y:= ROC( x, 1, $);
       If(y>=0, x, 0);
       If(y<0, x, 0)

    It ends up giving me two indicators that make one very broken histogram. Also, anything above zero is one color and anything below zero is another. If there is a way to make color conditional to the direction of the change in relation to the previous measurement (in this case the DI from the day before) that would be best. Thanks
  •  04-02-2009, 23:06 29333 in reply to 29329

    Re: making an indicator look like a price oscillator

    Here's one take on the simple version of colouring a chart:

    -----------------------------------
    x:= ROC( DI(), 1, $);

    plus:=x*(x>0);
    minus:=x*(x<0);

    {histograms}
    0; {blue}
    plus; {green}
    minus; {red}

    -----------------------------------




    I think this is more what you're after though?

    -----------------------------------

    x:= ROC( DI(), 1, $);

    yp := ValueWhen(1,x>0,x) > ValueWhen(2,x>0,x);
    yn := ValueWhen(1,x<0,x) < ValueWhen(2,x<0,x);

    {histograms}
    0; {blue}
    x*(x>0)*(yp>0); {lightgreen}
    x*(x>0)*(yp=0); {darkgreen}
    x*(x<0)*(yn>0); {darkred}
    x*(x<0)*(yn=0); {red}

    -----------------------------------






    Hope this helps.

    wabbit Big Smile [:D]


    P.S. Don't forget to save the chart as a template after adjusting the colours so you don't have to do it every time!


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  04-15-2009, 18:24 29443 in reply to 29333

    Re: making an indicator look like a price oscillator

    Thank you, that helps a lot. My only question would be is there any way to set x in relation to the previous day's data as opposed to having it related to 0? I don't have the most advanced knowledge of MetaStock formulas but I feel like an inequality that relates today's data to the previous day's data should be possible. Then I could use the histogram coloring scheme you provided to color code it to my preference. Thank you very much for your continued help.
  •  04-15-2009, 19:47 29445 in reply to 29443

    Re: making an indicator look like a price oscillator

    Sorry, I don't understand the problem?  Can you provide more detail?


    wabbit Big Smile [:D]


    "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim."
    Edsgar W. Dijkstra

     

    MS: 6.52 EOD, 7.x EOD, 8.0 PRO, 9.2 PRO w/QC, 10 PRO w/QC C, 11 PRO w/QC & MDK
    For custom MetaStock programming : http://www.wabbit.com.au
    My SkyPE status :
    My SkyPE account : wabbit.com.au

  •  08-24-2009, 14:38 30514 in reply to 29445

    Re: making an indicator look like a price oscillator

    I'm sorry ignore that last post; I'm not even sure what I was going for. The second formula you provided me, the one that uses the ValueWhen function, actually accomplishes what I was trying to do. I am unfamiliar with that formula and I was wondering if you could explain the purpose of the inequality in the function because when I tried recreating similar indicators I was unsuccessful. Thanks a lot.
  •  08-26-2009, 21:52 30530 in reply to 30514

    Re: making an indicator look like a price oscillator

     Think of ValueWhen(A,B,C) as going backwards on the chart and picking out the "A"th 
     occurrence from today of  "C" when the calculation or value of "B" is true. I had to
     write a test formula to convince myself  of what it is doing, do one with moving averages.
     

     

View as RSS news feed in XML