NexusFi: Find Your Edge


Home Menu

 





Vertical Line


Discussion in ThinkOrSwim

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




 
Search this Thread

Vertical Line

  #1 (permalink)
 elgaza 
Toronto Canada
 
Experience: Master
Platform: NinjaTrader 7
Trading: ES
Posts: 109 since Jul 2011
Thanks Given: 16
Thanks Received: 18

Hi
I have this one line code that draws vertical lines every hour
can anyone add the needed code to allow this only on 1M and 5M charts?

thank you so much

AddVerticalLine(GetTime() % AggregationPeriod.HOUR == 0, color = Color.ORANGE, stroke = Curve.LONG_DASH);

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
What broker to use for trading palladium futures
Commodities
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
ZombieSqueeze
Platforms and Indicators
 
  #2 (permalink)
ColoradoCliff
Parker CO/USA
 
Posts: 22 since Jun 2017
Thanks Given: 0
Thanks Received: 5

Here's some code that should give you what you're looking for. It's not quite as simple as you would have thought. Note that this code is specifically for the 1M & 5M TimeFrame only. It would not be difficult to modify it to support any timeframe up to 1Hour. Right now, it doesn't draw the vertical lines overnight from midnight to market open (ET).

#***********

Def validChartTime = GetAggregationPeriod() == AggregationPeriod.MIN or GetAggregationPeriod() == AggregationPeriod.FIVE_Min;
# Modify this line to support other/additional timeframe charts

Def sessionStartTime = RegularTradingStart(GetYYYYMMDD());
## Expected session start time is 0930 ET

Def secondsFromStart = (GetTime() - sessionStartTime)/1000;
## Need to know what the start time of the candle is and whether or not it's at the top of the hour

Def onHour = secondsFromStart % 1800 < 1 and secondsFromStart % 3600 > 1;
## There are 3600 seconds per hour.
## For it to be on the top of the hour, the number must be divisible by 1800 (30 mins) but not by 3600

AddVerticalLine(validChartTime and onHour, color = Color.ORANGE, stroke = Curve.LONG_DASH);

#***********



elgaza View Post
Hi
I have this one line code that draws vertical lines every hour
can anyone add the needed code to allow this only on 1M and 5M charts?

thank you so much

AddVerticalLine(GetTime() % AggregationPeriod.HOUR == 0, color = Color.ORANGE, stroke = Curve.LONG_DASH);


Reply With Quote
Thanked by:
  #3 (permalink)
badiboy
BIRMINGHAM
 
Posts: 7 since Oct 2020
Thanks Given: 4
Thanks Received: 2


Playing with this code for fun, it doesn't;t have all checks balances, inputs will allow for flexibility

input vertLinePeriod = AggregationPeriod.HOUR;
input allowedPeriod_1 = AggregationPeriod.MIN;
input allowedPeriod_2 = AggregationPeriod.FIVE_MIN;


def canDrawVertLine = GetAggregationPeriod() == allowedPeriod_1 OR GetAggregationPeriod() == allowedPeriod_2;
AddVerticalLine(canDrawVertLine and GetTime() % vertLinePeriod == 0, color = Color.ORANGE, stroke = Curve.LONG_DASH);








ColoradoCliff View Post
Here's some code that should give you what you're looking for. It's not quite as simple as you would have thought. Note that this code is specifically for the 1M & 5M TimeFrame only. It would not be difficult to modify it to support any timeframe up to 1Hour. Right now, it doesn't draw the vertical lines overnight from midnight to market open (ET).

#***********

Def validChartTime = GetAggregationPeriod() == AggregationPeriod.MIN or GetAggregationPeriod() == AggregationPeriod.FIVE_Min;
# Modify this line to support other/additional timeframe charts

Def sessionStartTime = RegularTradingStart(GetYYYYMMDD());
## Expected session start time is 0930 ET

Def secondsFromStart = (GetTime() - sessionStartTime)/1000;
## Need to know what the start time of the candle is and whether or not it's at the top of the hour

Def onHour = secondsFromStart % 1800 < 1 and secondsFromStart % 3600 > 1;
## There are 3600 seconds per hour.
## For it to be on the top of the hour, the number must be divisible by 1800 (30 mins) but not by 3600

AddVerticalLine(validChartTime and onHour, color = Color.ORANGE, stroke = Curve.LONG_DASH);

#***********


Reply With Quote




Last Updated on October 21, 2023


© 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