Click here to Login





                                                   Zweig Indicator Function

  0

0
Amritendu Maji
2017-08-03 01:34:05


Using your help and the examples from other functions, I tried to write the Zweig Indicator. It returns 0, 1, -1 and one can take their trading decisions based on that.

Before I upload the formula, can you please check and see that it works as intended? Input is the series (close is the default), PerOffLow and PerOffHigh

double p = Series[0];
double tL = PerOffLow[0]; //t in percent
double tH = PerOffHigh[0];
int trend = 0;

double LC = Series[0];
double HC = Series[0];

for(int i = 0;i<Series.Length;i++)
{
if (trend == 0)
{
if (((Series[i] - LC) / LC) >= (tL / 100))
{
trend = 1;
}
if (((HC - Series[i] ) / HC) >= (tL / 100))
{
trend = -1;
}
}
else if ((trend == 1) && (((HC - Series[i]) / HC) >= (tH / 100)))
{
trend = -1;
LC = Series[i];
}
else if (trend == -1 && ((Series[i] - LC) / LC) >= (tL / 100))
{
trend = 1;
HC = Series[i];
}

if ( Series[i] < LC) LC = Series[i];
if ( Series[i] > HC) HC = Series[i];
result[i] = trend;
}




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
Ease of Movement Indicator
Swing Point Function (SP)
Traders Dynamic Index - TDI Indicator
Put minus Call Options Volume - Market Indicator
Current Drawdown of any Price Series or Indicator

How-to Lessons
How to hide a trading indicator from a particular time frame
How to optimize an indicator in your trading system
How to dynamically update the settings of an indicator
How to create a moving average of an indicator
How to create a custom trading indicator

Related Forum Threads
Stock or industry relative strenght : Indicator or composite ?
TimeframeApply function
newbie looking for function help
Keltner Channel Indicator
Sortino ratio indicator -

Blog Posts
Create a stock index or a trading indicator using the composite t...
Backtesting chart patterns using the auto support and resistance ...
Detect chart patterns using the auto support/resistance indicator
How to create the advance/decline market breadth indicator
How to create a ratio indicator using QS Trading Software









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.