TradingView
NigglesSquiggles
Mar 19, 2018 1:56 AM

PT_MA Cross Visualiser 

EOS / EthereumBinance

Description

This indicator is designed for use with Profit Trailer's CROSS strategies.
The user can select either EMA or SMA averages and input their own buy value settings.

Release Notes

I had a request to add a "Tip Jar" for those who wanted to express their thanks for these indicators.
So if you want to say thanks, then you're welcome:

LTC Tip Jar: LX4bUBdjiRPsagUbZoAczSGgDC4YqTJL7w
Comments
southnjes
Been kinda testing this on a normal chart for ease of viewing. I had something similar but I liked the extra functions you had. I tried to modify the code a litte (I'm a complete non coder and sit and just try to get it to work),but I couldn't. Essentially. On my original script I had. The values gave me a red bar as well as the green to see the crossdowns. On this one I never get a cross down red bar even with adding some to your code. I figure that it's just a rewrite and copy paste of a certain section in the code but I'm not sure if it is correct. I think it works though.

Any chance you could add this into it or check the code below that is yours with the added bit and tell me if this is done correctly giving the correct output? Some areas where I see a cross down, there is no red bar.

As a new trader I like to have this visual on the chart but I would like it to be accurate.

Thanks for all you do on the teaching. I've learned that anything other than idiot proof coding is just not for me.:)

//@version=2
// Created 2018 - by @squiggles#8806
// LTC Tip Jar: LX4bUBdjiRPsagUbZoAczSGgDC4YqTJL7w
//
study(title="PT_MA Cross Visualiser", shorttitle = "PT_CrossVis", overlay=true, precision=8)
maSLOWLen = input(100, title="Slow MA Length")
maFASTLen = input(7, title="Fast MA Length")
useEXP = input(true, title="Use Expontential")
MA_Cross_Candles = input(2, title="MA Cross Candles")
Buy_Value = input(0.05, title="Buy Value")
Sell_Value = input(0.05, title="Sell Value")

smaFast = sma(close, maFASTLen)
smaSlow = sma(close, maSLOWLen)
emaFast = ema(close, maFASTLen)
emaSlow = ema(close, maSLOWLen)

maFast = useEXP ? emaFast : smaFast
maSlow = useEXP ? emaSlow : smaSlow

// spread calculations
sprd = ((maFast/maSlow)-1) * 100
sprd1 = ((maFast/maSlow)+1) * 0

Buy_Condition(spread, candles, buyValue) =>
sprdCond = buyValue > 0 ? spread > buyValue : spread < buyValue
for i = 1 to candles
sprdCond := buyValue > 0 ? spread > buyValue and crossover(maFast, maSlow) : spread < buyValue and crossunder(maFast, maSlow)
sprdCond

Condition_Met = Buy_Condition(sprd, MA_Cross_Candles, Buy_Value)

Sell_Condition(spread, candles, sellValue) =>
sprdCond1 = sellValue > 100 ? spread > sellValue : spread < sellValue
for i = 1 to candles
sprdCond1 := sellValue > 100 ? spread > sellValue and crossunder(maFast, maSlow) : spread < sellValue and crossover(maFast, maSlow)
sprdCond1

Condition_Met1 = Sell_Condition(sprd, MA_Cross_Candles, Sell_Value)

bgcolor(Condition_Met ? lime : na, transp=50, title="Cross")
bgcolor(Condition_Met1 ? red : na, transp=50, title="Cross")
plot(maSlow,title="MA1 Slow", color = red, linewidth = 1, transp=0)
plot(maFast,title="MA2 Fast", color = aqua, linewidth = 1, transp=0)


More