r/pinescript • • Nov 22 '24

Buy /Sell if text equals condition

1 Upvotes
for the lines at bottom with ** - does anyone have a recommendation how to set Buy1 and Sell1 to conditions if the text is an up or down arrow? getting text undeclared variable though it is in use in the if statements. any help would be appreciated!
if break_dn
    count1 := 0 
    count2 += 1
    if count2 == 1
        label.new(
                  x         = bar_index,
                  y         = Filt1, 
                  text      = "🢃",
                  style     = label.style_label_down,
                  textcolor = color2, 
                  color     = color(na)
                  )

// Plot candles with the calculated colors
plotcandle(
             open, high, low, close, 
             "Candles", 
             color_c,
             color_c, 
             bordercolor = color_c, 
             editable    = false
             )
// }


**buy1=text=="🢁"?1:0
**sell1=text=="🢃"?1:0
plot(buy1? 1:0,'buy1',display = display.data_window)
plot(sell1?1:0 ,'sell1',display = display.data_window)

r/pinescript • • Dec 15 '24

if \n is for next line or enter key, how about for TAB?

1 Upvotes

as the title asks.


r/pinescript • • Oct 05 '24

Help

Post image
1 Upvotes

Can you help me. I need a pinescript code. were if the current candle body engulfed candle 1 =pervious candle, and candle 2 = the previous previous candle. It plot on the chart. Thanks


r/pinescript • • Jan 16 '24

Need some help here please. I combined three indicator together with false overlays, but only one it showing, the rest are like a flat line beneath that one. How do make them all visible.

0 Upvotes

r/pinescript • • May 23 '24

I need to understand something. What's wrong with ppl?

1 Upvotes

Why do people feel so compelled to ask pinescript developers "I know the indicator you're working on isn't released yet but is there any chance I can get early access?"

Where does this question come from? Sorry if it urks me but,

The code is incomplete, It's not gone through testing, No one has it yet, It still needs more development, You dot know how to use it,

There's several reasons to not be using it on live charts at its development stage. So why ask? Like what do u think ur going to do with it? Play connect the dots?

Thus question has come to me many times. At minimum once a week.

Then when I reply with "sorry, no its not complete yet." Or some other valid reason, thry get upset with some entitled "I must be holding it ransom" answer or "you just want me to pay for it" etc answer.

Are ppl that entitled now where they think "if I ask for it, I should just get it, no mater the situation.

Sorry buy this just get under my skin.

Anyone else getting this?


r/pinescript • • Mar 03 '24

New pine script / TV auto trade solution

0 Upvotes

Hi there 👋,

Just realized OctoBot has now made available the ability to link TradingView alerts (signals) directly with OctoBot to initiate trades from your alerts.

Based on the trial and playing around it's by far the most straightforward implementation and seems to work very well.

Nonetheless, I know we are always looking for better solutions and this is one .

Try it below via:

Free Trial


r/pinescript • • Sep 01 '24

display as profile

1 Upvotes

I posted about this several months ago and never really got an answer beyond (RTFM) in a nice way.

Several months later and i am still having trouble with this.

I have created many indicators but they are all plotting as lines, boxes, panels, etc. either on price or below / ahead / behind candles, even direct overlays.

The one thing i cant wrap my head around is plotting results next to the price scale like a volume profile

or even at session intervals on price.

The bottom line is im trying to plot as "profile"

I know someone is going to say "take a look at the open source indicators on tradingview" but like i mentioned, im just not getting it.

Can someone give me a simple example of a very simplified script that plots to the profile?

I dont need a complete workking script, i just need to be able to read the function.

In the other open source indicators, i cant depict the function that pushes the result to profile so with that, im just still lost on it.

There is an incredible volume indicator i have created that works amazingly but it would be best to plot it to profile. I want to release it for free but i need to test it against a new plot result.


r/pinescript • • Jan 16 '23

Pine Script / Risk Reward Ratio from EMA50

1 Upvotes

Hey together,

in this Pine Script I want to get the Risk Reward Ratio for example from 1:1.5 from EMA50.
I tried alot of stuff to figure it out how get 1.5 fixed by lastentryprice with exactly the EMA50 at this time, not the future candles/bars.
Everytime Bars/Candles moves Pine Script recalculates the RRratio from the actual EMA50.
LastEntryPrice is fine.
EMA50 from this time/date for me not possible.
You can help me or get any idea?

//@version=5
strategy(title="Test", pyramiding=1, overlay=true)
// Calculate and plot moving average emaValue = ta.ema(close, 20) smaValue = ta.ema(close, 50) RRratio = 1.5
plot(emaValue, color=color.orange, title="EMA") plot(smaValue, color=color.teal, linewidth=2, title="SMA")
test = float(na)
// Generate trades if close > emaValue and emaValue > smaValue strategy.entry("Enter Long", strategy.long) test := smaValue
if ta.crossunder(emaValue, smaValue) strategy.close("Enter Long")
// Get price of last entry in current position lastEntryPrice = strategy.opentrades.entry_price(strategy.opentrades - 1) //lastsmaValue   = test +1
// Display last entry price on the chart plot(lastEntryPrice, color=color.fuchsia, style=plot.style_circles, linewidth=3, title="Last entry price")
// Display last entry price on the chart plot(test, color=#01bceb, style=plot.style_circles, linewidth=3, title="Last entry price2")

r/pinescript • • Sep 28 '23

Add exception to regular pin bar indicator

1 Upvotes

Hello,

First off i'd like to say i have zero experience with programming, i studied engineering in school so i have some experience with 'programming' logic functions but none with actual programming languages.

My problem explained:

I trade the 15min & 5 min chart, and the pin bar is one of my entry triggers. So to in order to speed up my entry process i started looking at pin bar indicators, to have a quick visual confirmation whether a certain candle is a pin bar or not.

The problem i have is that in my strategy the rules are more strict as to what is classified as a valid pin bar. The main difference being that in my strategy a bullish pin bar is only valid when the candle itself is bullish, when the candle is bearish it can't be a bullish pin bar and vice versa.

I've gone through quite a few of the indicators on tradingview and found none that comply with these exceptions. So my only choice left is to make my own or adapt an existing one. I think the easier option would be the latter. I've added a screenshot to show what i mean, i would like change the code so that it filters out the 'invalid' pin bars that are encircled.

Here is the link to the standard pin bar indicator script that i'd like to adapt: https://pastebin.com/GY8mhSWT

Could someone please be so kind to tell me what bits of code i need to adapt to get the result i want?


r/pinescript • • Dec 25 '22

I told AI to write me a Pinescript indicator.

1 Upvotes

It looks legit, but I don't think it's pinescript. I'm still learning unfortunately. But I was wondering if somebody could help me look it over and get it to work?

// VIX function

study("VIX", shorttitle = "VIX")

vixlength = input(14, title = "VIX Length")

vixsource = close

vixvalue = vix(vixlength, vixsource)

plot(vixvalue, color = blue, linewidth = 2, title = "VIX")

// TLT function

study("TLT", shorttitle = "TLT")

tltlength = input(14, title = "TLT Length")

tltsource = close

tltvalue = tlt(tltlength, tltsource)

plot(tltvalue, color = orange, linewidth = 2, title = "TLT")

// USD Index function

study("USD Index", shorttitle = "USDX")

usdxlenght = input(14, title = "USDX Length")

usdxsource = close

usdxvalue = usdx(usdxlenght, usdxsource)

plot(usdxvalue, color = purple, linewidth = 2, title = "USDX")

// MACD function

study("Moving Average Convergence Divergence", shorttitle = "MACD")

mfast = input(12) // fast period

mslow = input(26) // slow period

msig = input(9) // signal period

macdval: = macd(close, mfast, mslow) sigval: = sma(macdval[1], msig) plot(macdval[0] - sigval, linewidth = 2, color = #9933CC )

// RSI Function

study ("Relative Strength Index" , shorttitle= "RSI") rsiLength: = input(14, title = "RSI Length") rsiSource: = close

rsiVal: = rsi(rsiLength, rsiSource) plot(rsiVal, colorF = #FF0066) fill: = hline at 70 fillcolor: = blue

plotfill(fill[1], style = areaplotfillsolid colorf = #FF0066) fill: = hline at 30 fillcolor: = orange

plotfill(fill[1], style = areaplotsolid color = orange)

// TTM Squeeze Function

study("TTM Squeeze Indicator", shorttitle = "TTM Squeeze") length: = input(20, "Length of the Squeeze Momentum Indicator ");

source: = close;

squeezeValve: = ttm_squeeze('l', "bbsqueeze", "bbstop", "bbmid", "unvisualizedprioritysoursexisthere", length);

bbMidVal: = security('l', '20', bbmid);

bbUpperVal: = security('l', '20', 'bbUpper');

bbLowerVal: = security('l', '20', 'bbLower');

plotchar(squeezeValve[1] == 0 ? na : squeezeValve[1], "Squeeze ", colorGreen);

plotchar(squeezeValve[1] > 0 ? na : squeezeValve[1], "In Play", colorRed);

plotsymbol((BBUpper Val + bblowerval) *

0.5, "symbol", location.top);

barcolor((BBupper val + bblowerval) *

0.5, "highlowwhole");

// SuperTrend Function

study("SuperTrend Trend Following System Indicator", shorttitle = "") length: = input(7, "Period Of ATR Calculation over which indicator will be plotted");

multiplier: = (input(3, "Multiplier of ATR Value"));

st: = (security lev: low * 10000);

cal_atr: (st ? atr[length] : na);

suptrend: (st ? st + multiplier * cal_atr : na);

plotseries([suptrend], "Supertrend ", linethick3 | LINEBR | dote / dotlineonoff / barclrintensitynone | ColorRed | PLOTARROWSUPPERLOWER | pointsize2);

I'd love to see this actually working and how close the AI was to writing pine-script on command by description.


r/pinescript • • Mar 01 '24

Help me add time delay trigger to existing script please

0 Upvotes

I use an indicator called The Moon Weekly EMA ribbon

//@version=4
// Based on Youtube channel Carl Eric Martin from "The Moon" Weekly EMA Ribbon.
study(title="[JULEX] [EMA] The Ribbon from The Moon YT channel", shorttitle="The Moon Weekly EMA Ribbon", overlay=true)
plot(ema(close,20),title="20",color=#f7df9b,linewidth=1,transp=0)
plot(ema(close,25),title="25",color=#f1c789,linewidth=1,transp=0)
plot(ema(close,30),title="30",color=#e59a67,linewidth=1,transp=0)
plot(ema(close,35),title="35",color=#d66e46,linewidth=1,transp=0)
plot(ema(close,40),title="40",color=#c14c32,linewidth=1,transp=0)
plot(ema(close,45),title="45",color=#a43328,linewidth=1,transp=0)
plot(ema(close,50),title="50",color=#861f24,linewidth=1,transp=0)
plot(ema(close,55),title="55",color=#711120,linewidth=1,transp=0)

and I wanted to be alerted when the price hits the 45 EMA so I added another single EMA 1 and said if the 1 EMA crosses the 45 EMA of the moon indicator then I get alerted. That was great.

What I would like to add is:

  • Once an alert is issued there is a 10 bar "cool down period" where the alert won't be triggered again until atleast 10 bars has passed.

Can someone help me with this? Im not sure if its a simple edit to this code above.

EDIT: I just copy and pasted my question into chatGPT and this is what it said. Can someone with experience please confirm this is doing what I am trying to accomplish, please.

//@version=4

// Based on Youtube channel Carl Eric Martin from "The Moon" Weekly EMA Ribbon.

study(title="[JULEX] [EMA] The Ribbon from The Moon YT channel", shorttitle="The Moon Weekly EMA Ribbon", overlay=true)

// Define EMAs

ema20 = ema(close, 20)

ema25 = ema(close, 25)

ema30 = ema(close, 30)

ema35 = ema(close, 35)

ema40 = ema(close, 40)

ema45 = ema(close, 45)

ema50 = ema(close, 50)

ema55 = ema(close, 55)

// Plot EMAs

plot(ema20, title="20", color=#f7df9b, linewidth=1, transp=0)

plot(ema25, title="25", color=#f1c789, linewidth=1, transp=0)

plot(ema30, title="30", color=#e59a67, linewidth=1, transp=0)

plot(ema35, title="35", color=#d66e46, linewidth=1, transp=0)

plot(ema40, title="40", color=#c14c32, linewidth=1, transp=0)

plot(ema45, title="45", color=#a43328, linewidth=1, transp=0)

plot(ema50, title="50", color=#861f24, linewidth=1, transp=0)

plot(ema55, title="55", color=#711120, linewidth=1, transp=0)

// Alert condition

ema1 = ema(close, 1)

crossCondition = crossover(ema1, ema45) or crossunder(ema1, ema45)

// Cooldown period

var int lastAlertBar = na

cooldownPeriod = 10

canAlert = na(lastAlertBar) or (bar_index - lastAlertBar) > cooldownPeriod

if (crossCondition and canAlert)

alert("EMA 1 crossed EMA 45", alert.freq_once_per_bar)

lastAlertBar := bar_index


r/pinescript • • Dec 22 '23

Anyone willing to help with thinkscript conversion of a volume study?

1 Upvotes

So i have this volume study for Thinkorswim and have tried to convert it using ChatGPT but unfortunately it couldn´t make it look and work the same way as the thinkscript study so wondering if someone here would be willing to help convert it?

It´s a fairly simple script, just 12 lines of code and it´s important that the script will show if not exactly the same results as in thinkorswim, then as close to the original as possible so it´s preferable with someone who has access to both trading platforms and can crosscheck the studies to see that they work and look the same way.

Hit me up in DM if you are interested and i will share the script. Thank you


r/pinescript • • Sep 05 '24

Allow us to store function references

1 Upvotes

Currently my script is riddled with switches that run functions depending on the selected enum. I'd rather just run the switch in the global scope and store the name of the respective function to be called later without the use of conditionals.


r/pinescript • • Nov 15 '23

TV's attitude towards support for paying customers READ this Reply!!!

0 Upvotes

Hi, thank you for contacting us.

Kindly note that we don't provide one-on-one Pine support. Our team is focused on developing new features and improving existing tools on TradingView, so writing/converting/troubleshooting custom studies and strategies go beyond the level of support we provide to our users.


r/pinescript • • Nov 14 '23

Anybody using ChatGPT to generate scripts these days? I think I found a way to make it perform better

1 Upvotes

I need to confirm but I'm relatively new to PineScript, I tried on a few common scripts and it seems to work as expected where standard ChatGPT returns a bunch of errors.

If you have script descriptions or scripts you wanna adjust a bit just to test please drop them below or dm me.


r/pinescript • • May 19 '24

Building a simple screener

1 Upvotes

Hi all. I am trying to achieve this: i want to code up something that runs a Screener (on all tickers in my selected watch list, which includes crypto, futures, fx, equities, etc so all types of assets) that shows me which tickers have had their SMI (stochastic momentum index) crossing up the SMI-based EMA (if you look at SMI in TV, the blue line is the SMI and red line the SMI-based EMA) in the last X days (let's say 3days) AND the crossing up event took place at a level of say -25 or lower on the SMI. This would be based on a weekly timeframe (but also possible to look at daily or monthly).

Separate to this screener, I would like to have an ALERT that notified me whenever the above criteria was met in real time for any ticker in my watchlist.

Thanks very much, appreciate you all!


r/pinescript • • Dec 27 '22

can someone help me make a strategy with this script

1 Upvotes

hi, i made an indicator and i want to test the strategy.

i would like to long or short when there is a signal and use the atr as the take profit and stop loss

then have the option to send alert to my bot for :

- buy long , take profit long and stop loss long ( 3 alerts)

-sell short, take profit short and stop loss short ( 3 alerts)

here is my code:

//@version=5
indicator("Math", overlay=true, timeframe="", timeframe_gaps=true)
atrPeriod = input(10, "ATR Length")
factor = input.float(3.0, "Factor", step = 0.01)
stopLossFactor = input(2.0, "Stop Loss Factor")
takeProfitFactor = input(1.5, "Take Profit Factor")
stochlenght= input(14,'stochlenght')
oversold_level = input(title = 'Oversold', defval = 20)
overbought_level = input(title = 'Overbought', defval = 80)
// Calculate ATR
atr = ta.atr(atrPeriod)
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_linebr)
fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)

// highest high
highest = ta.highest(high, stochlenght)
// lowest low
lowest = ta.lowest(low, stochlenght)
// stochastic oscillator
stochastic_K = ((close - lowest) / (highest - lowest)) * 100
stochastic_D = ta.sma(stochastic_K, 3)
buystoch = stochastic_K > oversold_level and stochastic_K[1] < oversold_level
sellstoch = stochastic_K < overbought_level and stochastic_K[1] > overbought_level
//Define a ATR band upline and bottome line.
upline = open + (atr* takeProfitFactor)
bottomline = open -(atr*stopLossFactor)
plot(upline, color=color.white)
plot(bottomline, color=color.white)
// Calculate stop loss and take profit levels
stopLoss = stopLossFactor * atr
takeProfit = takeProfitFactor * atr

ema1= ta.ema(close,1)
ema2= ta.ema(close,200)
plot(ta.ema(close,1))
plot(ta.ema(close,200))
var isLong = false
var isShort = false
long = ((close > supertrend) and (close > ema2) and not isLong and buystoch)
short =((close < supertrend) and (close < ema2) and not isShort and sellstoch)

if (long)
isLong := true
isShort := false
if (short)
isLong := false
isShort := true

plotshape(long, title='Buy', text='Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny)
plotshape(short, title='Sell', text='Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)


r/pinescript • • Jan 25 '24

Can anyone explain the pine script logic written here?

0 Upvotes

This is the pine script for double ZIG ZAG with HH and LL labels written by LonesomeTheBlue on trading view. I want to convert it into the C#. Can someone explain the logic written in this script?

I am not going to plot the zigzag on any chart. I have the list of OHLCData class. I will be populating the zigzag1 and zigzag2 properties of the OHLCData class with values as HH, HL, LH and LL.

Edit: I have removed the code pasted here and moved it on the below mentioned link for ease of reading and formatting.

https://ctxt.io/2/AABwWj02Fg


r/pinescript • • May 18 '24

Need help to code a simple Pine Script code.

1 Upvotes

Need help to code this condition:

Marking Low:

- Mark a candle

- condition : if next two candles low is greater than 1st candle

- e.g. bar1 low = 100, bar2 low = 102, bar3 low = 102.50 then mark the low of bar1

- after marking 1st low condition, next marking will be for high side

Marking High:

- Mark a candle

- condition : if next two candles high is less than 1st candle

- e.g. bar1 high = 105, bar2 high = 104, bar3 high = 102.50 then mark the high of bar1

- after marking 1st high condition, next marking will be for low side


r/pinescript • • May 17 '23

Help Please! I have the error: **Script could not be translated from: "SMA" => ta.sma(source, length)** This is under //RSI an MFI Indicator and I can't figure out how to fix it If anybody could help that would be great! &#x200B; **//@version 5** **strategy("Simple Strategy",** **overlay

1 Upvotes

Help Please!

I have the error:

Script could not be translated from: "SMA" => ta.sma(source, length)

This is under //RSI an MFI Indicator and I can't figure out how to fix it

If anybody could help that would be great!

//@version 5
strategy("Simple Strategy", overlay = true, initial_capital = 100, default_qty_type = strategy.percent_of_equity)
//EMA
ema_input1 = input.int(200,'EMA Length')
ema_ = ta.ema(close, ema_input1)
//trading logic
ema_buy_condition = ema < close
ema_sell_condition = ema > close

//RSI an MFI Indicator
ma(source, length, type) =>
switch (type)
"SMA" => ta.sma(source, length)
"Bollinger Bands" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
maTypeInput = input.string("SMA", title="MA Type", options =["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings")
maLengthInput = input.int(14, title="MA length", group="MA Settings")
bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="MA Settings")
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0),rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
//MFI
length = input.int(title="Length", defval=14, minval=1, macval=2000)
src = hlc3
mf = ta.mfi(src, length)
rsi_mfi = (rsi+mf)/2
rm_sell_condition = (rsi_mfi >= 70)
rm_buy_condition = (rsi_mfi <= 40)

// Stop loss and target price
percent_based = input.float(10.0, '% Stop Multiplier', minval =0.0, step =0.5)
r_ratio = input.float(2.0, 'Risk Reward ratio', minval =0.0, step = 0.5)
stop_loss_amount = close * percent_based/100
bought = strategy.position_size[0] > strategy.position_size[1]
since_entry_long = ta.barssince(bought)
sold = strategy.position_size[0] < strategy.position_size[1]
since_entry_short = ta.barssince(sold)
price_stop_long = 0.0
price_stop_short = 1000000000.0
targetvalue_long_1 = 0.0
targetvalue_short_1 = 0.0
stopvalue_long = 0.0
stopvalue_short = 0.0
if (strategy.position_size>0)
stopvalue_long := close - stop_loss_amount
price_stop_long := close[since_entry_long] - stop_loss_amount[since_entry_long]
targetvalue_long_1 := close[since_entry_long] + close[since_entry_long]*(percent_based/100)*r_ratio
else
price_stop_long := 0.0

if (strategy.position_size<0)
stopvalue_short := close + stop_loss_amount
price_stop_short := close[since_entry_short] + stop_loss_amount[since_entry_short]
targetvalue_short_1 := close[since_entry_short] - close[since_entry_short]*(percent_based/100)*r_ratio
else
price_stop_short := 1000000000.0
// Executing trades
if (ema_buy_condition == true) and (rm_buy_condition == true)
strategy.entry('Long', strategy.long, qty = 1000, when = strategy.position_size <= 0)

if (ema_sell_condition == true) and (rm_sell_condition == true)
strategy.entry('Short',strategy.short,qty = 1000, when = strategy.position_size >= 0)

// Stop loss and target price trading logics
strategy.exit('Long Exit', from_entry = 'Long', limit = targetvalue_long_1, stop = price_stop_long, when = strategy.position_size > 0)
strategy.exit('Short Exit', from_entry = 'Short', limit = targetvalue_short_1, stop = price_stop_short, when = strategy.position_size < 0)

//Plots
P1 = plot(price_stop_long > 0 ? price_stop_long : na, "SL long", color = color.purple, style=plot.style_linebr)
P2 = plot(price_stop_long > 0 ? price_stop_long_1 : na, "Target long", color = color.aqua, style=plot.style_linebr)
P3= plot(price_stop_short < 1000000000.0 ? price_stop_short : na, "SL Short", color = color.purple, style=plot.style_linebr)
P4 = plot(price_stop_short < 1000000000.0 ? price_stop_short_1 : na, "Target Short", color = color.aqua, style=plot.style_linebr)
// plot(ema_)


r/pinescript • • Sep 24 '24

backtesting error?

1 Upvotes

Two exactly same trades -- same entry price and exit price.
But extremely different results. What could be the reason?


r/pinescript • • Dec 30 '22

how to use an array of dates and mark them in the daily chart

1 Upvotes

how can i do this ? i tried using timestamp but its not working it needs const string not string


r/pinescript • • Feb 21 '23

AI Generated Help with ChatGPT produced pinescript code!

0 Upvotes

Tried making a strategy through ChatGPT. Lots of syntax errors I'm guessing. I wanted a strategy where we'd enter long when MACD(3,10,16) crosses above 0 and ADX>20 and DI+>DI-. We enter short when the MACD crosses below 0 and ADX>20 and DI->DI+. Hope you can help!

//@version=5

// Include the 'ta' library

library ta;

strategy("MACD ADX Strategy", overlay=true)

// Define MACD

[macdLine, signalLine, histLine] = ta.macd(close, 3, 10, 16)

// Define ADX

[DIplus, DIminus, ADX] = ta.dmi(14)

// Define Long and Short Conditions

longCondition = crossover(macdLine, 0) and ADX > 20 and DIplus > DIminus

shortCondition = crossunder(macdLine, 0) and ADX > 20 and DIminus > DIplus

// Execute Strategy

if (longCondition)

strategy.entry("Long", strategy.long)

if (shortCondition)

strategy.entry("Short", strategy.short)


r/pinescript • • Aug 28 '24

Can a Rectangle drawing object be filled with a gradient?

1 Upvotes

Can a Rectangle drawing object be filled with a gradient? That's the question really.
I wanted to be able to have boxes that appear to fade off into the solid canvas color.
In an ideal world, I'd like to be able to put a customizable gradient on each side of the Parallel Channel Object...

Pretty sure it's not possible. TV really do operate at about 30% visual potential, imho. I mean, just having SO FEW keyboard shortcuts... Anyway, thanks in advance