Click here to Login





                                                   condition being true in the last X days

  0

0
allan nathan
2015-10-29 11:33:03


Hi,
Cant figure out how to code a condition being true over the last 5 days.I tried using Barssince,but it doesnt seem to work.

buy= barssince(cross(close,sma(close,50))<= 5);

thanks,

Allan





QuantShare
2015-10-30 03:38:40

  0

Hi Allan,

There are several ways to do that:

a = istrue(condition, 5);

or

a = llv(condition, 5);



allan nathan
2015-10-30 11:50:46

  0

hi,
any reason the code below does not work


goodma=cross(close,sma(close,50));
a=istrue(goodma,5);
buy= a;

this code does

a=istrue(close>ref(close,5),5);
buy=a;

thanks,

Allan



QuantShare
2015-10-31 03:46:04

  0

You can plot the variables on a chart to see what they return.

The variable "goodma" gets the crossover between the price and moving average. It is not possible to have 5 crossovers on a row.



allan nathan
2015-10-31 08:39:35

  0

Maybe I am not being clear. I would like to know how to code the formula that meets the condition of one moving average crossover over the last 5 days. Not looking for multiple crossovers.Just one over the past x bars.


QuantShare
2015-11-02 02:50:17

  0

a = hhv(condition, 5)


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
Trading Indicator: True between the first and last signal
Stock Trading Rules - Percentage That Passed in the Last Trading ...
Number of Consecutive Trading Bars Condition was True
Singapore Exchange EOD Data - SGX - Last 20 days
Top 20 stocks with the highest 10 day rate of change - Current an...

How-to Lessons
How to create a volatility-based Stop - Dynamic stop based on the...
How to quickly select stocks based on the last value of a databas...
How to quickly download the most recent EOD data for your stocks
How to change volume bar colors when the price closes down
How to plot two different time frames in the same chart

Related Forum Threads
close above the highest high in the last 5 days
How to get the last day of the month in C#
Show Date Column when condition was true Dynamic Watchlist
Replacing value for the last 100 bars (end of day data)
Getting volume for period of last condition

Blog Posts
Custom Shortcuts - Move a Chart to Display the Last Quotes/Data
True portfolio simulation applied to trading systems
The Ultimate Guide to Create Trading Systems in QuantShare
Create Realtime Quote Sheets with the Watchlist Tool
How to Pick the Best Trend Indicators









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.