How to automatically move Cursor CROSS onto the most recent Candlestick ?

Razor_Morozumi

New member
Under <Style - Appearance - Common> at TOS platform,
I set:
Cursor: CROSS
Snap crosshairs to: Open

Please give me some advice on how to automatically position my Cursor on the real-time Candlestick.
I know if I set up <Time axis> for having the most recent Candlestick will be displayed in the center of the monitor, I simply make my cursor stays in the center.

But, I rather want to have an entire day chart displayed on my monitor, Candlestick will be displayed from left to right based on time duration.
So, I can't make my cursor stays in the same location and manually need to move onto the most recent Candlestick.

If Cursor CROSS is not able to use for this purpose, please advise how to have CROSS lines always onto the newest Candlestick automatically.
Thank you very much for your input/support.
 
Solution
Set the color here:
pTFNNdA.png


You can also set the source to close and it will track prices.

It shows up on the current day only.

Ruby:
DefineGlobalColor("CROSS", CreateColor(000, 000, 255));
Input Source = Open;
def MilDay = 
    (24 * 60 * 60 * 1000) 
    / GetAggregationPeriod()
;
def Offset = 
    if !Offset[1] and GetDay() == GetLastDay() then 
        fold i = 0 to ceil(MilDay) 
        with d = no while d == no do
            if !IsNaN(GetValue(close, -i)) 
            and IsNaN(GetValue(close, -i - 1)) 
            then GetValue(Source, -i) 
            else no
    else 
        Offset[1]
    ;
;
plot CrossHair = if !Offset then Double.NaN else Offset;
CrossHair.assignvalueColor(GlobalColor("CROSS"));
def LastBar =...
Thinkscript can't interact with the cursor, detect mouse clicks, or anything similar. I can get thinkscript to paint fake cross hairs if you want though. What would like the y-axis position to be?
 
Thank you very much for your reply, Joshua.
I want to have the y-axis position as OPEN.
I just want to clarify that your script might be automatically repainted onto the newest Candlestick as time goes by?

If you can post that thinkscript, it is greatly appreciated!
 
Set the color here:
pTFNNdA.png


You can also set the source to close and it will track prices.

It shows up on the current day only.

Ruby:
DefineGlobalColor("CROSS", CreateColor(000, 000, 255));
Input Source = Open;
def MilDay = 
    (24 * 60 * 60 * 1000) 
    / GetAggregationPeriod()
;
def Offset = 
    if !Offset[1] and GetDay() == GetLastDay() then 
        fold i = 0 to ceil(MilDay) 
        with d = no while d == no do
            if !IsNaN(GetValue(close, -i)) 
            and IsNaN(GetValue(close, -i - 1)) 
            then GetValue(Source, -i) 
            else no
    else 
        Offset[1]
    ;
;
plot CrossHair = if !Offset then Double.NaN else Offset;
CrossHair.assignvalueColor(GlobalColor("CROSS"));
def LastBar = !IsNaN(close) and IsNaN(close[-1]);
AddChart(
    high = if LastBar then Double.POSITIVE_INFINITY else Double.NaN, 
    low = if LastBar then Double.NEGATIVE_INFINITY else Double.NaN, 
    open = if LastBar then Source else Double.NaN, 
    close = if LastBar then Source else Double.NaN, 
    type = ChartType.CANDLE, 
    growcolor = GlobalColor("CROSS")
);


def  FRP = Double.NaN;
plot RP = FRP[-Milday];
RP.assignValueColor(GlobalColor("CROSS"));
 
Solution
It works perfectly!!!

As for the Chart screen, I have multiple sections under the price chart as added studies such as MACD, TTM_Squeeze.
Is there any TOS functionality that will take your module as a subsetting of TOS general setting for reflecting it on the entire Chart Windows (includes multiple sections and studies) just like the Cursor setting under <Common - Style>?
If possible, I can disable Cursor but your module just acts as its alternative for my chart screen.

If not, I can add your module in individual studies to reflect the same result.
No matter what, I thank you so much for all your time and effort to make this, Joshua.

Best,
Razor
 
Last edited:
Set the color here:
pTFNNdA.png


You can also set the source to close and it will track prices.

It shows up on the current day only.

Ruby:
DefineGlobalColor("CROSS", CreateColor(000, 000, 255));
Input Source = Open;
def MilDay =
    (24 * 60 * 60 * 1000)
    / GetAggregationPeriod()
;
def Offset =
    if !Offset[1] and GetDay() == GetLastDay() then
        fold i = 0 to ceil(MilDay)
        with d = no while d == no do
            if !IsNaN(GetValue(close, -i))
            and IsNaN(GetValue(close, -i - 1))
            then GetValue(Source, -i)
            else no
    else
        Offset[1]
    ;
;
plot CrossHair = if !Offset then Double.NaN else Offset;
CrossHair.assignvalueColor(GlobalColor("CROSS"));
def LastBar = !IsNaN(close) and IsNaN(close[-1]);
AddChart(
    high = if LastBar then Double.POSITIVE_INFINITY else Double.NaN,
    low = if LastBar then Double.NEGATIVE_INFINITY else Double.NaN,
    open = if LastBar then Source else Double.NaN,
    close = if LastBar then Source else Double.NaN,
    type = ChartType.CANDLE,
    growcolor = GlobalColor("CROSS")
);


def  FRP = Double.NaN;
plot RP = FRP[-Milday];
RP.assignValueColor(GlobalColor("CROSS"));

Is there a way to get the cursor to paint further to the left?
 
I don't see why not, but what specifically would you have it targeting?
It has been a while but thank you very much for your input.
By the way, if I only need a vertical line but a cross (which means I don't need a Horizontal line), what code should be? I tried to modify your code but it is too complicated for me to modify.

Thank you in advance!!

I forgot to explain the reason why.
I separate windows under TOS Added Studies and strategies such as MacD, EMA, volume study, etc.
It is much easier for me to see the exact moment of each plot at the time. So, if I use a vertical line at the most recent candle bar as synchronized,
Nothing for beneficial for other professional traders or TOS users, but it is quite helpful for me as a mature trader.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
323 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top