Nightshark Script for Morning Star Candle Strategy

Nightshark Script for Morning Star Candle Strategy

Full Tutorial:

Think Script signal code:

# Define Morning Star Pattern
def isRed1 = close[2] < open[2]; # First candle is red

# Small body for the second candle, manually calculate absolute value
def smallBodyValue = if close[1] > open[1] then close[1] - open[1] else open[1] - close[1];
def largeBodyValue = if close[2] > open[2] then close[2] - open[2] else open[2] - close[2];
def isSmallBody = smallBodyValue < (largeBodyValue / 4);

def isGreen3 = close > open; # Third candle is green

# Final condition for Morning Star
def isMorningStar = isRed1 and isSmallBody and isGreen3 and close > ((open[2] + close[2]) / 2);

# Add separate labels
AddLabel(yes, "Signal: " + (if isMorningStar then "   BUY      " else "   NONE  "), if isMorningStar then Color.GREEN else Color.GRAY);

# Plot arrows for Buy signals
plot ArrowUp = if isMorningStar then low - tickSize() else Double.NaN;
ArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ArrowUp.SetLineWeight(3);
ArrowUp.SetDefaultColor(Color.GREEN);

SET UP:

Nightshark Script:

StopScript() {
    Send, {F2}
}

BuyCondition() {
    return area[1] = "BUY"
}

loop {
    loop {
        read_areas()
    } until BuyCondition()

    click(point.a)
    sleep 3000

    loop {
        read_areas()
    } until (toNumber(area[2]) > 20 || toNumber(area[2]) < -10)

    click(point.b)
    sleep 3000

    loop {
        read_areas()
        if (toNumber(area[3]) > 60 || toNumber(area[3]) < -40) {
            StopScript()
        } else {
            break
        }
    }
}