Click here to Login

Trading Software Trading objects Features How-to Blog Search


                                                   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

  0

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


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
Kaufman's Efficiency Ratio (Fractal Efficiency)
EURUSD Long Positions Ratio
Mojena Market Timing Model
Williams AD - Accumulation Distribution Indicator

How-to Lessons
How to quickly select stocks based on the last value of a databas...
How to plot arrows below/above candlesticks on a chart
How to import trading data from CSV files
How to create a composite index/indicator
How to create and trade a Neural Network model

Related Forum Threads
caption / labeling of indicators etc.
custom indicator
OnNewPosition event
Angle of an SMA line
guru , Static watchlist

Blog Posts
Beta release
Fundamental Screen based on Stock price, ROI and Market capitaliz...
Day Trading: A trading system that combines intraday and EOD data
How to create market indicators using the composite function - Pa...
Create a stock index or a trading indicator using the composite t...









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 © 2012 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items