DMI Oscillator buy and sell signals

Berezowsky

New member
Hello, I was wandering if you might be able to help me with a script for a WL column. Basically what I am looking for is when the DMI oscillator changes from negative to positive, Give the Change signal (buy now), second bar signal (buy) and subsequent bars, just positive. The code I am using and trying to adapt is the following:

Important to know... each code it is giving the correct signals either for long or short in a different column. the goal is to achieve everything into the same code to have everything in the same column.

Code:
#Long
input length = 100;
input paintBars = yes;
input averageType = AverageType.WILDERS;
def diPlus = DMI(length, averageType)."DI+";
def diMinus = DMI(length, averageType)."DI-";
plot osc = diPlus - diMinus;
Addlabel (yes,
    if        OSC    < 0 then "N-"
    else if   OSC[1] < 0 then "Buy Now"
    else if   osc[2] < 0 then "B"
    else if   osc    > 0 then "P+"
    else "^",
    if        osc    < 0 then color.red
    else if   osc[1] < 0 then color.black
    else if   osc[2] < 0 then color.black
    else if   osc    > 0 then color.green
    else   color.gray);
assignbackgroundcolor(
    if         OSC    < 0 then color.black
    else if    OSC[1] < 0 then color.green
    else if    OSC[2] < 0 then Color.light_GREEN
    else color.black);

#SHORTING
input length = 100;
input paintBars = yes;
input averageType = AverageType.WILDERS;
def diPlus = DMI(length, averageType)."DI+";
def diMinus = DMI(length, averageType)."DI-";
plot osc = diPlus - diMinus;
Addlabel (yes,
    if        OSC    > 0 then "+"
    else if   OSC[1] > 0 then "Sh now"
    else if   osc[2] > 0 then "Sh"
    else "-",
    if        osc    > 0 then color.green
    else if   osc[1] > 0 then color.black
    else if   osc[2] > 0 then color.black
    else   color.red);
assignbackgroundcolor(
    if         OSC    > 0 then color.black
    else if    OSC[1] > 0 then color.red
    else if    OSC[2] > 0 then Color.pink
    else color.black);

THANK YOU IN ADVANCED!!!

Fernando
 

Similar threads

Top