Pine Script Tutorial | Developing Real Trading Strategies On TradingView

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ม.ค. 2025

ความคิดเห็น • 383

  • @EarlWallaceNYC
    @EarlWallaceNYC ปีที่แล้ว +7

    As an experienced python programmer, this format and pace was just right for me. Many Thanks.

  • @jeremyberker8482
    @jeremyberker8482 20 วันที่ผ่านมา +1

    Just went to your full tutorial with code and WOW. I can tell you put allot of time in to it and it seems very well thought out and easy to follow. I will be spending some time on that site learning. Thanks for all of the time you put in to this.

  • @DIYerGirl
    @DIYerGirl ปีที่แล้ว +7

    I just discovered your video, and it was very easy to understand. It was well-organized and clearly explained. I'm new to Pine scripting. so I'm saving this to my playlist. Thanks!

  • @vinybaba493
    @vinybaba493 ปีที่แล้ว +7

    I am not from a coding background(wanna be), but the way you explained everything is really good. Thanks.

    • @kevin.licenji
      @kevin.licenji ปีที่แล้ว

      Hey Viny, if you're still interested in Pinescript, I wanted to let you know about a software I've created that automates the backtesting of strategies in thousands of different scenarios. Once you input your strategy into the software, it tests it on dozens of different assets and timeframes to see where it performs best. So, with just one command, you can backtest your strategy not only on one pair or commodity, but on dozens of them, including stocks, cryptocurrencies, and more.
      But the best part is that the software can also change the variables in your script. For example, it can find the perfect value for your stop loss and take profit in different scenarios or try dozens of different values for moving averages, MACD, RSI, ATR, Bollinger Bands, or any indicator you're using.
      The results are incredible because with just one command, you get thousands of different combinations for your strategy without having to do anything. And it's 100% safe that you'll find a setting that performs better than the one you were using by default. Why? Because every strategy can be fine-tuned by trying better values for the indicators, or because it's a strategy that doesn't work well on the asset you're using but performs great on another one, or it performs better on a different timeframe than the one you usually use.
      I'm also subscribed to TradingView's Premium plan, which allows me to backtest with all the data available on the platform, going back 50 years for daily candles and 22 years for 30-minute candles.
      If you want to check it out, I invite you to visit my Fiverr page. As I found you, I'll give you the first round for free, where I'll provide you with the results of your strategy in 100 different scenarios, and you'll immediately see how powerful it is. I always deliver a file with the raw data table and an Excel file with graphs and filters to quickly find the most performing strategies among the thousands tested.
      You can find me on Fiverr by searching for "I will automate thousands of backtests." If you see more than one person, look for the one with the username "codingtrading." Feel free to message me there, even just to give me your thoughts, as I'm new to the platform. Thanks a lot!

  • @AlvinEvangelista
    @AlvinEvangelista 3 ปีที่แล้ว +28

    Excellent crash course, answered pretty much all the questions I had from other Pine Script videos. Thanks for the detailed info.

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว +1

      Thank you

    • @aldolabuonora
      @aldolabuonora 3 ปีที่แล้ว

      @@JamesBachini hi James, excellent video!! I m looking for someone who developes some strategies in trading view.
      Do you work for clients?

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว +1

      @@aldolabuonora I don't sorry. Might find someone upwork or freelancer if you search for pinescript. Alternatively there's a big public library you can use to search for a similarish strategy and try and contact the author who will understand it.

  • @alexp7274
    @alexp7274 11 หลายเดือนก่อน +3

    Nice video. 5:12 I suggest to re-edit this part to take out FTX

    • @JamesBachini
      @JamesBachini  11 หลายเดือนก่อน

      Good point, if only it was possible to edit TH-cam vids)

  • @rohitkashyapx
    @rohitkashyapx 3 ปีที่แล้ว +6

    Amazing! Thank you so much for the video. An extremely underrated channel in my opinion

  • @hksoros
    @hksoros ปีที่แล้ว +4

    mad respect for you james, this is the best, right to the point pinescript tutorial i need!

  • @sebastianllosa12
    @sebastianllosa12 3 ปีที่แล้ว +5

    This is the first time I give a like, subscribe and leave a comment in a video, but this kind of information certainly deserves it. Truly amazing content!!! Thank you and keep up with the good work!

    • @kevin.licenji
      @kevin.licenji ปีที่แล้ว

      Hey man, if you're still interested in Pinescript, I wanted to let you know about a software I've created that automates the backtesting of strategies in thousands of different scenarios. Once you input your strategy into the software, it tests it on dozens of different assets and timeframes to see where it performs best. So, with just one command, you can backtest your strategy not only on one pair or commodity, but on dozens of them, including stocks, cryptocurrencies, and more.
      But the best part is that the software can also change the variables in your script. For example, it can find the perfect value for your stop loss and take profit in different scenarios or try dozens of different values for moving averages, MACD, RSI, ATR, Bollinger Bands, or any indicator you're using.
      The results are incredible because with just one command, you get thousands of different combinations for your strategy without having to do anything. And it's 100% safe that you'll find a setting that performs better than the one you were using by default. Why? Because every strategy can be fine-tuned by trying better values for the indicators, or because it's a strategy that doesn't work well on the asset you're using but performs great on another one, or it performs better on a different timeframe than the one you usually use.
      I'm also subscribed to TradingView's Premium plan, which allows me to backtest with all the data available on the platform, going back 50 years for daily candles and 22 years for 30-minute candles.
      If you want to check it out, I invite you to visit my Fiverr page. As I found you, I'll give you the first round for free, where I'll provide you with the results of your strategy in 100 different scenarios, and you'll immediately see how powerful it is. I always deliver a file with the raw data table and an Excel file with graphs and filters to quickly find the most performing strategies among the thousands tested.
      You can find me on Fiverr by searching for "I will automate thousands of backtests." If you see more than one person, look for the one with the username "codingtrading." Feel free to message me there, even just to give me your thoughts, as I'm new to the platform. Thanks a lot!

  • @hypercub3
    @hypercub3 3 ปีที่แล้ว +1

    What a helpful video!
    I was able to completely create my strategy with the help of your video.
    Thanks from Korea.

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว +1

      Awesome, hope it's profitable for you 👍

  • @bree3073
    @bree3073 3 ปีที่แล้ว +2

    Excellent is the best word for this... now I learned pine script in about ten minutes....great job! Very interesting the last minutes how to create a javascript file for advanced doing...I ll read all on your site!

  • @sundancer06
    @sundancer06 2 ปีที่แล้ว +2

    i cant believe you gave us a treasure..thank you so much

  • @ibrahimcelebi1366
    @ibrahimcelebi1366 3 ปีที่แล้ว +2

    super genuine information in short time ! thankxx

  • @RaghavaIndra
    @RaghavaIndra ปีที่แล้ว +2

    Amazing explanation of pine scripting concept. Thanks a lot.

  • @curiouskittycat5977
    @curiouskittycat5977 9 หลายเดือนก่อน +1

    Awesome video. The chop is the problem. How to recognize it programmatically and switch strategy or at least stop trading is the question. Thank you for sharing your knowledge. excited to check out your other videos.

    • @JamesBachini
      @JamesBachini  9 หลายเดือนก่อน +1

      Recognising what stage the market is in and adjusting focus on mean reversion strategies in choppy conditions and trend following strategies when there is momentum. Things like volatility indexes and distance from long term moving averages can help alongside market sentiment checks.

  • @mladenpavla
    @mladenpavla 3 ปีที่แล้ว +4

    Thanks James, no doubt this channel will grow!!!

  • @javidafkar
    @javidafkar 3 ปีที่แล้ว +2

    Excellent. Thanks for the detailed info.

  • @mirrorcube3709
    @mirrorcube3709 3 ปีที่แล้ว +3

    excellent and concise info. thank you

  • @stephonhenry-rerrie3997
    @stephonhenry-rerrie3997 หลายเดือนก่อน +1

    thanks for sharing this. very helpful

  • @marci1964
    @marci1964 2 ปีที่แล้ว +2

    Brilliant video - thanks!

  • @cmzshalom
    @cmzshalom 3 ปีที่แล้ว +3

    Subscribed. Liked.
    And thank you!
    First video I watched as a total beginner and it really gave the overview I was looking for exactly. Many thanks 🙏

  • @LightchaserG
    @LightchaserG 2 ปีที่แล้ว +2

    Thank you, James, appreciate the share and learnings.
    Keep it up, really good the way you explain.

  • @KamalSingh
    @KamalSingh 3 ปีที่แล้ว +7

    Good tutorial at the right pace and details!

    • @kevin.licenji
      @kevin.licenji ปีที่แล้ว

      Hey man, if you're interested in Pinescript, I wanted to let you know about a software I've created that automates the backtesting of strategies in thousands of different scenarios. Once you input your strategy into the software, it tests it on dozens of different assets and timeframes to see where it performs best. So, with just one command, you can backtest your strategy not only on one pair or commodity, but on dozens of them, including stocks, cryptocurrencies, and more.
      But the best part is that the software can also change the variables in your script. For example, it can find the perfect value for your stop loss and take profit in different scenarios or try dozens of different values for moving averages, MACD, RSI, ATR, Bollinger Bands, or any indicator you're using.
      The results are incredible because with just one command, you get thousands of different combinations for your strategy without having to do anything. And it's 100% safe that you'll find a setting that performs better than the one you were using by default. Why? Because every strategy can be fine-tuned by trying better values for the indicators, or because it's a strategy that doesn't work well on the asset you're using but performs great on another one, or it performs better on a different timeframe than the one you usually use.
      I'm also subscribed to TradingView's Premium plan, which allows me to backtest with all the data available on the platform, going back 50 years for daily candles and 22 years for 30-minute candles.
      If you want to check it out, I invite you to visit my Fiverr page. As I found you, I'll give you the first round for free, where I'll provide you with the results of your strategy in 100 different scenarios, and you'll immediately see how powerful it is. I always deliver a file with the raw data table and an Excel file with graphs and filters to quickly find the most performing strategies among the thousands tested.
      You can find me on Fiverr by searching for "I will automate thousands of backtests." If you see more than one person, look for the one with the username "codingtrading." Feel free to message me there, even just to give me your thoughts, as I'm new to the platform. Thanks a lot!

  • @matiaswoiciechowski9356
    @matiaswoiciechowski9356 2 ปีที่แล้ว +1

    Man you are A W E S O M E thank you so much for this

  • @mataloha
    @mataloha ปีที่แล้ว +1

    this is a good and simple explanation

  • @Fahad-jh1zw
    @Fahad-jh1zw 3 ปีที่แล้ว +1

    best pine script explanation

  • @arcdisney
    @arcdisney ปีที่แล้ว +1

    thank you the knowledge is very helpful for beginners like me

  • @yoonesgholamy6417
    @yoonesgholamy6417 3 ปีที่แล้ว +1

    I like this tutorial , great job

  • @SeasonedDev
    @SeasonedDev 3 ปีที่แล้ว +5

    Hi James, I like this video, keep doing your great job

  • @neilwu4781
    @neilwu4781 ปีที่แล้ว

    Great video! Thanks James.

  • @nws4714
    @nws4714 3 ปีที่แล้ว +2

    super helpful video! thank you so much!

  • @trader8880
    @trader8880 3 ปีที่แล้ว +1

    This really helped reduce the learning curve

  • @GlynisDance
    @GlynisDance 2 ปีที่แล้ว +1

    Your videos really are very helpful - thank you! :)

  • @khumofx1838
    @khumofx1838 2 ปีที่แล้ว +8

    Hi James, thank you for the awesome content you put together. much respect for the way you presented and how all the concept you delivering come together at the end. Screen visual was not so good though, i hope you take it well for improvement. Overall, brilliant video. Thanks once again.

  • @arjundhaigude9579
    @arjundhaigude9579 ปีที่แล้ว +1

    thanks for sharing valuable information. I need to develop pine script for session volume profile strategy, can you please guide me. Thanks.

    • @JamesBachini
      @JamesBachini  ปีที่แล้ว

      Start with the docs you can pull volume data and then start to work with it to develop your strategy

  • @rbbtllc1146
    @rbbtllc1146 3 ปีที่แล้ว +2

    WOW and thank you!!!

  • @naqijamal9933
    @naqijamal9933 ปีที่แล้ว +2

    Thank you!

  • @gillyOO7
    @gillyOO7 6 หลายเดือนก่อน +3

    Chat GPT does pinescript real well. Was looking at using capitalize AI strategys

    • @theslayer962
      @theslayer962 2 หลายเดือนก่อน

      Hell yeah dude I just made one

    • @Personwithquestions
      @Personwithquestions 2 หลายเดือนก่อน

      They keep giving me errors.

  • @SAKOLPLY
    @SAKOLPLY 3 ปีที่แล้ว +1

    It's very nice content , well explain

  • @jimkoblick1776
    @jimkoblick1776 3 ปีที่แล้ว +2

    Perfect Thanks !!

  • @qadir03232803023
    @qadir03232803023 3 ปีที่แล้ว +1

    Great video bro.

  • @deejaydaiel9181
    @deejaydaiel9181 2 ปีที่แล้ว +1

    Great video! Could you please make an updated video for version 5?

  • @caruntualexandru
    @caruntualexandru 3 ปีที่แล้ว +1

    nice work!

  • @derrickchow4019
    @derrickchow4019 2 หลายเดือนก่อน

    Hi, pls advise how to write "forecast" pine on tradingview. Thanks

  • @dabbopabblo
    @dabbopabblo 3 ปีที่แล้ว +1

    this has been very helpful, only thing I gotta say is maybe turn the white balance down cause it looks like you have a tanning and albino filter on at the same time

  • @NK-lp2bj
    @NK-lp2bj ปีที่แล้ว +1

    Hi could you please create a video about hicknachi strategy code, need high time frame with green to red and red to green based long and short

  • @hanialadmaai5596
    @hanialadmaai5596 2 ปีที่แล้ว +3

    Thank you for the great video. However, I faced an issue at the beginning as I got an error "line 5: Could not find function or function reference 'study'."

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว +2

      Try upgrading the code to v5
      www.tradingview.com/pine-script-docs/en/v5/migration_guides/To_Pine_version_5.html

  • @ameneh212
    @ameneh212 ปีที่แล้ว +1

    Thanks a lot!!

  • @Berghiker
    @Berghiker 2 ปีที่แล้ว +1

    How do I program it to sell after it made for example, 100 cents? My entry is after the moving average crosses over another MA.

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว +1

      Store the entry price in a variable and then check on each candle if price > entry +100

    • @Berghiker
      @Berghiker 2 ปีที่แล้ว

      @@JamesBachini Thanks.

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว +1

      @@Berghiker here's some code that shows how to do stop losses and take profits. You can use this as a base and adjust it to whatever you need.

  • @rbbtllc1146
    @rbbtllc1146 3 ปีที่แล้ว +1

    Have you been able to add sound alerts (beep) to your crossover points? Thank you

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว +1

      I haven't tried, but sounds like a fun script. I have notifications setup to the mobile app and that works well.

  • @davidjulien236
    @davidjulien236 ปีที่แล้ว +1

    Awesome.

  • @pilotpug
    @pilotpug ปีที่แล้ว

    Excellent vid, thx

  • @Berghiker
    @Berghiker 2 ปีที่แล้ว +1

    How do I change the stopLoss from percent to cents or ticks?

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว +1

      Set a variable for your entry and the check if the current price is $0.0x away from your entry

  • @stansuen8072
    @stansuen8072 2 ปีที่แล้ว +2

    James, great video! Direct to the point, swift and not boring and useful!
    If we are to build our own server for live algo trading using python, which framework would you use? Backtrader, VectorQT...etc? (I am just a beginning willing to spend much time to learn. Just want to find the right direction to invest my learning hours)

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว +3

      If I was doing it I would just connect directly to the exchange api using rest or websockets. Each exchange is different but in crypto markets you can get data and post trades quite easily.

    • @shadabahamad1250
      @shadabahamad1250 ปีที่แล้ว

      @@JamesBachini (williams Fractals) tredingview indicator's convert the signals of this pinscript into a script that gives signals one minute in advance

  • @ssjmnews9997
    @ssjmnews9997 2 ปีที่แล้ว +1

    Nice video

  • @joshuam2341
    @joshuam2341 3 ปีที่แล้ว +1

    Thank you.

  • @HereIsmarcus
    @HereIsmarcus 3 ปีที่แล้ว +1

    Great intro. Thanks so much. I have experience with javascript , java , C , VB -What language do yo recommend I learn to code a forex bot connected to Pepperstone for example ?

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว

      I'm not familiar with Pepperstone but check the API and see what wrappers they have. Probably NodeJS using JavaScript would be a good choice as a simple scripting language. That's what I use so probably have a bias here.
      If you are doing very low time frame quant stuff where speed is essential then there might be some benefit to using C.
      Only other factor would be if you are looking at doing a lot of machine learning work in which python is normally the weapon of choice.
      Probably overcomplicating a simple question. My general recommendation would be JavaScript using NodeJS. Can run it locally to start with and then migrate to a server or microservice for production.

    • @HereIsmarcus
      @HereIsmarcus 3 ปีที่แล้ว +1

      @@JamesBachini Thankyou. That's very helpful.

  • @bayfundamental
    @bayfundamental 2 ปีที่แล้ว +2

    Hey James, where do you run your nodes? On your pc 7/24 or any cloud server to advice?

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว +1

      I generally start with them running locally because I'm breaking/tweaking things constantly and then once they are fairly stable I'll migrate them to a secure environment.

  • @kingali0011
    @kingali0011 6 หลายเดือนก่อน +1

    Can you create ICT unicorn model strategy pine script

  • @ธนพลเอกศรีรุ่งโรจน์

    That awesome, I love this kind of video. Do you have any pine script tutorial more?

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว

      No that was the only one. I'll try and get some more recorded. Thank you

    • @lasvegasbrad
      @lasvegasbrad 3 ปีที่แล้ว

      @@JamesBachini , wow, I was ready to pay $$ for your info! Please tell us how your trading is going. With BTC and ETH at all time highs now, you should be rich!

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว

      @@lasvegasbrad no complaints. Euphoric with markets at all time highs 👍

  • @lalitlkv07
    @lalitlkv07 ปีที่แล้ว +1

    Thanks 🙏

  • @heltontorrini33
    @heltontorrini33 3 หลายเดือนก่อน

    Hey, good evening! I am from another country, very poor! I found it very exciting to watch this video and everything else! I couldn't understand 100%, and I would like to know if it's possible to get this script somehow?

    • @JamesBachini
      @JamesBachini  3 หลายเดือนก่อน

      Link to code in the description

  • @jb9282
    @jb9282 3 ปีที่แล้ว

    hey nice video ! one question : how to add a price deviation for entry and exit - for more realistic simulation on TV.
    Tahnk you :)

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว

      You can set a slippage amount when defining the strategy. Is that kind of what you are looking for or could you make it work?
      More info here:
      www.tradingcode.net/tradingview/strategy-slippage-setting/

  • @deniz9974
    @deniz9974 3 ปีที่แล้ว

    Great tutorial. How can we define the position size (cash) which is variable value for each order?
    when i try this, it calculates different size:
    strategy(title="xxx", overlay=true, initial_capital=1000, default_qty_type=strategy.cash, default_qty_value=1)
    strategy.entry("Long", strategy.long, when=long_condition, qty=position_size)
    the "position_size" is a float value which i calculated with risk management.

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว +1

      I think it's qty in the entry function
      strategy.entry(id="foo", long=true, qty=50)

    • @deniz9974
      @deniz9974 3 ปีที่แล้ว

      @@JamesBachini I got it. "calc_on_every_tick=false" makes the differance between my qty and realtime qty 😁. When it's true, the calcs are ok. Thanks for the reply

  • @RahulSahu-ob8iv
    @RahulSahu-ob8iv 3 ปีที่แล้ว

    Kindly publish video on Moving average crossover with martingale position sizing.. thanks

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว

      Cross over is pretty straight forward
      if ta.ma(30,close) > ta.ma(200,close)
      Martingale might be a bit more difficult and not sure I understand it well enough to have any conviction.

  • @aamersaeed1529
    @aamersaeed1529 2 ปีที่แล้ว

    I want to check if 3,4,5 candles closed within the body of previous candle(this candle is slightly bigger than other candles)

  • @DG10-youtube-channel
    @DG10-youtube-channel 2 ปีที่แล้ว +1

    Hi James, many thanks for the lesson. One question can I using pine script monitor several symbols? Let's say I am looking 50 different assets: is there a way in pine script to get a alert for when any of those 50 papers cross a moving average for example... again many thanks

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว +1

      No the alerts are a bit intentionally awkward in my opinion. You would need to set one up every 3 months for each asset. I think there is a limit on the number of alerts you can have too based on your fee tier. I guess it's done this way to protect system resources but it makes it awkward to build out a custom screener/alert system like what you are after.
      I'd suggest if you want to do it get the data from somewhere else like Tiingo and set up a custom script with alerts on something like Twilio.

  • @gavirtualhustle6572
    @gavirtualhustle6572 2 หลายเดือนก่อน

    nice..how i can try to use this strat..thanks

  • @dailyshorts8989
    @dailyshorts8989 3 ปีที่แล้ว

    thank you for your effort, I have a question, How Can we convert mt4 or mt5 indicators or templates to Tradingview?? How we use them in tradingview??

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว +1

      I don't know of any automated way. Probably need to recode them

    • @dailyshorts8989
      @dailyshorts8989 3 ปีที่แล้ว +1

      @@JamesBachini thank you for answer sir

  • @nguyenanhvu7345
    @nguyenanhvu7345 2 ปีที่แล้ว

    Please make a video tell me how to create source "Previous Indicator's Data" for RSI similar as MT4

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว

      I don't think there's a way to do that sorry. You would probably need to combine the two indicators into a single script

  • @johndough8699
    @johndough8699 3 ปีที่แล้ว

    I was thinking of writing my own advisor in MT5. It looks like TV might be a better and more modern solution.

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว

      I think it's fine for visualising data but mt5 or just a script might be better for actually executing the trades

  • @adithya-elearning
    @adithya-elearning 2 หลายเดือนก่อน

    Do you help to create one single indicator combination of 6 indicators

  • @RajeshB65
    @RajeshB65 3 ปีที่แล้ว

    Hey James,
    Thanks for the video tutorial.
    I am looking for functionality like below-
    User mouse over any candle and a new label will display over it showing the difference between open and close price.
    It can be already completed candles or running candle.

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว +1

      I've not seen code to do onhover before. That doesn't mean it's not possible just that I've never seen it. Start with Google or if you've seen another inidcator using it check the code.
      The labels themselves are quite straightforward to do what you want. Something like this.
      label.set_text(close - open)
      I'm just not sure if it's possible to get them to display only on candle mouse over.

    • @RajeshB65
      @RajeshB65 3 ปีที่แล้ว

      @@JamesBachini thanks for the reply..
      I think there must be something in pine script that will allow us to do that because when we mouse over any candle the at top you can see open, close, high, low values.
      Not sure if such kinda functionality also available in pine..
      But I guess there should be..

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว +1

      @@RajeshB65 you've probably hit the nail on the head there. There's quite a lot that should be in pinescript but isn't. It's a compromise between having a powerful scripting language and keeping as simple as possible. I saw they added tooltips recently but I don't think that can be used on candles. Might be worth putting in a feature request if you can't find a way to do it.
      One way you could potentially do something similar is to just output the current candle to a label. Another way would be to plot a chart of the open - close price difference. So you'd have another line over the top which would show values. Not ideal but maybe a viable workaround doing something like this.

    • @RajeshB65
      @RajeshB65 3 ปีที่แล้ว +1

      @@JamesBachini yeah!
      I am successfully able to do that..

  • @jleoarsenault6107
    @jleoarsenault6107 3 ปีที่แล้ว

    what is best time frame to you this code on?? Do you have any public that u can use on US stock market?? thanks great video

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว

      It really depends on the situation and volatility of the traded asset. In theory it will work with stocks but you may want to fit the moving average to the data and backtest each stock individually.

  • @nickkarafillidis4637
    @nickkarafillidis4637 3 ปีที่แล้ว

    excellent!! how about short?

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว

      strategy.entry("sell", strategy.short, 10, when=whatever > 0)

  • @Berghiker
    @Berghiker ปีที่แล้ว

    How do you plot the number of the length of the candle(low to high) above the candle?

  • @amywachsmuth4293
    @amywachsmuth4293 3 ปีที่แล้ว

    Great video.
    Is there a way to script /know if current candle is higher on current close vs highest in Premarket same as if lower ?? Can u create
    A filter for this ??

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว

      I mainly trade crypto so it's open 247. I would hazard a guess that you need to get premarket data from somewhere and the use the time function to put in the market trading hours or something like that. I vaguely remember an update recently from the pinescript Devs about a specific function to give true or false if it's in trading hours so might be worth googling that. But generally I don't use it so can't help, sorry.

  • @RajeshB65
    @RajeshB65 3 ปีที่แล้ว

    Hi James,
    Do you know what technology stack is used behind tradingview.
    I mean to say when we can see price is updating real time without any ajax call.
    I would like to know what is used behind it.

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว

      I assume web sockets but don't know for sure

  • @kltaito
    @kltaito 2 ปีที่แล้ว

    Hello! Great video. I was wondering if there is a way to combine EMAs with an indicator? Like the Ttm squeeze, RSI, or stochastic?

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว +1

      yeah it's quite simple to do you just use an if statement with multiple checks
      if (ta.ema(source, length) and ta.rsi(source, length)) {
      // do whatever here
      }
      Something like that I think from memory. Or you might need to do it like
      FilterOK = false
      Filter1 = close > open
      Filter2 = rising(volume,1)
      FilterOK := Filter1 and Filter2

    • @kltaito
      @kltaito 2 ปีที่แล้ว

      @@JamesBachini ok thank you

  • @sorooshd7895
    @sorooshd7895 5 หลายเดือนก่อน

    thanks for the video James, I'm new to this and want to modify an existing indicator on Tradingview but not quite sure how to do it. Specifically, I want to use the existing Stochastic Momentum Index to get the same alerts on crossings of SMI & SMI-based EMA but add a condition to get those alerts only when crossing happens in the oversold or overbought region. Do you know how I can add this condition? Should the pine code be changed from indicator to study or strategy and rewritten or is there an easier way to modify it? thanks

    • @JamesBachini
      @JamesBachini  5 หลายเดือนก่อน +1

      You could maybe use something simple like RSI to check if it's overbought or oversold and add a condition for that when popping the alert? Combine it with something like this www.google.com/amp/s/zenandtheartoftrading.com/pinescript/generate-trading-signals-with-rsi/%3famp

    • @sorooshd7895
      @sorooshd7895 5 หลายเดือนก่อน +1

      @@JamesBachini thanks for the reply, I’ll check it out!

  • @mkjeffrey4355
    @mkjeffrey4355 6 หลายเดือนก่อน +1

    Hi my name is Jeffrey
    Please I would like to know how to setup TLM trading view strategies

  • @ICARTEN
    @ICARTEN 3 ปีที่แล้ว

    Awesome and clean explanation.
    Quick question, what code should i use to exit when a condition that involve last 7 candles stops being true?
    Thanks in advance and keep up the good content :)

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว +1

      Thank you!
      You can use something like strategy.close(all); which will close any open trades

  • @thangbach6705
    @thangbach6705 3 ปีที่แล้ว +1

    thank you

  • @memarket1675
    @memarket1675 2 ปีที่แล้ว +1

    Can't see the code in phone screen it's too tiny. Please zoom on the code.

  • @batz9672
    @batz9672 2 ปีที่แล้ว

    Hi James, how to remove the choppy signals, when the market is ranging? Thanks

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว

      Wait for a breakout 😉
      When the market is ranging mean reversion strategies tend to work better than trend following. Usually volatility and trading volumes are lower too which makes it more difficult than upOnly market mode.

  • @slimfit9605
    @slimfit9605 2 ปีที่แล้ว

    hello how can we encode the result "5 days ATR value * 2 + 5 days EMA value = result" as a horizontal straight line on the chart?

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว

      I don't think it can be a horizontal line because it would change as the daily value changes

  • @iMajedaldhafer
    @iMajedaldhafer 3 ปีที่แล้ว

    Thanks James. Is it possible to create alerts when condition is fulfilled regardless of ticker name? for example: I want to receive an alert for any symbol that it MA7 crosses up its MA20 (1 day interval).

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว +1

      Only way I've seen to do it is to set one alarm per ticker

    • @iMajedaldhafer
      @iMajedaldhafer 3 ปีที่แล้ว

      @@JamesBachini Thanks again James

  • @chrisjones4512
    @chrisjones4512 2 ปีที่แล้ว

    James is there anyway to set up an alert for all stocks that meet a specific crossover ? Example if apple 20 crosses the 100 ema then i would automatically get an alert. But i want if for all stocks this happen for not just one stock. Any idea? Thanks in advance this video was pure gold!

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว

      It's possible. Bad news is you need to set up each stock individually. There are a million and one prebuilt ma crossover strategies in the library. Choose one which includes an alert in the code and then set that alert up as an alarm for each market you want to trade.

  • @fabriziomeli2161
    @fabriziomeli2161 2 ปีที่แล้ว

    Hi James, excellent video. I have one question? In wich way can I connect my Pinescript strategy to FTX exchange? I want to do like an automatically trading trough the strategy. But I can't find a tutorial, I can't connect the strategy to the exchange, thank you

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว

      Pinescript isn't great for execution. I would recommend using a separate script which interacts with the FTX API to collect data and manage orders/positions

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว

      Example code here
      jamesbachini.com/order-execution-strategy/

    • @samiab6077
      @samiab6077 2 ปีที่แล้ว

      @@JamesBachini
      Did you get burned with FTX? I did :'(

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว

      @@samiab6077 yes I had some FTT on there :"(

  • @facepalmjesus1608
    @facepalmjesus1608 2 หลายเดือนก่อน +1

    i have created an indicator and turned it to strategy but when i load it to strategy tester it does not take any trades. i dont know how to proceed

    • @JamesBachini
      @JamesBachini  2 หลายเดือนก่อน

      If you've tried it against multiple markets and timeframes I expect it's something to do with the condition where it opens the trade. Hard to advise more but you could probably put it into chatGPT and ask why isn't this taking any trades

  • @jleoarsenault6107
    @jleoarsenault6107 3 ปีที่แล้ว

    Do you know or have done a video on Pivots traditiona auto that could tell when a ticker cross say S/R 1 or 2 ?

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว

      I haven't had much experience with that sorry 🤷‍♂️

  • @shamalmohammed4857
    @shamalmohammed4857 3 ปีที่แล้ว

    Thank you for your video, can you create an alert script for percent slope of sinko span line A and B inside Ichimuko indicator ? It will be so great job, because as you know if the above mentioned lines pointing up or down they tell us where the market will going . Regards

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว +2

      You could try looking in the Tradingview indicator/strategy library. Ichimuko is pretty widely used so there should be something that does what you are looking for or could be modified to.

  • @Berghiker
    @Berghiker 2 ปีที่แล้ว

    How do I plot a line for the long stop loss? Do I need to use something like line.set_x1? It's asking me for a value.

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว

      Set a variable for the stop loss price when you place an order and plot a line using that

  • @polytech7862
    @polytech7862 3 ปีที่แล้ว

    Hi James any idea how to use custom indicator for triggering

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว

      To execute a real trade? There are some integrated partners you can do this with. I've always hard coded any strategies that look like they'll work into either node or python scripts and executed via the exchange/broker APIs. This gives a lot more control.

    • @polytech7862
      @polytech7862 3 ปีที่แล้ว +1

      @@JamesBachini thanks alot James ,🙏

  • @aamersaeed1529
    @aamersaeed1529 2 ปีที่แล้ว

    I want to code dominant candle breakout into pinescript indicator but I am unable to do so.

  • @boralabrodi3641
    @boralabrodi3641 2 ปีที่แล้ว

    is it possible to get I private class only to talk about a type of entry strategy? How much would it be? Thanks

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว

      Sorry it's not something I can do. I'd be careful about paying anyone to code you entry signals. Entries are overrated, risk management is more important to long term success.

    • @boralabrodi3641
      @boralabrodi3641 2 ปีที่แล้ว

      @@JamesBachini actually I just wanna learn how to set an entry after my inside bar, and the next candle buys at the open price. I want it to buy when the price breaks above the inside bar previous candle

    • @JamesBachini
      @JamesBachini  2 ปีที่แล้ว

      @@boralabrodi3641 can you just set a variable on the previous candle and use that in a if statement for an entry signal?

  • @lubin2764
    @lubin2764 3 ปีที่แล้ว

    Is there a debug mode to be able to run the script line by line and explore the variables ? I would like to decode a complex existing pine scripts...

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว +1

      I wish there was, unfortunately it's a bit hit and miss. Tradingview published some info here on debugging.
      www.tradingview.com/pine-script-docs/en/v4/Debugging.html

  • @KLiCuk1
    @KLiCuk1 3 ปีที่แล้ว

    Thanks for a great intro tutorial. Do you have a more in depth course that takes us through the Pine Script language? If not can you recommend one?

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว +12

      I don't sorry. I'd recommend pouring a strong coffee and getting stuck in to the official docs at www.tradingview.com/pine-script-docs/en/v4/Introduction.html
      The other thing is just learning through experience. A lot of the indicators and strategies on the Tradingview library have open code. I've learnt quite a bit by looking for a similar strategy to what I'm trying to do and then seeing how the original developer coded it.

    • @KLiCuk1
      @KLiCuk1 3 ปีที่แล้ว +3

      @@JamesBachini I’ll do that and thanks for the vids you’ve already done

  • @zacmason
    @zacmason 3 หลายเดือนก่อน

    thanks for the tutorial. I'm new to this, and pasted your code into my Pine Editor, but when I tap 'Strategy Tester' I get a Caution message "This Strategy did not generate any orders throughout the testing range". I've checked every line but not sure why its not working for me. Would appreciate any tips on this :)

    • @JamesBachini
      @JamesBachini  3 หลายเดือนก่อน

      Could you try it on a different market or timeframe?

  • @Traqy
    @Traqy 3 ปีที่แล้ว

    Is there a way to have just the long position show and not the EMA?

    • @JamesBachini
      @JamesBachini  3 ปีที่แล้ว

      On a mobile so can't see the code but perhaps try removing the plot commands for each moving average?