Hi guys
As all the really smart and nice people are here at steve's i guess this is the best place for advice.
As usual, i will point out that I'm not a programmer but trader BUT I do manage too build some projects from time to time with my limited knowledge.
Anyway, i need advice or help?! In a project i'm working on I want to keep track of the highest high or lowest low on a order since open.
Basic logic:
Loop open trades
Check if order is but or sell
If buy, have we had a higher high since last loop and if so update the highvalue with the new high for the order
vice versa for sells..
My first thought was to handle this with a fileread/write
Put a new order in a file
update the highest high value on specific ticketnumber if a new high has been made.
BUT my guess is this should be easier to handle in arrays? or will the filefuncion do? As this will check on every tick?
If arrays is the correct way to go, could anyone point to any kind of code as arrays look pretty heavy for a "trader"programmer.. Or is there actually some kind of similar function out there?
Thanks.
Orderhandling Arrays or filewrite
- renexxxx
- Trader
- Posts: 860
- Joined: Sat Dec 31, 2011 3:48 am
Orderhandling Arrays or filewrite
As no one has posted a reply to frankie, I thought I would.
First of, I would never do any File I/O on every tick, this would be too much to handle for your little terminal.exe.
I have created a little code snippet that you can adjust to your needs. A few things to note:
First of, I would never do any File I/O on every tick, this would be too much to handle for your little terminal.exe.
I have created a little code snippet that you can adjust to your needs. A few things to note:
- The orderInfo array will be re-initialized when Empty4 restarts. You would lose your high's and low's from before the restart. If this is important to retain, use GlobalVariables.
I have used an array of STRUCTs to store the required information. This is to keep it simple, but you can also use a CLASS, with methods to update itself.
I am not sure if this is for a one-symbol EA or multi-symbol EA. You may need to adapt accordingly.
This code has not been tested. This is just me typing away whilst watching TV and having a glass of wine. But it looks OK.
You do not have the required permissions to view the files attached to this post.
-
frankie
- Posts: 9
- Joined: Mon Dec 05, 2011 5:30 pm
Orderhandling Arrays or filewrite
First, thankyou for taking time to present some example code as I'm pretty sure it will be a good starting point. I also thought that using filewrite on every tick could cause problems. So this will be a new thing to learn, so i will look into your code and hope i get my head around the logic. Thanks again..renexxxx » Tue Oct 21, 2014 2:06 am wrote:As no one has posted a reply to frankie, I thought I would.
First of, I would never do any File I/O on every tick, this would be too much to handle for your little terminal.exe.
I have created a little code snippet that you can adjust to your needs. A few things to note:
Hope this helps you.
- The orderInfo array will be re-initialized when Empty4 restarts. You would lose your high's and low's from before the restart. If this is important to retain, use GlobalVariables.
I have used an array of STRUCTs to store the required information. This is to keep it simple, but you can also use a CLASS, with methods to update itself.
I am not sure if this is for a one-symbol EA or multi-symbol EA. You may need to adapt accordingly.
This code has not been tested. This is just me typing away whilst watching TV and having a glass of wine. But it looks OK.
-
frankie
- Posts: 9
- Joined: Mon Dec 05, 2011 5:30 pm
Orderhandling Arrays or filewrite
Finaly I got both time AND my head around the code. Played with it and inserted it into a test EA and... Works like a charm, just what I was looking for. Many many thanks again for your help. It is a great piece of code I can build on.. again, thanksrenexxxx » Tue Oct 21, 2014 2:06 am wrote:As no one has posted a reply to frankie, I thought I would.
First of, I would never do any File I/O on every tick, this would be too much to handle for your little terminal.exe.
I have created a little code snippet that you can adjust to your needs. A few things to note:
Hope this helps you.
- The orderInfo array will be re-initialized when Empty4 restarts. You would lose your high's and low's from before the restart. If this is important to retain, use GlobalVariables.
I have used an array of STRUCTs to store the required information. This is to keep it simple, but you can also use a CLASS, with methods to update itself.
I am not sure if this is for a one-symbol EA or multi-symbol EA. You may need to adapt accordingly.
This code has not been tested. This is just me typing away whilst watching TV and having a glass of wine. But it looks OK.