How to create Price Range Tool using new Pine Script V5? - futures io
futures io



How to create Price Range Tool using new Pine Script V5?


Discussion in Platforms and Indicators

Updated
    1. trending_up 1,052 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

How to create Price Range Tool using new Pine Script V5?

(login for full post details)
  #1 (permalink)
 foreverlearner 
Rio de Janeiro. Brazil.
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Trading: Emini ES
 
Posts: 29 since Sep 2019
Thanks: 9 given, 31 received

PineScript V5 allow us to use input.time and input.price with mouse click.

I would like to know how I can code:

Percentage difference between high of candle (selected with input.time) and input.price (selected with mouse click above candle.

I want to create something similar to the Price Range tool using pine script.

Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
$0 trades
EasyLanguage Programming
Does anyone have the code for Anchored Vwap to use in Qu …
Traders Hideout
pay for programmer coding a custom indicator
Traders Hideout
Brad Cowan
Trading Reviews and Vendors
Google Keyword Search Alerts
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Why dont people trade 150 ES contracts?
40 thanks
Spoo-nalysis ES e-mini futures S&P 500
36 thanks
Any long term success stories from funded traders in the …
26 thanks
Daytrading.Coach Review
17 thanks
How to work on strategy
17 thanks
 
(login for full post details)
  #2 (permalink)
 foreverlearner 
Rio de Janeiro. Brazil.
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Trading: Emini ES
 
Posts: 29 since Sep 2019
Thanks: 9 given, 31 received

I managed to do this with some help, so I will leave the code here.

 
Code
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/


//I use part of CAGR code in this code.
//@version=5
indicator("Price Range", "Price Range Tool", overlay = true)


color TVBLUE = #1848CC
int   DEFAULT_POINT1 = timestamp("2021-09")
int   DEFAULT_POINT2 = timestamp("2021-10")

// These two time inputs with `confirm = true` launch the interactive input mode     when adding the script to the chart.
var int    entryTimeInput      = input.time(DEFAULT_POINT1, "Point 1", confirm =     true)
var int    exitTimeInput       = input.time(DEFAULT_POINT2, "Point 2", inline = "2", confirm = true)
var float  exitPriceInput      = input.price(10000, "", inline = "2", confirm = true)


getPriceForTime(t)=>
    var float price = na
    if time[1] <= t and time >= t and na(price)
        price := close
    price

int   entryTime     = math.min(entryTimeInput, exitTimeInput)
int   exitTime      = math.max(entryTimeInput, exitTimeInput)
float entryPrice    = getPriceForTime(entryTime)
float exitPrice     = getPriceForTime(exitTime)
Compare =  math.round((exitPriceInput / entryPrice) * 100, 2) - 100

//Plot Line
line.new(entryTime,  entryPrice, exitTime, exitPriceInput, xloc = xloc.bar_time,     color = color.new(TVBLUE, 90), style = line.style_dotted, width = 1)

// Circles
label.new(entryTime, entryPrice, xloc = xloc.bar_time, color = TVBLUE, style =     label.style_circle, size = size.tiny)
//label.new(exitTime,  exitPriceInput,  xloc = xloc.bar_time, color = TVBLUE, style = label.style_circle, size = size.tiny)

// Percentage Label
lblText = str.format("{0, number}%", Compare)
label.new(exitTime, exitPriceInput, text = lblText, xloc = xloc.bar_time, yloc =     yloc.price, style = label.style_label_lower_left, color = TVBLUE, textcolor =     color.white, size = size.normal)

Started this thread Reply With Quote


futures io Trading Community Platforms and Indicators > How to create Price Range Tool using new Pine Script V5?


Last Updated on November 22, 2021


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts