Last Order

 

Hello,


i will check, if i have open an order at the actual bar. My idea is, just ask OrderOpentime() and Time[0] with an Order Select


   RefreshRates();

      bool setOrder = false;

      for(int j=0;j<OrdersTotal();j++)
        {

         Ticket=OrderSelect(j,SELECT_BY_POS,MODE_TRADES);
         if(OrderMagicNumber()==MN && OrderSymbol() == _Symbol)
           {
           
           if ( OrderOpenTime() < Time[0] )  setOrder = true;
            Print("Opentime: ", OrderOpenTime()," Time: ", Time[0]);
                    
           }
        }

The Answer in the jornal at the tester is


2018.01.03 19:23:09.433 2017.10.02 10:02:29  Renko_Risk EURUSD,M1: Opentime: 1506938549 Time: 1506938549


is this only happen with the tester or is this always?


im using Renko Chart and the offline Chart tester from OVO

https://ovo.cz/products/free-mt4-utilities/offline-test-helper/

in general the Bars have an different open Time


Offline Test Helper
Offline Test Helper
  • 2016.10.16
  • Milan
  • ovo.cz
What does the helper after dropping on a chart: Creates a virtual server folder. Absence of the on-line server will prevent the terminal from updating any chart. Copies essential Metatrader data to the new server folder (instrument list with latest quotes). Creates a copy of the current offline chart. Set its timeframe to M1. Removes...
 

amando:

i will check, if i have open an order at the actual bar. My idea is, just ask OrderOpentime() and Time[0] with an Order Select

if ( OrderOpenTime() < Time[0] )  setOrder = true;


The Answer in the jornal at the tester is

2018.01.03 19:23:09.433 2017.10.02 10:02:29  Renko_Risk EURUSD,M1: Opentime: 1506938549 Time: 1506938549

is this only happen with the tester or is this always?

  1. Your if is checking if you have an order opened before the current bar.
  2. Your printout says you opened an order, on the first tick if the current bar. Has nothing to do with your if.
  3. What do you mean "this only happen?" What's the problem?
 

sorry, you are right, i did a mistake later on,

i wrote 

      if(
      setOrder = false &&

instead of

      if(
      setOrder == false&&


courios, MT4 didnt brought an error during compiling

 
amando: courios, MT4 didnt brought an error during compiling
  1. Because it's not an error. It's equivalent to setOrder=false; if(setOrder && ... To prevent those types of errors put the constants on the left, e.g. if(0 == ticket)
  2. You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence.
    SetOrder is sounds like a verb, not question or statement. hasOpenedPreviously is what you're testing.