Trailing Stop offset or displace

AndrewPnF

New member
I'm learning thinkscripting by trying to take what I can find and then modifying it.

I'm wondering about the offset and displace capabilities.

I found this unattributed code to display a line that is an input percent off the Low of the aggregation period.

input percentAbove = 20.0;
def lowOfQuarter = low(period = AggregationPeriod.QUARTER);
plot data = lowOfQuarter * (1 + percentAbove * 0.01);

Is there a way to push this line display forward using a user input value, so that the prior quarter's line able to be moved to the right.

Sort of like a lower Price Channel but set at user defined percentage off the low.

Or, is there a way to create an AggregationPeriod on multiples of the accepted periods. I know in Days, they have 2 days and 3 days.... as accepted periods. Is there a way to do this with weeks, or months or quarters? So an aggregation on 2 quarters? Or 4 months?

Thank you for any guidance and assistance offered

Andrew G.
 
Solution
I'm learning thinkscripting by trying to take what I can find and then modifying it.

I'm wondering about the offset and displace capabilities.

I found this unattributed code to display a line that is an input percent off the Low of the aggregation period.

input percentAbove = 20.0;
def lowOfQuarter = low(period = AggregationPeriod.QUARTER);
plot data = lowOfQuarter * (1 + percentAbove * 0.01);

Is there a way to push this line display forward using a user input value, so that the prior quarter's line able to be moved to the right.

Sort of like a lower Price Channel but set at user defined percentage off the low.

Or, is there a way to create an AggregationPeriod on multiples of the accepted periods. I know in Days, they have 2...
I'm learning thinkscripting by trying to take what I can find and then modifying it.

I'm wondering about the offset and displace capabilities.

I found this unattributed code to display a line that is an input percent off the Low of the aggregation period.

input percentAbove = 20.0;
def lowOfQuarter = low(period = AggregationPeriod.QUARTER);
plot data = lowOfQuarter * (1 + percentAbove * 0.01);

Is there a way to push this line display forward using a user input value, so that the prior quarter's line able to be moved to the right.

Sort of like a lower Price Channel but set at user defined percentage off the low.

Or, is there a way to create an AggregationPeriod on multiples of the accepted periods. I know in Days, they have 2 days and 3 days.... as accepted periods. Is there a way to do this with weeks, or months or quarters? So an aggregation on 2 quarters? Or 4 months?

Thank you for any guidance and assistance offered

Andrew G.

See if this helps.

The isnan(close(period=aggregationperiod.quarter) creates a recursive (the prior value is repeated whenever there is blank space or missing data), which extends the last lines value to the right edge of the chart.

Then the ow(period = AggregationPeriod.QUARTER)[0] allows you to displace the lines by adjusting [0]
Ruby:
input percentAbove = 20.0; 
def lowOfQuarter = if isnan(close(period=aggregationPeriod.QUARTER)) then lowofQuarter[1] else low(period = AggregationPeriod.QUARTER)[0];
plot data = lowOfQuarter * (1 + percentAbove * 0.01);
data.setpaintingStrategy(paintingStrategy.HORIZONTAL);
 
Solution

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

See if this helps.

The isnan(close(period=aggregationperiod.quarter) creates a recursive (the prior value is repeated whenever there is blank space or missing data), which extends the last lines value to the right edge of the chart.

Then the ow(period = AggregationPeriod.QUARTER)[0] allows you to displace the lines by adjusting [0]
This works perfectly.... and I now have an example of If Then Else to work with/through in my learning. I appreciate your help very much. Thank you.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
516 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