Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I am trying to create a signal and indicator that will calculate a trend line that can be used to create entry/exit signal. Does anyone have some sample code that I can take a look at for doing this? I want to create a line based on bottoms or tops of a trend channel. Here's a pic of what I'm looking to do...
OK, so I started experimenting and created the following indicator just to see if it will plot a trend line on a flexrenko chart. It would plot a trend line with the starting point being on bar number 165 at 4185.00 and the end point being at bar number 1051 at 4180.50.
It did successfully plot the line, but it taxed the hell out of my processor. And when I say taxing, I opened the task manager and the CPU usage for MC went from 0.1% to 9%. And I have a robust system. Do all plotting codes do this?
Not sure I understand. It plotted one line. Is there a more efficient approach to this. If so, I'm all ears. I'm a complete noob to coded trend lines. Thanks
I am not sure I understand what you mean by that. Are you saying you are just seeing one line or did you actually check the number of drawings for the chart (for example by looking at all drawings via -> Format Drawings)?
you need to keep in mind how your code is evaluated. It is called on every bar/tick and since you are drawing the trendline unconditionally, every call will result in a new trendline using the same values.
This is also the solution to you problem i.e. you will probably want to add a condition to ensure the trendline is only drawn once. What you use here is up to you.
So let's say I put a condition in there to calculate it once right at the point where the second (end) point is identified. What happens when I tell it to extend right? will it extend right even if it calculates one time?