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
Conditional Trailing Stop Exit 2013-10-18
Portfolio vs Stock Return
Currency Mgmt v 0.9

How-to Lessons
How to optimize the stop limit of a trading system
How to detect stocks trading near all time highs
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

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
Automatically create historical quotes charts
Backtesting Your Trading Systems: Symbol Segmentation
How to Backtest Your Trading System for Each Industry
How to Backtest Each Stock or Asset Individually
10 masks to create thousands of rules to use into your trading sy...









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.