NexusFi: Find Your Edge


Home Menu

 





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


Discussion in Platforms and Indicators

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




 
 

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

 
 foreverlearner 
Rio de Janeiro. Brazil.
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Trading: Emini ES
Posts: 30 since Sep 2019
Thanks Given: 10
Thanks Received: 37

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

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
36 thanks
Tao te Trade: way of the WLD
24 thanks
Spoo-nalysis ES e-mini futures S&P 500
21 thanks
Bigger Wins or Fewer Losses?
19 thanks
GFIs1 1 DAX trade per day journal
16 thanks
 
 foreverlearner 
Rio de Janeiro. Brazil.
 
Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Trading: Emini ES
Posts: 30 since Sep 2019
Thanks Given: 10
Thanks Received: 37

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

 



Last Updated on November 22, 2021


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts