Latest Articles related to all categories. Microsoft, Twitter, Xbox, Autos and much more

Full width home advertisement

Post Page Advertisement [Top]



Creating a script for Trading View that identifies stocks breaking above their 90-period Moving Average (MA90) can be quite useful for traders. In this example, I'll provide you with a simple Pine Script strategy that accomplishes this task. Please note that Pine Script is specific to the Trading View platform.

 PineScript


//@version=4

study(title="MA90 Breakout Scanner", shorttitle="MA90 Breakout", overlay=true)


// Input for MA period

ma_length = input(90, title="MA Period", minval=1)


// Input for the percentage above the MA to trigger a breakout

breakout_percentage = input(1, title="Breakout Percentage", minval=0, step=0.1)


// Calculate the MA

ma = sma(close, ma_length)


// Calculate the breakout level

breakout_level = ma * (1 + (breakout_percentage / 100))


// Plot the MA and breakout level

plot(ma, color=color.blue, title="MA90")

plot(breakout_level, color=color.red, title="Breakout Level")


// Define conditions for a breakout

breakout_condition = crossover(close, breakout_level)


// Plot shapes on the chart when a breakout occurs

plotshape(breakout_condition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)


// Alert when a breakout occurs

alertcondition(breakout_condition, title="MA90 Breakout", message="Stock has broken above MA90 by the specified percentage.")

Explanation:


We start with setting up the script using study with custom inputs for MA period and breakout percentage.


The Moving Average (MA) is calculated using sma (Simple Moving Average) with the specified period.


We calculate the breakout level by multiplying the MA by (1 + (breakout_percentage / 100)), which allows for a customizable percentage above the MA.


We plot the MA and the breakout level on the chart for visualization.


We define a breakout_condition variable that checks if the closing price crosses above the breakout level.


We use plotshape to plot green triangles below the bars when a breakout condition is met.


Finally, we set up an alertcondition to trigger an alert when a breakout occurs.


To use this script in TradingView, follow these steps:


Open the TradingView platform.

Create a new chart for the stock or market you want to analyze.

Click on "Indicators and Strategies" (or press Ctrl + I).

Find and add the custom indicator you created by searching for its name.

Adjust the inputs as desired (e.g., MA period, breakout percentage).

Save and apply the indicator to the chart.

You should see green triangles below the bars where a breakout occurs.

You can set up alerts to receive notifications when a breakout happens.

Please remember that this script provides a basic MA90 breakout scan. Traders should perform further analysis and risk management before making any trading decisions. 

 

No comments:

Post a Comment

Bottom Ad [Post Page]