Getting StopLoss and TakeProfit Out of OpenOrder line-Prevents Order execution

 

I have been spending a lot of time trying to correct a StopLoss and TakeProfit problem.My Broker

doesn't accept the StopLoss and TakeProfit in the same line of code as the OpenOrderBuy or OpenOrderSell.

I have been very frustrated with this because of 2 reasons. I am not an expert Programmer and I feel that

this should be a fairly easy fix.Also the only EA'S that will open and close orders right now are ones that have

No stops or take Profits. After trying OrderModify that's when I finally gave up. I currently have completed a new

Scalp EA that tests good on the Strategy tester but is useless until I get this problem fixed.This EA requires stops

and target profits. I am putting in the Order part of the code that contains the problem to make it clear and visible.

The real code for this is "I GIVE UP"!!!!!

JimTrader1

Files:
 
2.21 GigaWatts ! ... 2.21 GigaWatts !
 
jimtrader1:

Also the only EA'S that will open and close orders right now are ones that have

No stops or take Profits. After trying OrderModify that's when I finally gave up.

There has been lots written about this . . . ECN stuff
 
//++++ These are adjusted for 5 digit brokers.
int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.015      0.0150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int     init(){
     if (Digits % 2 == 1){      // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
//---- These are adjusted for 5 digit brokers.
    /* On ECN brokers you must open first and THEN set stops
    int ticket = OrderSend(..., 0,0,...)
    if (ticket < 0)
       Alert("OrderSend failed: ", GetLastError());
    else if (!OrderSelect(ticket, SELECT_BY_TICKET))
       Alert("OrderSelect failed: ", GetLastError());
    else if (!OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0)
       Alert("OrderModify failed: ", GetLastError());
     */
 
RaptorUK:
There has been lots written about this . . . ECN stuff


Thanks Raptor. Yeah I think it is the ECN problem. Looks like my question was justified.

I think we can possibly get around it though.

Gonna use your Google search tonight.

Also going to be studying a lot of other EA'S.

JimTrader1

 
WHRoeder:

Thanks very much WHRoeder for the code section. It looks as though hearing from ther other guys, there is a

problem with ECN Brokers. At least with the code you sent me I have something to work with.

Also could you explaing the pips2double and pips2points?

JimTrader1

Reason: