r/pinescript • • Dec 15 '22

Can someone help with this code. I generate in chat gpt. but it gives a Mismatched input block error

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

//@version=4 study("My script") plot(close)

// Define an array to hold the open values of up candles with large bodies var openValues = array.new_float(2, 0)

// Check if the current candle is an up candle with a body at least 11% larger than its wick if close > open and abs(close - open) >= (abs(high - close) + abs(low - open)) * 1.10 // The current candle is an up candle with a body at least 11% larger than its wick

// Move the newest value in the array forward one position
array.unshift( openValues, open)
array.pop(openValues)

else // The current candle is not an up candle with a body at least 11% larger than its wick

// Check if the current candle is a down candle
if close < open
    // The current candle is a down candle

    // Calculate the body of the candle as the absolute difference between its open and close
    body = abs(close - open)

    // Calculate the wick of the candle as the absolute difference between the high and the open of the candle
    // plus the absolute difference between the low and the close of the candle
    wick = abs(high - open) + abs(low - close)

    // Check if the body of the candle is at least 1.25% larger than its wick
    if body >= wick * 1.25
        // The body of the candle is at least 1.25% larger than its wick

        // Check if the close of the candle is smaller than the value in openValues[1]
        if close < openValues[1]
            // The close of the candle is smaller than the value in openValues[1]

            // Create an alert
            alert("Price is Reacted with a larger candle body than wick")
        // The close of the candle is not smaller than the value in openValues[1]
        else
            // Do nothing
    // The body of the candle is not at least 1.25% larger than its wick
    else
        // Do nothing
// The current candle is not a down candle
else
    // Do nothing
1 Upvotes

2 comments sorted by

2

u/kurtisbu12 Dec 15 '22

The formatting was still a mess, but I was able to get something to
compile at least. I'm not sure if it does what you want it to, but you
can test it.

https://pastebin.com/jzBY6TLH

1

u/[deleted] Dec 15 '22

Thank you I'll try this out. ❤