stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Trendlines open orders
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=264
Page 1 of 1
Author:  Steve Gill [ Tue Jan 17, 2012 10:01 pm ]
Post subject:  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 :D

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 :)
Author:  Steve Gill [ Thu Jan 19, 2012 10:38 am ]
Post subject:  Re: Trendlines open orders

OK I've made a bit of progress :D

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?
Author:  gaheitman [ Thu Jan 19, 2012 11:46 am ]
Post subject:  Re: Trendlines open orders

Steve Gill wrote:OK I've made a bit of progress :D

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?
Post the pertinent loop and I'll give it a look-see. :D

George
Author:  Steve Gill [ Thu Jan 19, 2012 1:09 pm ]
Post subject:  Re: Trendlines open orders

gaheitman wrote: Post the pertinent loop and I'll give it a look-see. :D

George
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!

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 :)
All times are UTC Page 1 of 1