Click here to Login





                                                   supertrend

  0

0
Juliettpapa
2011-05-02 10:37:26


Has anybody written the supertrend indicator?
I have tried to do it, but it is to heavy for a beginner....



QuantShare
2011-05-02 14:57:46

  0

Do you have the formula of the supertrend indicator in another program language? how it looks like? (I saw a lot of versions)


Juliettpapa
2011-05-02 15:43:27

  0

I have been working with this one (link) for years.
The formula/variables are in english.
The explanations are in german.
Maybe you can use a translator like google or babelfish.

http://www.tradesignalonline.com/lexicon/default.aspx?id=13453


Regards
Joerg



QuantShare
2011-05-03 06:10:36

  1

Best Answer
After you add the indicator, right click on a chart then add the following formula: (Let me know if this is what you were looking for)

s1 = supertrend(10, 3);
plot(absolute(s1), "", colorRed);
UpdateColor(s1 < 0, colorDarkGreen);


Indicator:

VectorD volaValue = TA.Atr(Period);
VectorD avgValue = TA.MedPrice();

VectorD upperValue = cFunctions.CreateNumericVector();
VectorD lowerValue = cFunctions.CreateNumericVector();
VectorD trendFlag = cFunctions.CreateNumericVector();
VectorD flagValue1 = cFunctions.CreateNumericVector();
VectorD flagValue2 = cFunctions.CreateNumericVector();
VectorD close = cFunctions.Close;
double lastTrendValue = 0;

for(int i=1;i < result.Length;i++)
{
upperValue[i] = avgValue[i] + ( Factor[i] * volaValue[i] );
lowerValue[i] = avgValue[i] - ( Factor[i] * volaValue[i] );

if(i == 0)
{
continue;
}


if(close[i] > upperValue[i - 1])
{
lastTrendValue = 1;
}

if(close[i] < lowerValue[i - 1])
{
lastTrendValue = -1;
}

trendFlag[i] = lastTrendValue;

if(trendFlag[i] < 0 && trendFlag[i - 1] > 0)
{
flagValue1[i] = 1;
}
else
{
flagValue1[i] = 0;
}

if(trendFlag[i] > 0 && trendFlag[i - 1] < 0)
{
flagValue2[i] = 1;
}
else
{
flagValue2[i] = 0;
}

if(trendFlag[i] > 0 && lowerValue[i] < lowerValue[i - 1])
{
lowerValue[i] = lowerValue[i - 1];
}

if(trendFlag[i] < 0 && upperValue[i] > upperValue[i - 1])
{
upperValue[i] = upperValue[i - 1];
}

if(flagValue1[i] == 1)
{
upperValue[i] = avgValue[i] + ( Factor[i] * volaValue[i] );
}

if(flagValue2[i] == 1)
{
lowerValue[i] = avgValue[i] - ( Factor[i] * volaValue[i] );
}

if(trendFlag[i] == 1)
{
result[i] = -lowerValue[i];
}
else
{
result[i] = upperValue[i];
}
}



Juliettpapa
2011-05-03 09:42:01

  0


QuantShare
2011-05-03 13:47:45

  0

I tested it here and I am getting the right indicator (picture 2)

I forget to tell you to add 2 parameters: (Period and Factor)



Juliettpapa
2011-05-03 15:18:54

  0

OK. Once again something with my charts.
When using a new one, it works fine.

Well done!
Thanks.



Juliettpapa
2011-05-03 15:51:18

  0

Sorry.
The indicator changes its style by changing time frame or factor of vola

http://screencast.com/t/f0Q0sU0kIyRe



QuantShare
2011-05-04 05:37:44

  0

The green line is displayed when a certain condition is met. Otherwise only the red line is shown. It is normal that decreasing the Factor will result in more signals and thus displaying the green line.


Juliettpapa
2011-05-04 15:44:54

  0

Sorry, but this is not right.
The supertrend must work in all timeframes and with all factors of vola.

See this:
http://screencast.com/t/D9kLSE1x



QuantShare
2011-05-05 05:14:37

  0

Change the following line:

for(int i=0;i < result.Length;i++)

to

for(int i=1;i < result.Length;i++)



Juliettpapa
2011-05-05 06:27:56

  0

now it is ok


velappan periasamy
2017-06-12 12:44:05

  0

I need the R code for the Supertrend indicator.


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
Supertrend Indicator
Yahoo Historical Buy/Sell Recommendations
mov avrages
Price to Book Ratio Historical Data - Market to Book
Stock Trading Rules - Percentage That Passed in the Last Trading ...

How-to Lessons
How to improve the performance of QuantShare databases?
How to create a hatched area in a chart
How to import trades into a portfolio
How to set order type of a trading system programmatically
How to create a Monte Carlo simulation

Related Forum Threads
coding a strat using supertrend
caption / labeling of indicators etc.
TrendLengthIndicator
Automatic SQN Indicator
Can you share your main (candlestick chart) formula? Here's mine!

Blog Posts
How to download the history of dividend payments for stocks in th...
Correlation of market indicators
New features in QuantShare - Trading Software
Historical volatility estimators
Creating a download item: Initial Jobless Claims









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.