Download MetaTrader 5
To add comments, please log in or register
Publish your task in Freelance service and developers will execute your order.
Sherif Hasan
7223
Sherif Hasan 2014.04.26 16:42 

Hi,

I wrote EA's for different pairs. but i like to use only one chart.

Currently i run GBPUSD chart and strategy running for EA on 30min tf. now i add code for USDJPY with 4hr startegy also.

EA not opening buy/sell orders?

i take values from following code by opening GBPUSD chart. why USDJPY orders not opening?

Error:

OrderSend() error - invalid stops

CODE:

some_time=iTime("USDJPY", PERIOD_D1, 0);
shift=iBarShift("USDJPY",0,some_time);
Hval=iHigh("USDJPY",0,shift);
Lval=iLow("USDJPY",0,shift);
HLdiff=Hval-Lval;
Alain Verleyen
Moderator
28536
Alain Verleyen 2014.04.26 17:23  
sheriffonline:

Hi,

I wrote EA's for different pairs. but i like to use only one chart.

Currently i run GBPUSD chart and strategy running for EA on 30min tf. now i add code for USDJPY with 4hr startegy also.

EA not opening buy/sell orders?

i take values from following code by opening GBPUSD chart. why USDJPY orders not opening?

Error:

Please show your OrderSend() call and all the relevant code.
Sherif Hasan
7223
Sherif Hasan 2014.04.26 17:27  
angevoyageur:
Please show your OrderSend() call and all the relevant code.


I get values from following code:

some_time=iTime("USDJPY", PERIOD_D1, 0);
shift=iBarShift("USDJPY",PERIOD_H4,some_time);
Hval=iHigh("USDJPY",PERIOD_H4,shift);
Lval=iLow("USDJPY",PERIOD_H4,shift);
HLdiff=Hval-Lval;

OrderSend() call:

for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_BUYSTOP && OrderSymbol() == "USDJPY" && OrderMagicNumber() == 1)
        {
            exists = true;
        }
    }
    else
    {
        Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
    }

Please solve the issues?

Note: I do backtesting currently. still not tried with forward test. while backtest i choose different timeframe,pair...

Keith Watford
Moderator
7888
Keith Watford 2014.04.26 17:35  
sheriffonline:

I get values from following code:

OrderSend() call:

Please solve the issues?



That's OrderSelect, not OrderSend

Anyway, most likely that you are trying to open trades on USDJPY, but using the chart symbol's Ask/Bid

Sherif Hasan
7223
Sherif Hasan 2014.04.26 17:48  
GumRai:


That's OrderSelect, not OrderSend

Anyway, most likely that you are trying to open trades on USDJPY, but using the chart symbol's Ask/Bid

Yes. here is the OrderSend() code:
{
    int expire = TimeCurrent() + 60 * 480;
    double price = NormalizeDouble(Hval, NDigits) + PriceOffset*PipValue*Point;
    double SL = price - BuyStoploss*PipValue*Point;
    if (BuyStoploss == 0) SL = 0;
    double TP = price + BuyTakeprofit*PipValue*Point;
    if (BuyTakeprofit == 0) TP = 0;
    if (480 == 0) expire = 0;
    int ticket = OrderSend("USDJPY", OP_BUYSTOP, BuyLots, price, 4, SL, TP, "My Expert", 2, expire, Blue);
    if (ticket == -1)
    {
        Print("OrderSend() error - ", ErrorDescription(GetLastError()));
    }
Alain Verleyen
Moderator
28536
Alain Verleyen 2014.04.26 18:31  
sheriffonline:
Yes. here is the OrderSend() code:

What are the value of price,SL,TP and current bid/ask for USDJPY ? You have to print these values to check what happens.
Sherif Hasan
7223
Sherif Hasan 2014.04.26 18:54  
angevoyageur:
What are the value of price,SL,TP and current bid/ask for USDJPY ? You have to print these values to check what happens.


Here is the values found from journal.


2014.04.27 00:15:58.734 2014.04.25 04:00 KULDU GBPUSD,M30: open #10 buy stop 0.10 GBPUSD at 102.60700 sl: 102.60200 tp: 102.61700 ok

whroeder1
13602
whroeder1 2014.04.26 19:49  
   double price = NormalizeDouble(Hval, NDigits) + PriceOffset*PipValue*Point;
For other pairs you can't use ANY predefines
/
To add comments, please log in or register