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

Is this Valid?
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3489
Page 1 of 1
Author:  Arav [ Sun Mar 09, 2014 5:42 am ]
Post subject:  Is this Valid?

If I attach an EA to say EURUSD chart and then call 'OrderSymbol()' to verify whether it is on EURUSD chart or not like this:

if (Order_Symbol()==EURUSD) // ?
Author:  renexxxx [ Sun Mar 09, 2014 8:06 am ]
Post subject:  Is this Valid?

Arav » Sun Mar 09, 2014 3:42 pm wrote:If I attach an EA to say EURUSD chart and then call 'OrderSymbol()' to verify whether it is on EURUSD chart or not like this:

if (Order_Symbol()==EURUSD) // ?
No, that is not quite valid.

1. It should be Symbol() not Order_Symbol(). Btw. There is a function OrderSymbol() (without the underscore) that returns the name of the symbol previously selected with OrderSelect() ). From the question, I assume that you are not after this one.
2. EURUSD should be between double quotes: "EURUSD".
3. You should be aware that some br0kers use suffixes for their symbols, such as "EURUSD.m". If that is the case, Symbol() would return "EURUSD.m" and the if-statement would return false. You might get away with

Code: Select all

   if ( StringSubstr( Symbol(), 0, 6 ) == "EURUSD" ) {}
R.
Author:  Arav [ Sun Mar 09, 2014 11:42 am ]
Post subject:  Is this Valid?


No, that is not quite valid.

1. It should be Symbol() not Order_Symbol(). Btw. There is a function OrderSymbol() (without the underscore) that returns the name of the symbol previously selected with OrderSelect() ). From the question, I assume that you are not after this one.
2. EURUSD should be between double quotes: "EURUSD".
3. You should be aware that some br0kers use suffixes for their symbols, such as "EURUSD.m". If that is the case, Symbol() would return "EURUSD.m" and the if-statement would return false. You might get away with

Code: Select all

   if ( StringSubstr( Symbol(), 0, 6 ) == "EURUSD" ) {}
R.
Thanks for the reply.
Actually I messed up the code.
It had to be
if (OrderSymbol()=="EURUSD")

My requirement is that:
After selecting an order, EA will verify that whether it is the Pair it is attached with.

Code: Select all

BuyOrder_1=OrderSend("EURUSD", iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_1,NULL,Magic_Number_3, 0,Blue);

for(cnt=OrdersTotal()-1;cnt>=0;cnt--)
                       { 
                            if(!OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) continue;
                               if(OrderSymbol() == Symbol() && OrderMagicNumber() ==  Magic_Number_3)
                                    {
                                       if (OrderSymbol()=="EURUSD")
                                          {
                                               if (OrderType()==OP_BUY)
                                                   {
                                                       Order Modifying function;
                                                    }
                                                 }
                                               }
                                             }
And if I want to take the 'Symbol' of OrderSend() as a variable is it possible?

Code: Select all

extern string Chart_Symbol=EURUSD; //Would I have to put this with "" i.e. "EURUSD" ?

BuyOrder_1=OrderSend(Chart_Symbol, iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_1,NULL,Magic_Number_3, 0,Blue);
And if the symbol is like "EURUSDpro" then what to do?

Code: Select all

extern string Chart_Symbol="EURUSDpro"/"EURUSD.m"; // ???
Author:  renexxxx [ Sun Mar 09, 2014 11:56 am ]
Post subject:  Is this Valid?

If you want your EA to do something specific if it is attached to the "EURUSD" chart, you would do something like:

Code: Select all

extern string chart_symbol = "EURUSD";

if ( StringFind( Symbol(), chart_symbol, 0 ) == 0 ) {
   // Do something special for chart_symbol
}
Author:  Arav [ Sun Mar 09, 2014 12:25 pm ]
Post subject:  Is this Valid?

renexxxx » Sun Mar 09, 2014 5:56 pm wrote:If you want your EA to do something specific if it is attached to the "EURUSD" chart, you would do something like:

Code: Select all

extern string chart_symbol = "EURUSD";

if ( StringFind( Symbol(), chart_symbol, 0 ) == 0 ) {
   // Do something special for chart_symbol
}
No the EA wont do anything Specific while attached with a specific pair.
Rather it'll do the same thing for every pair.
So I want that there will be single function for Buy & Sell.
The Symbol will be different while it'll open trades for different pairs.
Also can I do it for all pairs just attaching it to Only One pair?
Regards
Author:  renexxxx [ Sun Mar 09, 2014 7:35 pm ]
Post subject:  Is this Valid?

Arav » Sun Mar 09, 2014 10:25 pm wrote: Also can I do it for all pairs just attaching it to Only One pair?
Regards
Yes, you can.
All times are UTC Page 1 of 1