Tradingview Strategy - ATR_Supertrend/EMAs

retire020

New member
UPDATED CODE: Below I have updated the code from the original posting. Updated corrected some bugs on 11-10-2021

I put together a strategy based on Money Miner , and Ribbon EMAs, see FXAccurate on youtube Trading Idea where I got the idea. Money miner is basically an ATR supertrend idea, and then I added several EMAs 9,20,34,50,100,200 so for example when Buy signal and the close > EMAs then go long, exit either on Profit target, or stop which is based on Sell signal or a fixed stoploss. I just started learning PineScript and this is my first try at coding it. It works very well on NQ 5 min. You can adjust several settings including qty of contracts/shares.
You are welcome to test it out.
My best TOS strategy is CSA Trend and Momentum strategy that @diazlaz on Usethinkscript, I am going to attempt to write that in PineScript
SupertrendEMAStrategy I made the strategy a link rather than expose it to the google website scraping.
 
Last edited:

retire020

New member
Win rate and PT vary from instrument to instrument , timeframe and date range. There are too many variables to offer a stated win rate etc.. I offered the code so that others can try if they like and comment on it. Since the B4Indicators site seems open to various ideas, I posted just one idea. I think many are looking for ways to take their ideas to whatever platform and be able to see how it performs. here is an example: NQ 5Min Strategy. Please let me know if this kind of posting is okay, as I know you concentrate on the B4 Signals mostly.
 

barbaros

Administrator
Staff member
You are absolutely correct. This site is open to anyone to share any idea or any indicator. I was just wondering if you had any suggestion of success of this strategy for others to get started from. However, I understand the variability of the success rate.
 

retire020

New member
Since posting the code from my original post, I have made some changes and some tweaks. Looking at NQZ2021 on a five minute chart, trading 1 Contract. It does quite good: 10/01/2021 to 11/05/2021
$ 17310.00 17.31 %Net Profit
25 Total Closed Trades
76 % Percent Profitable 3.84 Profit Factor
$ 1735.00 Max Drawdown
I already developed a Tradingview webhook to TDA api and I'm looking at one to Interactive Broker because you can paper trade that and not TDA. My idea good or bad would be to use NQ as the trade condition and actually day trade QQQ options that would be close to the money and not to far from expiration based on day of the week. Per below this was a trade the strategy took that I evaluated a possible option trade.
Trade #TypeSignalDate/TimePriceContractsProfit $Profit %Cum. Profit $QQQRound +1optionpriceSold at HighSold at Signal
1​
Entry LongLONG
10/1/21 13:35​
14714.75​
1​
1240​
0.42​
1240​
359​
360​
QQQ_100421C360
1.57​
$1000​
1​
Exit LongEOD
10/1/21 16:10​
14776.75​
1​
1240​
0.42​
1240​
1.97​
$400​
If anyone has ideas or please see how this code does for yourself. Please share any thoughts.
 

barbaros

Administrator
Staff member
Starting to look at the script. By default, shorts are not enabled. Since we have been in a bull market, not including shorts, it might show better results but for good practice and long term profitability, we need to include the shorts too.

Using NQ1!, the continuous contract on TradingView, equity curve looks good, but the profit factor isn't high. Though this test is from beginning of 9/2021. Profit percentage is higher because the account size was adjusted down to $13k.
m2Py8Yb.png


When shorts are enabled, equity curve doesn't look that well.
cZvOzYz.png


I'll do more testing soon.
 

retire020

New member
Some strategies have a built in bias for trend direction. As it is a supertrend focused strategy it is biased by direction. You must have changed some of the settings to get the results you have displayed. I did the same contract NQ1 and 5 min timeframe for 9/1 to 11/7 2021 and got much stronger results. the Short strategy during Sept 1- Oct 10 when there was a significant downtrend in NQ it locked in $20K in profit. but it all evaporated from Oct 10 till now which has been an uptrend. I guess if you had a broader pulse on the current trend you could adapt the strategy. Like adding Market Forecast on a Daily signal.
 

barbaros

Administrator
Staff member
That was it. I had the chart on 3m instead of 5m.
CfIL9As.png


It is not bad with ES as well.
pbJjLOf.png


I will be curious to see if a higher time frame addition of trend direction can determine if long only or short only. In order to be able to use it handsfree, it will benefit from auto switching.

Good job with implementation. Results look very encouraging.
 

barbaros

Administrator
Staff member
If we expand the date range on NQ
gbfXmJI.png


I wonder if the short only before 9/2021 would benefit more than long only in that period.
 

retire020

New member
Hi all once again updated the code in post 1, we found coding errors/omissions and corrected them. Interesting side note: there is a OIF folder called incoming on NinjaTrader that @thetradeengine made me aware of. So my next project is to webhook to NT a txt file that can open and close positions. I tried to recreate this strategy on NT but not with the same results as Tradingview. So maybe I use TV for the strategy and NT for the order management.
 

barbaros

Administrator
Staff member
Hi all once again updated the code in post 1, we found coding errors/omissions and corrected them. Interesting side note: there is a OIF folder called incoming on NinjaTrader that @thetradeengine made me aware of. So my next project is to webhook to NT a txt file that can open and close positions. I tried to recreate this strategy on NT but not with the same results as Tradingview. So maybe I use TV for the strategy and NT for the order management.
Thank you for the update.

Here is the latest equity curve.
fROUCp1.png
 

zeedent7

New member
Hi all once again updated the code in post 1, we found coding errors/omissions and corrected them. Interesting side note: there is a OIF folder called incoming on NinjaTrader that @thetradeengine made me aware of. So my next project is to webhook to NT a txt file that can open and close positions. I tried to recreate this strategy on NT but not with the same results as Tradingview. So maybe I use TV for the strategy and NT for the order management.
I'm new to coding/trading view

I copied the script into pine editor but I am not getting any results on strategy tester. How do I enable it? Sorry if it is a stupid question
 

retire020

New member
I'm new to coding/trading view

I copied the script into pine editor but I am not getting any results on strategy tester. How do I enable it? Sorry if it is a stupid question
Once you added the pinescript and saved it and then Add to chart, depends on what symbol and timeframe, you can also adjust the date range in settings. it may not work for certain instruments like forex. Try NQZ2021
 

zeedent7

New member
Once you added the pinescript and saved it and then Add to chart, depends on what symbol and timeframe, you can also adjust the date range in settings. it may not work for certain instruments like forex. Try NQZ2021
Thanks! I was on a symbol that wasn't registering trades

What do you use for your stop loss on the script? next sell signal or fixed?

Also would the sell signal come as the price dropped below moving averages or the moneyminer line? Just trying to understand the strat

From the fxaccurate post do you know the script for the emas he has visible on the chart? I can't seem to find the color changing ones
 

retire020

New member
Thanks! I was on a symbol that wasn't registering trades

What do you use for your stop loss on the script? next sell signal or fixed?

Also would the sell signal come as the price dropped below moving averages or the moneyminer line? Just trying to understand the strat

From the fxaccurate post do you know the script for the emas he has visible on the chart? I can't seem to find the color changing ones
profit and stop are a percentage based see inputs, but also it can close on sell signal (money miner sell and squeeze momentum <0 and finally for sure sell EndofDay. So there are several condition money miner is one of them, squeeze momentum another and finally 6 emas being green or red emas are 9,20,34,50,100,200. So the strategy evolved from the money miner and ribbon emas but not strictly using the technique. For the emas in the video = SS EMA / EMA Ribbon stokedstocks
 
Top