ChrisMoody
Education

New Video Tutorials - Coding Custom Indicators - Ask Questions!

FX:EURJPY   Euro Fx/Japanese Yen
I am currently recording a Video Tutorial Series on PineScript...Creating Custom Indicators.

ASK QUESTIONS BELOW....QUESTIONS WILL BE ANSWERED IN ON-GOING VIDEO SERIES.

Each Video will be 10 Minutes in Length, Covering a Specific Topic.

I will Start By Taking A Common Indicator Like the MACD and Starting From The Very Basics, Then Adding In All Customizable Options.

Topics Include:
- The Basics You Need To Know.
- Available Reference Materials.
- Creating Custom Colors Based On Conditions.
- Changing Bar Colors Based On Conditions.
- Using Multi-TimeFrames.
- And More...

We Will Have Guest Appearances From Some Of The Top Coders On TradingView Showing Advanced Techniques!!!

We Will Also Cover Other Types Of Indicators!!!

ASK QUESTIONS BELOW...ANYTHING REGARDING CODING IN PINESCRIPT.

QUESTIONS WILL BE ANSWERED IN VIDEO SERIES.
I have a question, I want to make a custom indicator on a already built-in indicator. Is it possible?
Reply
Hi Chris
I am new at this programming, and my last programming hour was something lige 20 years ago, but I am trying. ;-)
I am trying to make a indicator that combine several indicatores, and it all worked well until I tryed to put ADX and DI into it. Now it don't accept my literals in the ADX and DI section, and >I can't understand why. I have marked the problem with /////PROBLEM///// in the schript behind, but it ids not only line 61, it is also the 7 next literals in the next 7 lines.
Can anybody help me

//@version=3

study(title="Moneymaker", shorttitle="MoMa", precision=0)

//DEMA2
DEMA_length2 = input(26, minval=1)
dema_src2_1 = input(close, title="DEMA 2 Source")
dema_e2_1 = ema(dema_src2_1, DEMA_length2)
dema_e2_2 = ema(dema_e2_1, DEMA_length2)
dema2 = 2 * dema_e2_1 - dema_e2_2
//plot(dema2, color=blue)

//DEMA3
DEMA_length3 = input(50, minval=1)
dema_src3_1 = input(close, title="DEMA 3 Source")
dema_e3_1 = ema(dema_src3_1, DEMA_length3)
dema_e3_2 = ema(dema_e3_1, DEMA_length3)
dema3 = 2 * dema_e3_1 - dema_e3_2
//plot(dema3, color=black)

dema = dema3 < dema2 ? 1 : 0//Sætter variablen til 1 hvis dema3 krydser under dema2

//Volume
showMA = input(true)
barColorsOnPrevClose = input(title="Color bars based on previous close", type=bool, defval=false)//
vol_Open = barColorsOnPrevClose ? close > close ? 0 : 1 : open > close ? 0 : 1 // sætte volume barcode til 1 hvis grøn, eller rød
vol_Spike = volume > sma(volume,20) ? 1 : 0 // Sætte volume barcode til 1 hvis højere end de sidste 20 sma, ellers 0
vol = vol_Spike == 1 and vol_Open == 1 ? 1 : 0 // sætter variabel til 1 hvis både vol_Open og vol_Spike er opfyldt

//MACD
MACDfast = 12, MACDslow = 26
fastMACD = ema(close, MACDfast)
slowMACD = ema(close, MACDslow)
MACD = fastMACD-slowMACD
MACDs = sma(MACD, 9)
//plot(MACD, color=blue)
//plot(MACDs, color=orange)
macd = MACDs < MACD ? 1 : 0

//MFI
length = input(title="Length", type=integer, defval=10, minval=1, maxval=2000)
src = hlc3
upper = sum(volume * (change(src) <= 0 ? 0 : src), length)
lower = sum(volume * (change(src) >= 0 ? 0 : src), length)
mf = rsi(upper, lower)
//plot(mf, color=#459915)
//overbought=hline(80, title="Overbought", color=#c0c0c0)
//oversold=hline(20, title="Oversold", color=#c0c0c0)
//fill(overbought, oversold, color=#9915ff, transp=90)
mfi = mf > 80 ? 1 : 0

//ADX and DI
len = input(title="Length", type=integer, defval=14)
th = input(title="threshold", type=integer, defval=20)

TrueRange = max(max(high-low, abs(high-nz(close))), abs(low-nz(close)))
DirectionalMovementPlus = high-nz(high) > nz(low)-low ? max(high-nz(high), 0): 0
DirectionalMovementMinus = nz(low)-low > high-nz(high) ? max(nz(low)-low, 0): 0

//////////////////////////////////////////////////PROBLEM///////////////////////////////////////////////////////////
SmoothedTrueRange = nz(SmoothedTrueRange) - (nz(SmoothedTrueRange)/len) + TrueRange
//SmoothedDirectionalMovementPlus = nz(SmoothedDirectionalMovementPlus) - (nz(SmoothedDirectionalMovementPlus)/len) + DirectionalMovementPlus
//SmoothedDirectionalMovementMinus = nz(SmoothedDirectionalMovementMinus) - (nz(SmoothedDirectionalMovementMinus)/len) + DirectionalMovementMinus

//DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100
//DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100
//DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100
//ADX = sma(DX, len)

//plot(DIPlus, color=green, title="DI+")
//plot(DIMinus, color=red, title="DI-")
//plot(ADX, color=black, title="ADX")
//hline(th, color=black, linestyle=dashed)

// Setup
MoMa = dema == 1 and vol == 1 and macd == 1 and mfi == 1 ? 1 : 0

//vol_Spike_and_vol_Open_and_dema3_under_dema2 = vol_Spike_and_vol_Open == 1 and dema3_under_dema2 == 1 ? 1 : 0
//vol_Spike_and_vol_Open_and_dema3__under_dema2_and_MACDs_under_MACD = vol_Spike_and_vol_Open_and_dema3_under_dema2 == 1 and MACDsignal < macd ? 1 :0

//plot(vol_Spike_and_vol_Open, color = yellow, style=columns, title="Volume open")
//plot(dema_Cross, color = red, style=columns, title="Dema cross")
//plot(vol_Spike_and_vol_Open_and_dema3_under_dema2, color = red, style=columns, title="Dema cross")
plot(MoMa, color = red, style=columns, title="Dema cross")


Reply
I would like to edit the zigzag indicator
to draw Aline when a finish wave from the zigzag is finished
it will help to draw the supp and res levels for each end of a wave for the zigzag .
Reply
Hi,

Can you please help me out, I'm trying to do a conditional format of the chart background colour when Stoch is above 80 for example. I'm completely new to pine editor

Thanks
Reply
Hello Cris

This one might be easy for you but I am struggling to find the answer.

All I want to know is how to set an alarm if two indicators meet the right standards(?) or set an indicator as the "Rob Rsi Stoch MACD Combo Alert" indicator.

In this case I want the "CM_RSI-2 Strategy Lower Indicator" crossing the 80 or 90 line and the RSI(5) lower than 60,, if that happens an alert would be off or a red(or green) bar would appear the same way as the "Rob Rsi Stoch MACD Combo Alert" as I mentioned.

It must be very simple for you but if your time is not worth it to explain. Could you tell me where to start from please?

Kind Regards,
Keep your awsome Work ;)
Thank you

Reply
Hi Chris

Your posts have been a great source of help for me to develop something of my own using Pine Script. There is one query I have for you. I want to show pivot - support - resistance lines in my custom code only for the current day / session or from a certain number of days before the current day. Standard Pivot Point code in TV library has this feature. But am unable to find a function or set of functions that will enable me to do this. Would be grateful if you can let me know how to do this ?

Syam
Reply
I am new to pinescript and am trying to figure out a simple strategy/alert that would signal an alert if the weekly %k stoch was greater than the previous weeks close AND the daily %K stoch is greater than the previous days close. Is this doable? Thanks
Reply
Hi Chris, not sure if this thread is still being used, but thought I would ask anyway as you seem to be 'the man'. I am having difficulty creating alerts. When my criteria is met, I plot a BUY arrow, and want an alert to occur at the point of the arrow being displayed. I am able to add the alert and condition to some of the currency pairs, but not on some others, because my script does not appear in the 'condition' list of the alert creation screen. My code for the alert is :

alertcondition(Trend == 1 and Trend == -1, "BUY", "BUY")
plotarrow(Trend == 1 and Trend == -1? Trend : na, title="Up Entry Arrow", colorup=green, maxheight=1000, minheight=50, transp=40)
alertcondition(Trend == -1 and Trend == 1, "SELL", "SELL")
plotarrow(Trend == -1 and Trend == 1 ? Trend : na, title="Down Entry Arrow", colordown=red, maxheight=1000, minheight=50, transp=40)

Any help very much appreciated.
Reply
Need help creating pine script to indicate 1atr value below and 3 atr value above price entry .

can you help me create a pine script that shows a line at 1 atr value below my price entry# and 3 atr value above the same price entry#.

for example: i want to buy a stock at 1.00, the atr value at 1.00 is 0.20. there for i would like an indicator to draw a line at 0.80 and 1.60.

Thank you
Reply
Hey Chris - all great stuff.

I wonder if you know how to create custom indicators for strategies, as you can't pull them in in the same way you can for Study() scripts even if you plot them as boolean indicators on overlays.

The real problem I have is that the strategy position indicators are one bar old and don't get rendered until the next bar, so custom alerts of some form seem necessary. Also in my case, I want "take profits" signals which requires position sizing calculations from the strategy itself so can't just create a separate study() for the underlying indicators.

Also, whilst I'm bothering you... do you know if it's possible to pull in data series from external indicators you don't have the source code for? I saw your post ages ago on the lunar cycles and thought it would be fun to see how that affected my back testing, but I'm not especially keen to manually code in lunar cycle dates back to the year 2000 so want to pivot off the built-in MP indicator in my strategy.

Cheers,

N
Reply
United States
United Kingdom
India
Deutschland
France
España
Italia
Polska
Türkiye
Россия
Brasil
Indonesia
Malaysia
Việt Nam
日本
한국
简体
繁體
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Priority Support Contact Support Ideas Published Followers Following Private Messages Chat Sign Out