Click here to Login





                                                   cycles indicator

  0

0
Dan
2011-01-30 15:18:50


Hello,

I am wishing to create an indicator that calculates the number of bars between two clicks on the chart.
I'd be gratefull to realize what formula to do this calculation by fetching mouse clicks on the chart
Please shed light :)



QuantShare
2011-01-31 04:55:37

  0

You can draw a line or a trendline (drawing tools), right click on it, select "Distances" then check "X Distance"


Dan
2011-02-03 10:25:06

  0

I am interested in writing a code wich calculates the number of bars between two clicks on chart and storing the value in a variable so i can design my indicator


QuantShare
2011-02-04 05:50:00

  0

You can do this by creating a custom drawing tool.

What is the function of the indicator you want to create?



Dan
2011-02-08 21:21:19

  0

Gurus,
Thank you on helping me realizing I'm up to create a "Custom Drawing Tool" rather than an "Indicator".
This drawing tool will calculate the average of distances taken from pairs of clicks on the chart,
so for every pair of clicks the distance of vector "X" is calculated and added to the "average" variable

Now, I can calculate only the 1st clicking distance with:

PointPosition p1 = Functions.ClickPositions[0];
PointPosition p2 = Functions.ClickPositions[1];

double distance = Math.Abs(p1.X - p2.X);

What is the code to add these distances to my "average" variable?



QuantShare
2011-02-09 04:54:34

  1

Best Answer
Here is an example:

bool isNewPair = false;
if(Functions.ClickPositions.Length == 0)
{
Global.SetVariable("count_distance", (double)0);
Global.SetVariable("average_distance", (double)0);
Global.SetVariable("last_click", 0);
return;
}
else if(Math.IEEERemainder(Functions.ClickPositions.Length, 2) == 0)
{
isNewPair = true;
}

string textDis = "";
if(isNewPair)
{
int lastClickIndex = Functions.ClickPositions.Length - 1;
PointPosition p1 = Functions.ClickPositions[lastClickIndex - 1];
PointPosition p2 = Functions.ClickPositions[lastClickIndex];
double distance = Math.Abs(p1.X - p2.X);
double avgDistance = 0;

if((int)Global.GetVariable("last_click") != lastClickIndex)
{
double count = 0;
if(Global.ContainsVariable("average_distance"))
{
count = (double)Global.GetVariable("count_distance");
avgDistance = (double)Global.GetVariable("average_distance");

avgDistance = avgDistance * count; // Calculate total distances
}

count = count + 1;
avgDistance = avgDistance + distance;
avgDistance = avgDistance / count;

Global.SetVariable("count_distance", count);
Global.SetVariable("average_distance", avgDistance);
Global.SetVariable("last_click", lastClickIndex);
}
else
{
avgDistance = (double)Global.GetVariable("average_distance");
}

textDis = "Last Distance: " + distance + " - Average: " + Math.Round(avgDistance, 2);
}
else
{
textDis = "Click on Chart";
}

TextObj text = Functions.PaneObject.DrawText("Distance", textDis, 0, 0.95);
text.UseFractionCoordinate = true;



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
Lunar Phase Indicator - New and Full Moon Cycles
Better Volume Indicator
Coppock - VLT Momentum Indicator
Triple Period Indicator
Short Cover Simulation Indicator

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

Related Forum Threads
Stock or industry relative strenght : Indicator or composite ?
to write and execute an Indicator
Indicator in a report
Adding an indicator to an indicator
Indicator for price

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









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.