Quick Question

 

Hey Guys, new member, been writing in MQL4 for a few weeks know and have a quick question:

Originally started my code on a 4 digit broker and for TP calculation have

ACCTTP = Ask + (take profit * point)

(take profit = 100)

switch to 5 digit broker and it shifts it back to 10 (which I understand why). But how do I get ACCTTP to be 100 on both 4 & 5 digit brokers?

Thanks

Bauer_Boy

 

int MyDig;

int init()

{

...

if(MarketInfo("EURUSD",MODE_DIGITS)==4) MyDig=1; else MyDig=10;

...

}

int start()

{

...

ACCTTP = Ask + (take profit * Point*MyDig);

...

)

 
Roger thank you for your input but now it seems i'm getting order send error 130 (invalid stop/tp) and can't seem to find out how (been trying to track it down for the past few hours).  Thanks for any more help you could give.  See my buy order send function below



    if(isBuying && !isSelling) 
         {  
           if(stopLoss > 0)
               ACCTSL = Ask - (stopLoss*Point*MyDig);

           if(takeProfit > 0)
               ACCTTP = Ask + (takeProfit*Point*MyDig);
           // Buy
           ticket = OrderSend(Symbol(), OP_BUY, lots, NormalizeDouble(Ask,5), slippage, ACCTSL,ACCTTP, 
                    nameEA, 16384,0,Red);  
                    Print ("Stop Loss Value", ACCTSL);
                    Print ("Take Profit Value", ACCTTP);
 

OK

1. Don't normalize Ask or Bid.

2. Show us your Stop and Take from your logs.

 
Make sure ACCTSL and ACCTTP are declared as doubles. You also need to make sure that the stoploss is large enough. Do the same calculations on ACCTSL as you do with ACCTTP before you place the order otherwise an intended stop of 10 pips will only be 1 pip.
 
fxcourt wrote >>
Make sure ACCTSL and ACCTTP are declared as doubles. You also need to make sure that the stoploss is large enough. Do the same calculations on ACCTSL as you do with ACCTTP before you place the order otherwise an intended stop of 10 pips will only be 1 pip.

Hey guys, thanks for your help, I'm still having problems here's what I'm getting


2009.08.05 08:07:02 Trender Beta Test EURUSD,H1: OrderSend (Trender Beta Test) failed with error #130

2009.08.05 08:07:02 Trender Beta Test EURUSD,H1: Take Profit Value1.4596
2009.08.05 08:07:02 Trender Beta Test EURUSD,H1: Stop Loss Value1.4196

ACCTSL & ACCTTP are declared as doubles


if(isBuying )
{
if(stopLoss > 0)
ACCTSL = Ask - (stopLoss*Point*MyDig);

if(takeProfit > 0)
ACCTTP = Ask + (takeProfit*Point*MyDig);
// Buy
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage,ACCTSL,ACCTTP,
nameEA, 16384,0,Red);
Print ("Stop Loss Value", ACCTSL);
Print ("Take Profit Value", ACCTTP);

 
Bauer_Boy wrote >>

Hey Guys, new member, been writing in MQL4 for a few weeks know and have a quick question:

Originally started my code on a 4 digit broker and for TP calculation have

ACCTTP = Ask + (take profit * point)

(take profit = 100)

switch to 5 digit broker and it shifts it back to 10 (which I understand why). But how do I get ACCTTP to be 100 on both 4 & 5 digit brokers?

Thanks

Bauer_Boy

Please see 'Damn Error 130 to Hell'

may help...

 
Bauer_Boy:

Hey guys, thanks for your help, I'm still having problems here's what I'm getting


2009.08.05 08:07:02 Trender Beta Test EURUSD,H1: OrderSend (Trender Beta Test) failed with error #130

2009.08.05 08:07:02 Trender Beta Test EURUSD,H1: Take Profit Value1.4596
2009.08.05 08:07:02 Trender Beta Test EURUSD,H1: Stop Loss Value1.4196

ACCTSL & ACCTTP are declared as doubles


if(isBuying )
{
if(stopLoss > 0)
ACCTSL = Ask - (stopLoss*Point*MyDig);

if(takeProfit > 0)
ACCTTP = Ask + (takeProfit*Point*MyDig);
// Buy
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage,ACCTSL,ACCTTP,
nameEA, 16384,0,Red);
Print ("Stop Loss Value", ACCTSL);
Print ("Take Profit Value", ACCTTP);

double IN = 100;

if(Digits == 5 || Digits == 3)

{

IN = IN / MathPow(10,Digits - 1);

}

if(Digits == 4 || Digits == 2)

{

IN = IN / MathPow(10,Digits);

}


Is MyDig a double also? Also what was the entry price?

I assume this EA places sell orders too. For sell orders make sure you are using the bid price and that you calculate the stop loss as entry price + stop pips.

 
And make sure the stop is not too small. Get the stop level from marketinfo and make sure that it is less than your stop.
 

-> Bauer_Boy


Some brokers insist that you perform your OrderSend() with stops (SL & TP) set to zero, in which case you will subsequently OrderSelect() that order and use OrderModify() to set the stops to the desired value.

If this is indeed the case, the following will return a value of zero:

Print("Broker stop level = ",MarketInfo(Symbol(),MODE_STOPLEVEL));


CB

 
cloudbreaker wrote >>

-> Bauer_Boy

Some brokers insist that you perform your OrderSend() with stops (SL & TP) set to zero, in which case you will subsequently OrderSelect() that order and use OrderModify() to set the stops to the desired value.

If this is indeed the case, the following will return a value of zero:

CB

Thank you CB, that was it

Reason: