Click here to Login





                                                   Maximum value of a given number of bars

  0

0
Francesco Pellarin
2014-02-08 09:27:09


Hi, I'm still practicing with QS Language...

What if I would like to set a variable with the highest high (or lowest low) of a given number of bars?

Thanks to anyone who will answer this!



QuantShare
2014-02-08 11:29:06

  0

Best Answer
Hi,

To do so, use the "hhv" (highest) or "llv" (lowest).

Examples:

=> 5-bar highest high
a = hhv(high, 5);

=> Stock reached 10-bar lowest low
a = (low == llv(low, 10));







Francesco Pellarin
2014-02-08 12:23:42

  0

Thank you, I'll try it right now!



JC
2020-09-01 14:14:28

  0

Hi, I have a related question
I want to calculate the Highest, lowest low value
a=LLV(Low,3);//being the lowest low for the last 3 bars
I want to use this as a sell criteria. A trailing stop of the lower donchian channel as it were
sell = close<highest LLV(Low,3)

my buy is similar, but since the last sell criteria
so my buy would be close>lowest, HHV

I'm thinking of highest since sell, or highest since buy, but we get into a loop with buy and sell as they are both dependent
hope im making myself clear



QuantShare
2020-09-02 08:53:01

  0

The lower Donchian channel should be:
LLV(ref(low, 1), 20) // assuming 20 bar period

So your sell rule should be:
sell = close < LLV(ref(low, 1), 20);
// Ref reference a previous bar or you can use low[1]

Plot these on a chart to have a visual confirmation



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Number of bars up to the end of the month
Number of Consecutive Trading Bars Condition was True
Number of Trading Bars to Fill a Gap Up
Number of bars since the beginning of the month
Maximum Drawdown Indicator

How-to Lessons
How to optimize the number of positions in a trading system
How to quickly select stocks based on the last value of a databas...
How to plot the number of stock tweets per day
How to add future bars to plan for market scenarios
How to display the number of stocks per day for different RSI gro...

Related Forum Threads
Number of bars
Preventing re-entery for certain number of bars
Replacing value for the last 100 bars (end of day data)
Counting bars after a condition has been met
Bars in slider

Blog Posts
The average maximum drawdown metric
QuantShare Trading Software: New Features in the 3.4.0 Version
Introduction to the trading rules analyzer
How to build and backtest a robust stock trading system
Day Trading: A trading system that combines intraday and EOD data









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.