Check for closed orders (and some .csv-stuff)
Results 1 to 5 of 5

Thread: Check for closed orders (and some .csv-stuff)

  1. #1
    I'm attempting to write a snippet that checks if a new trade shut, and if that is true it will export some worth.

    My code looks like this:

    Inserted Code datetime current=0; Inserted Code #91;abandoned #93;complete = OrdersTotal(); #91;abandoned #93;if(complete gt; 0) current = CurTime(); if(current! = CurTime()) FILE_WRITE #91;/abandoned #93; #91;/left#93;


    I tried some distinct sulotions, both discovered here on the forum and at Meataqoutes homepage, but I can't get anyone to operate properly. My idea is the set a variabel with the date when a position is open (orderstotal gt; 0 ) and compare this to the current time ( when a position isn't available, the variabel is going to have an old worth an thereby is not equal to CurrentTime() ).

    Instead, I get the ea to write to the document every volume-change once an position is available.

    What have I overlooked?


    And, another question - is it feasible to change, at a csv export to;?

  2. #2
    Use this...

    for(int I=0;ilt;OrdersHistoryTotal();I ){
    if(OrderSelect(I,SELECT_BY_POS,MODE_HISTORY)){

    to choose the order;

    then write the file like this

    int History, I;
    History=FileOpen(History.txt, FILE_CSV|FILE_WRITE,'|');
    for( I=0; ilt;OrdersHistoryTotal(); I )
    FileWrite(History,I,TimeToStr(OrderOpenTime()[I]),OrderTicket()[I],ECT...);
    FileClose(History);

  3. #3
    Or even OrderPrint() should do the job also.

  4. #4
    Thank you for your answer Kurka Fund.

    The thing is simply that I want to write to the file each time an order is shut. The main reason is that I have some values I need to write out, such as high and low of the transaction for further MFE/MAE-analysis. As far as I am concerned theres no particular command for low or high during the transaction, similar to OrderClose()?

    Therefore I need to check whether the order is shut. The logic I think is to compare TotalTrades together with the value previously, but I can�t get this to operate:--LRB-

    Any other solution?

  5. #5
    Ok .... I think that is what you are speaking about.

    First pick the order...
    PHP Code: <code><span style=�color: #000000�> <span style=�color: #0000BB�>
    </span><span style=�color: #007700�>for(</span><span style=�color: #0000BB�>inti</span><span style=�color: #007700�>=</span><span style=�color: #0000BB�>0</span><span style=�color: #007700�>;</span><span style=�color: #0000BB�>I</span><span style=�color: #007700�>lt;</span><span style=�color: #0000BB�>OrdersHistoryTotal</span><span style=�color: #007700�>();</span><span style=�color: #0000BB�>I</span><span style=�color: #007700�> ){
    if(</span><span style=�color: #0000BB�>OrderSelect</span><span style=�color: #007700�>(</span><span style=�color: #0000BB�>I</span><span style=�color: #007700�>,</span><span style=�color: #0000BB�>SELECT_BY_POS</span><span style=�color: #007700�>,</span><span style=�color: #0000BB�>MODE_HISTORY</span><span style=�color: #007700�>)){
    </span><span style=�color: #0000BB�></span> </span> </code> Then Throughout the time the order was open ascertain the large and high values...

    PHP Code: <code><span style=�color: #000000�> <span style=�color: #0000BB�>intOrderOpenbar</span><span style=�color: #007700�>=</span><span style=�color: #0000BB�>iBarShift</span><span style=�color: #007700�>(</span><span style=�color: #0000BB�>Symbol</span><span style=�color: #007700�>(),</span><span style=�color: #0000BB�>0</span><span style=�color: #007700�>,</span><span style=�color: #0000BB�>OrderOpenTime</span><span style=�color: #007700�>());
    </span><span style=�color: #0000BB�>intOrderClosebar</span><span style=�color: #007700�>=</span><span style=�color: #0000BB�>iBarShift</span><span style=�color: #007700�>(</span><span style=�color: #0000BB�>Symbol</span><span style=�color: #007700�>(),</span><span style=�color: #0000BB�>0</span><span style=�color: #007700�>,</span><span style=�color: #0000BB�>OrderCloseTime</span><span style=�color: #007700�>());

    </span><span style=�color: #0000BB�>doubleHighPoint</span><span style=�color: #007700�>=</span><span style=�color: #0000BB�>High</span><span style=�color: #007700�>#91;</span><span style=�color: #0000BB�>iHighest</span><span style=�color: #007700�>(</span><span style=�color: #0000BB�>Symbol</span><span style=�color: #007700�>(),</span><span style=�color: #0000BB�>0</span><span style=�color: #007700�>,</span><span style=�color: #0000BB�>MODE_HIGH</span><span style=�color: #007700�>,</span><span style=�color: #0000BB�>OrderOpenbar</span><span style=�color: #007700�>,</span><span style=�color: #0000BB�>OrderClosebar</span><span style=�color: #007700�>)#93;;
    </span><span style=�color: #0000BB�>doubleLowPoint</span><span style=�color: #007700�>=</span><span style=�color: #0000BB�>Low</span><span style=�color: #007700�>#91;</span><span style=�color: #0000BB�>iLowest</span><span style=�color: #007700�>(</span><span style=�color: #0000BB�>Symbol</span><span style=�color: #007700�>(),</span><span style=�color: #0000BB�>0</span><span style=�color: #007700�>,</span><span style=�color: #0000BB�>MODE_LOW</span><span style=�color: #007700�>,</span><span style=�color: #0000BB�>OrderOpenbar</span><span style=�color: #007700�>,</span><span style=�color: #0000BB�>OrderClosebar</span><span style=�color: #007700�>)#93;;
    </span><span style=�color: #0000BB�></span> </span> </code> Then yuo just write the values to the file like you were. . Hope this helps
    Or you can just add it to your order exit purpose... but I think it would work best as a seperate function.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners more information