Vertical Line with Time

reunionman

New member
I have a Study that adds a Vertical Line when certain Study Parameters are met. I am looking to add the Date/Time to the Line instead of just the word "Puts". The 2 Red Lines are from the study. The Yellow Line is one I added using the Time Level from the TOS drawing set. The Yellow Line has the Date / Time I would like to add to the Red Lines. I would like Both Date and Time, but I would at least like to have the Time.
The First Red Line happened at 11:20 AM
The Second Red Line happened at 12:02 PM

Here is the Line Code:
AddVerticalLine (StochCrossParameters, "PUTS", Color.RED, Curve.FIRM);

I was not able to Upload the Picture for some reason.
You can click on the Line Drawn below to see a Sample Picture of Lines Drawn:
Line Drawn
 
Solution
I have a Study that adds a Vertical Line when certain Study Parameters are met. I am looking to add the Date/Time to the Line instead of just the word "Puts". The 2 Red Lines are from the study. The Yellow Line is one I added using the Time Level from the TOS drawing set. The Yellow Line has the Date / Time I would like to add to the Red Lines. I would like Both Date and Time, but I would at least like to have the Time.
The First Red Line happened at 11:20 AM
The Second Red Line happened at 12:02 PM

Here is the Line Code:
AddVerticalLine (StochCrossParameters, "PUTS", Color.RED, Curve.FIRM);

I was not able to Upload the Picture for some reason.
You can click on the Line Drawn below to see a Sample Picture of Lines Drawn...
I have a Study that adds a Vertical Line when certain Study Parameters are met. I am looking to add the Date/Time to the Line instead of just the word "Puts". The 2 Red Lines are from the study. The Yellow Line is one I added using the Time Level from the TOS drawing set. The Yellow Line has the Date / Time I would like to add to the Red Lines. I would like Both Date and Time, but I would at least like to have the Time.
The First Red Line happened at 11:20 AM
The Second Red Line happened at 12:02 PM

Here is the Line Code:
AddVerticalLine (StochCrossParameters, "PUTS", Color.RED, Curve.FIRM);

I was not able to Upload the Picture for some reason.
You can click on the Line Drawn below to see a Sample Picture of Lines Drawn:
Line Drawn

As you did not not provide the code for StochCrossParameters, I used code provided in another post and used cond1 instead to position the vertical lines.

Code:
def cond1 = ExtMapBuffer1 crosses ExtMapBuffer2;
def xdate = if cond1 then GetYYYYMMDD() else Double.NaN;
input timezone = {default "ET", "CT", "MT", "PT"};

def starthour  = (if timezone == timezone."ET"
                        then 9
                        else if timezone == timezone."CT"
                        then 8
                        else if timezone == timezone."MT"
                        then 7
                        else 6) ;
def hour = Floor(((starthour * 60 + 30) + (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000) / 60);
def minutes = (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000 - ((hour - starthour) * 60 + 30) + 60;

AddVerticalLine(cond1, "PUTS     " + AsPrice(xdate) + "    " + hour + ":" + (if minutes < 10 then "0" else "") + minutes, Color.RED, Curve.FIRM);

Here is the example code with the cond1 vertical lines with date and time happened
Screenshot-2023-04-27-092529.png
Code:
#Converted MT4 HeikinAshi_EntryExit Indicator
#MikeLikesAnacottSteel
#8-27-2022
#MT4 indicator source: https://forex-station.com/app.php/attach/file/3349947

input MaMethod1 = AverageType.EXPONENTIAL;
input MaPeriod = 40;
input MaMethod2 = AverageType.EXPONENTIAL;
input MaPeriod2 = 1;

def maOpen = MovingAverage(MaMethod1, open, MaPeriod);
def maClose = MovingAverage(MaMethod1, close, MaPeriod);
def maLow = MovingAverage(MaMethod1, low, MaPeriod);
def maHigh = MovingAverage(MaMethod1, high, MaPeriod);

def haClose = (maOpen + maHigh + maLow + maClose) / 4;
def haOpen = (GetValue(haOpen, 1) + GetValue(haClose, 1)) / 2;
def haHigh = Max(maHigh, Max(haOpen, haClose));
def haLow = Min(maLow, Min(haOpen, haClose));

def ExtMapBuffer7;
def ExtMapBuffer8;

if (haOpen < haClose)
{
    ExtMapBuffer7 = haLow;
    ExtMapBuffer8 = haHigh;
}
else
{
    ExtMapBuffer7 = haHigh;
    ExtMapBuffer8 = haLow;
}

def ExtMapBuffer5 = haOpen;
def ExtMapBuffer6 = haClose;

plot ExtMapBuffer1 = MovingAverage(MaMethod2, ExtMapBuffer7, MaPeriod2);
plot ExtMapBuffer2 = MovingAverage(MaMethod2, ExtMapBuffer8, MaPeriod2);
plot ExtMapBuffer3 = MovingAverage(MaMethod2, ExtMapBuffer5, MaPeriod2);
plot ExtMapBuffer4 = MovingAverage(MaMethod2, ExtMapBuffer6, MaPeriod2);

ExtMapBuffer1.SetDefaultColor(Color.RED);
ExtMapBuffer1.SetPaintingStrategy(PaintingStrategy.LINE);
ExtMapBuffer1.SetLineWeight(1);

ExtMapBuffer2.SetDefaultColor(Color.BLUE);
ExtMapBuffer2.SetPaintingStrategy(PaintingStrategy.LINE);
ExtMapBuffer2.SetLineWeight(1);

ExtMapBuffer3.SetDefaultColor(Color.RED);
ExtMapBuffer3.SetPaintingStrategy(PaintingStrategy.LINE);
ExtMapBuffer3.SetLineWeight(1);

ExtMapBuffer4.SetDefaultColor(Color.BLUE);
ExtMapBuffer4.SetPaintingStrategy(PaintingStrategy.LINE);
ExtMapBuffer4.SetLineWeight(1);

AddCloud(ExtMapBuffer1, ExtMapBuffer2, CreateColor(255, 0, 102), CreateColor(0, 102, 255));
AddCloud(ExtMapBuffer1, ExtMapBuffer4, CreateColor(255, 0, 102), CreateColor(0, 102, 255));
AddCloud(ExtMapBuffer2, ExtMapBuffer1, CreateColor(0, 102, 255), CreateColor(255, 0, 102));
AddCloud(ExtMapBuffer2, ExtMapBuffer3, CreateColor(0, 102, 255), CreateColor(255, 0, 102));
AddCloud(ExtMapBuffer3, ExtMapBuffer4, CreateColor(255, 0, 102), CreateColor(0, 102, 255));

def cond1 = ExtMapBuffer1 crosses ExtMapBuffer2;
def xdate = if cond1 then GetYYYYMMDD() else Double.NaN;
input timezone = {default "ET", "CT", "MT", "PT"};

def starthour  = (if timezone == timezone."ET"
                        then 9
                        else if timezone == timezone."CT"
                        then 8
                        else if timezone == timezone."MT"
                        then 7
                        else 6) ;
def hour = Floor(((starthour * 60 + 30) + (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000) / 60);
def minutes = (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000 - ((hour - starthour) * 60 + 30) + 60;

AddVerticalLine(cond1, "PUTS     " + AsPrice(xdate) + "    " + hour + ":" + (if minutes < 10 then "0" else "") + minutes, Color.RED, Curve.FIRM);
 
Solution

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
388 Online
Create Post

Similar threads

Similar threads

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