Can anyone give me some pointers here please? I want to draw trendlines on the chart manually, multiple lines, and have my EA if price touches the line (once per bar but thats ok) then it will open a trade. I have seen Tipster trendlines and its good but over complicated for what I need, and I'm struggling to learn from it. I'd rather start simple and grow from there
Trendlines open orders
- Steve Gill
- Posts: 4
- Joined: Thu Dec 08, 2011 9:39 pm
Trendlines open orders
I'm determined to try and get better with Empty4 coding, my last programming experience was with Access 6.0 so that tells you how long ago it was
Can anyone give me some pointers here please? I want to draw trendlines on the chart manually, multiple lines, and have my EA if price touches the line (once per bar but thats ok) then it will open a trade. I have seen Tipster trendlines and its good but over complicated for what I need, and I'm struggling to learn from it. I'd rather start simple and grow from there
Can anyone give me some pointers here please? I want to draw trendlines on the chart manually, multiple lines, and have my EA if price touches the line (once per bar but thats ok) then it will open a trade. I have seen Tipster trendlines and its good but over complicated for what I need, and I'm struggling to learn from it. I'd rather start simple and grow from there
- Steve Gill
- Posts: 4
- Joined: Thu Dec 08, 2011 9:39 pm
Re: Trendlines open orders
OK I've made a bit of progress
Firstly I have a for loop - for (int i=ObjectsTotal()-1;i>=0;i--)
For every object I get the line price.
I then have another for loop within this, which is for every existing order. If there is an existing order opening (or open) at the line price, I move on (set matchedorder to true).
Then (still within the objects for loop) only if matched order is false, do I place an order to open on the line if price is at least 10 pips above or below the line (buy limit or sell limit orders).
Finally I set matchedorder to false, and then the for loop moves onto the next object.
However I'm finding that sometimes it works fine, but other times it keeps repeatedly creating orders even though there is an existing order open. Do you think I have my for loops in a bad order?
Firstly I have a for loop - for (int i=ObjectsTotal()-1;i>=0;i--)
For every object I get the line price.
I then have another for loop within this, which is for every existing order. If there is an existing order opening (or open) at the line price, I move on (set matchedorder to true).
Then (still within the objects for loop) only if matched order is false, do I place an order to open on the line if price is at least 10 pips above or below the line (buy limit or sell limit orders).
Finally I set matchedorder to false, and then the for loop moves onto the next object.
However I'm finding that sometimes it works fine, but other times it keeps repeatedly creating orders even though there is an existing order open. Do you think I have my for loops in a bad order?
- gaheitman
- Trader
- Posts: 655
- Joined: Tue Nov 15, 2011 10:55 pm
- Location: Richmond, VA, US
Re: Trendlines open orders
Post the pertinent loop and I'll give it a look-see.Steve Gill wrote:OK I've made a bit of progress![]()
Firstly I have a for loop - for (int i=ObjectsTotal()-1;i>=0;i--)
For every object I get the line price.
I then have another for loop within this, which is for every existing order. If there is an existing order opening (or open) at the line price, I move on (set matchedorder to true).
Then (still within the objects for loop) only if matched order is false, do I place an order to open on the line if price is at least 10 pips above or below the line (buy limit or sell limit orders).
Finally I set matchedorder to false, and then the for loop moves onto the next object.
However I'm finding that sometimes it works fine, but other times it keeps repeatedly creating orders even though there is an existing order open. Do you think I have my for loops in a bad order?
George
- Steve Gill
- Posts: 4
- Joined: Thu Dec 08, 2011 9:39 pm
Re: Trendlines open orders
Thanks George - I worked it out. School boy error, it was checking to see if an order was pending or not, and the instructions if it was live (ticket is -1) were outside of the if statement - doh!gaheitman wrote: Post the pertinent loop and I'll give it a look-see.![]()
George
Please have a look at the attached, and any comments on the code and the way I've done it would be welcome and appreciated. I've not been coding for about 15 years, and then it was Access, so I'm working my way slowly
You do not have the required permissions to view the files attached to this post.