EA: Miscellaneous Questions - Trading Strategy - page 2

 
Marco vd Heijden:

Yes in an orderselect loop use the filter:

And dont forget to reset it to 0 when you run another check else it will double.
Actually I have already tried OrderSymbol() == Symbol() a little different.
I will try it soon, thanks a lot for your prompt reply.
 
Marco vd Heijden:

Yes in an orderselect loop use the filter:

And dont forget to reset it to 0 when you run another check else it will double.

Sorry do you mean like that one?

Below method do not work for me.

int orders = 0;
for( int i = OrdersTotal() - 1; i >= 0; i-- )
{
    if( ! OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) ) continue;

    if( OrderSymbol() == Symbol() )
    {
        Print( "count orders: ", orders );
        orders++;
    }
}

---

My purpose is, if chart symbol orders is equal to 0 ( zero ) then do something otherwise skip this if();

if( Chart symbol order == 0 ) // I can't get correct counts for Chart Symbol Orders
{
  // calculate something
  // check something for Sell
  // check something for Buy
  // ...
}

Thanks in advance.

 
Max Enrik: Below method do not work for me.
"Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
 
whroeder1:
"Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.

Yeah it does not work for me.
I use that part of code for my Close Open Orders functions without any issues.

But now I need to get count of chart symbol open orders. That part of code did not worked for my purpose. That I obviously mentioned with below code.

if( Chart symbol order == 0 ) // I can't get correct counts for Chart Symbol Orders / I meant I do not know how can I get counts of Chart Symbol Orders.
{
  // ...
}
 

it's the right approach so you should be able to get it to work if orders stays zero

int orders = 0;
for( int i = OrdersTotal() - 1; i >= 0; i-- )
{
    if( ! OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) ) continue;

    if( OrderSymbol() == Symbol() )
    {
        Print( "count orders: ", orders );
        orders++;
    }
}

if( orders == 0 ) // I can't get correct counts for Chart Symbol Orders
{
  // calculate something
  // check something for Sell
  // check something for Buy
  // ...
}
 
Marco vd Heijden:

it's the right approach so you should be able to get it to work if orders stays zero


After I little change it then it works for me now.

Thanks a lot Mr. Marco.

 

First my 2 Automated orders got 50 pips both 100 pips. Sl and Tp were 50/50 ( 1:1 ratio )

Amazing! Simple and better Trading Strategy - good to improve it.

aeas
 

I am trying to use below code for EA Trading Hours, that only EA Trading runs specific hours. But EA Trading runs at 11pm.

Q:  What I missed for Trading Hours, please?

void OnTick()
{
    // below trading Hours just for example
    if( Hour() >= 10 && Hour() < 12 ) return;

    Runs();
    //---
    return;
}

Forum on trading, automated trading systems and testing trading strategies

Only Trade During Market Hours(Asia, UK, UK/US)

whroeder1, 2012.05.03 18:41

  1.  if(Hour()>=0 && Hour()<22)
    // if(Hour()>=0 && Hour()<=22)
      {
       return(true);
      }
      else
      {
        return(false);
      }
    //// or Simplify ///
    return( Hour()>=0 && Hour()<22 );

  2. If you mean code to allow a range, see my code

I am working on it, help me please.

 
Max Enrik:

But EA Trading runs at 11pm.

Q:  What I missed for Trading Hours, please?

I am working on it, help me please.

What you are missing is that 10 <= 11 < 12
 
whroeder1:
What you are missing is that 10 <= 11 < 12

Sorry I do not understand it.
Reason: