Click here to Login





                                                   Persistent variable (toggle) in Quantscript

  1

0
Kiran
2016-04-02 18:07:39


I have a the following 2 variables defined
- once higherHigh is set to 1 by the first condition, i would like it to persist (i.e. stay at 1 even if the condition below is false) until lowerLow is true
How do i set persistent variables? The script below gives an error ..

higherHigh = (hhv(high,per)>hhv(ref(high,per),per) && llv(low,per)>llv(ref(low,per),per)) || (higherHigh==true);
lowerLow = hhv(high,per)<hhv(ref(high,per),per) && llv(low,per)<llv(ref(low,per),per) || (lowerLow==true);



QuantShare
2016-04-04 06:30:53

  0

Here is how:

per = 10;
higherHigh = (hhv(high,per)>hhv(ref(high,per),per) && llv(low,per)>llv(ref(low,per),per));
lowerLow = hhv(high,per)<hhv(ref(high,per),per) && llv(low,per)<llv(ref(low,per),per);
higherHigh = LSwitch(higherHigh, lowerLow);



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
Set Global Variable
VIDYA - Variable Index Dynamic Average
Highest and Lowest value over a dynamic period
PIPS conversion formula in Forex trading
Percentile Rank of PEG, Price/Free Cash Flow and Price/Sales

How-to Lessons
How to automatically start a downloader every few minutes?
How to calculate the average of a time series using the money man...
How to get trading orders from a portfolio programmatically
How to filter stocks in a market composite
How to plot two different time frames in the same chart

Related Forum Threads
Best practices for using a Global Variable
Random variable
Date variable not showing up in Debug
Set Global Variable Between Strategy and AMM
Plot text and variable in the same line

Blog Posts
A vector-based language
How To Create and Backtest an S&P 500 Trend Following System
The Ultimate Guide to Create Trading Systems in QuantShare
Backtesting a Strategy Based on Bond and Stock Index ETFs
How to create a trading system, screen and composite using earnin...









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.