Trade Ideas to Discord Webhook
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © godzcopilot

//@version=5
indicator('Trade Ideas to Discord Webhook', shorttitle='💡', overlay=true)

// Input fields
alert_type = input.string('Combined',title='Alert Type',options = ['Combined', 'Entry', 'Exit'],tooltip='Select Alert Type' )

direction = input.string('LONG',title='Long/Short',options = ['LONG', 'SHORT'],tooltip='Select Long / Short' )

entry1 = input.float(0.0, title='Entry 1', group='Entry', inline='1')
entry2 = input.float(0.0, title='Entry 2', group='Entry', inline='1')
entry3 = input.float(0.0, title='Entry 3', group='Entry', inline='2')
entry4 = input.float(0.0, title='Entry 4', group='Entry', inline='2')

tp1 = input.float(0.0, title='TP 1', group='Exits', inline='3')
tp2 = input.float(0.0, title='TP 2', group='Exits', inline='3')
tp3 = input.float(0.0, title='TP 3', group='Exits', inline='4')
tp4 = input.float(0.0, title='TP 4', group='Exits', inline='4')

stopLoss = input.float(0.0, title='Stop Loss', group='Safe Trading', inline='5')
maxLeverage = input.int(0, title='Max Leverage', group='Safe Trading', inline='5')

otherNotes = input.string('', title='Other Notes', group='Trade Notes', inline='6')
sentAlert = false

// Indicator logic
alertCondition = (alert_type == 'Combined' and (entry1 != 0 or entry2 != 0 or entry3 != 0 or entry4 != 0)) or (alert_type == 'Entry' and (entry1 != 0 or entry2 != 0 or entry3 != 0 or entry4 != 0)) or (alert_type == 'Exit' and (tp1 != 0 or tp2 != 0 or tp3 != 0 or tp4 != 0))

msg_Color = direction == 'LONG' ? 60227 : 15730953
// JSON formatted alert message with ticker and excluding default values
jsonMessage = '{"embeds": [{ "title": "' + direction + ' trade idea for: ' + syminfo.ticker + '", "color": ' + str.tostring(msg_Color) + ', "description": "' + ((alert_type == "Combined" or alert_type == "Entry") ? '**__ENTRY__**' + '\\n' + (entry1 != 0 ? '**1:**󠀠ㅤ' + str.tostring(entry1) + '\\n' : '') + (entry2 != 0 ? '**2:**ㅤ' + str.tostring(entry2) + '\\n' : '') + (entry3 != 0 ? '**3:**ㅤ' + str.tostring(entry3) + '\\n' : '') + (entry4 != 0 ? '**4:**ㅤ' + str.tostring(entry4) + '\\n' + '\\n' : '') : "" ) + ((alert_type == "Combined" or alert_type == "Exit") ? '**__TAKE PROFIT__**' + '\\n' + (tp1 != 0 ? '**1:**ㅤ' + str.tostring(tp1) + '\\n' : '') + (tp2 != 0 ? '**2:**ㅤ' + str.tostring(tp2) + '\\n' : '') + (tp3 != 0 ? '**3:**ㅤ' + str.tostring(tp3) + '\\n' : '') + (tp4 != 0 ? '**4:**ㅤ' + str.tostring(tp4) + '\\n' + '\\n' : ''):"") + (stopLoss != 0 ? '**STOP LOSS:**ㅤ' + str.tostring(stopLoss) + '\\n' : '') + (maxLeverage != 0 ? '**MAX LEVERAGE:**ㅤ' + str.tostring(maxLeverage) + '\\n' + '\\n' : '') + (otherNotes != '' ? '**__CONSIDERATIONS:__**  ' + '\\n' + otherNotes : '') + '"}] }'


// Generate alerts
if alertCondition and not sentAlert
    alert(jsonMessage, alert.freq_once_per_bar)
    sentAlert := true
    sentAlert

