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

Orderhandling Arrays or filewrite
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3888
Page 1 of 1
Author:  frankie [ Mon Oct 20, 2014 1:30 pm ]
Post subject:  Orderhandling Arrays or filewrite

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.
Author:  renexxxx [ Tue Oct 21, 2014 1:06 am ]
Post subject:  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:
  • 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.
Hope this helps you.
Author:  frankie [ Tue Oct 21, 2014 9:10 am ]
Post subject:  Orderhandling Arrays or filewrite

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:
  • 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.
Hope this helps you.
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.. :good:
Author:  frankie [ Sat Oct 25, 2014 12:44 pm ]
Post subject:  Orderhandling Arrays or filewrite

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:
  • 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.
Hope this helps you.
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, thanks :yahoo:
All times are UTC Page 1 of 1