Stock Intrinsic Value & MOS Indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ChrisTradeOfficial

//@version=5
indicator("Stock Intrinsic Value & MOS Indicator", overlay=true)


// Define the inputs
pe_ratio = input(15, title="P/E Ratio")
eps = input(3, title="Earnings per Share")
div_yield = input(2, title="Dividend Yield")
margin_of_safety = input(30, title="Margin of Safety (%)")

// Calculate the intrinsic value
intrinsic_value = eps * (pe_ratio + (2 * (div_yield / 100)))
margin_of_safety_value = intrinsic_value * (1 - (margin_of_safety / 100))

// Plot the intrinsic value and margin of safety value
plot(intrinsic_value, color=color.blue, linewidth=2, title="Intrinsic Value")
plot(margin_of_safety_value, color=color.green, linewidth=2, title="Margin of Safety")