Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Is there any considerable differences between Jforex and MQL concepts?
 Post subject: Is there any considerable differences between Jforex and MQL concepts? Post rating: 0   Post Posted: Mon 23 Jul, 2012, 05:44 
User avatar

User rating: 0
Joined: Mon 23 Jul, 2012, 05:36
Posts: 10
Location: CanadaCanada
Am a newbie in Jforex and am considering Jforex for implementing my strategy .Although it sounds better than MQL ,It lacks from good examples and resources.
I don't know if all the rule in MQL4 is also applied to Jforex or not.
For example
For a long position :
Take profit :Ask+dblTakeProfit*mypoint
Stoploss :Bid-dblStopLoss*mypoint

Short position
Take profit :Bid-dblTakeProfit*mypoint
Stoploss :Ask+dblStopLoss*mypoint

but it seems these rules are converse here.Why in the following function
for long order Bid price ,and for short ASK have been used?


https://www.dukascopy.com/wiki/#Simple_Strategy

 private IOrder submitOrder(double amount, OrderCommand orderCmd, double takeProfitPips) throws JFException{
    double stopLossPrice, takeProfitPrice;
    //Calculating stop loss and take profit prices
    if (orderCmd == OrderCommand.BUY){
        stopLossPrice = history.getLastTick(this.instrument).getBid() - this.stopLossPips * this.instrument.getPipValue();
        takeProfitPrice = history.getLastTick(this.instrument).getBid() + takeProfitPips * this.instrument.getPipValue();
    }else {
        stopLossPrice =  history.getLastTick(this.instrument).getAsk() + this.stopLossPips * this.instrument.getPipValue();
        takeProfitPrice = history.getLastTick(this.instrument).getAsk() - takeProfitPips * this.instrument.getPipValue();
    }             
    //Submitting an order for the specified instrument at the current market price             
    return engine.submitOrder(getLabel(orderCmd), this.instrument, orderCmd, amount, 0, 20, stopLossPrice, takeProfitPrice);   
}


 
 Post subject: Re: Is there any considerable differences between Jforex and MQL concepts? Post rating: 0   Post Posted: Mon 23 Jul, 2012, 07:23 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
brazandeh wrote:
Why in the following function for long order Bid price ,and for short ASK have been used?
It is clearly not the case. SL and TP of a long order are short orders.


 
 Post subject: Re: Is there any considerable differences between Jforex and MQL concepts? Post rating: 0   Post Posted: Mon 23 Jul, 2012, 14:59 
User avatar

User rating: 0
Joined: Mon 23 Jul, 2012, 05:36
Posts: 10
Location: CanadaCanada
API Support wrote:
It is clearly not the case. SL and TP of a long order are short orders.

I didn't get that.could you please shed light on it more.
As far as I know:
Buy=Long
Sell=Short
but seems like your definitions are just the opposite.


 
 Post subject: Re: Is there any considerable differences between Jforex and MQL concepts? Post rating: 0   Post Posted: Mon 23 Jul, 2012, 15:09 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
brazandeh wrote:
As far as I know:
Buy=Long
Sell=Short
but seems like your definitions are just the opposite.
No they are not, stop loss of a position is in opposite direction than the position's direction - if you make a BUY order then the stop loss of it will be a SELL order.


 
 Post subject: Re: Is there any considerable differences between Jforex and MQL concepts? Post rating: 0   Post Posted: Tue 24 Jul, 2012, 07:13 
User avatar

User rating: 0
Joined: Mon 23 Jul, 2012, 05:36
Posts: 10
Location: CanadaCanada
API Support wrote:
No they are not, stop loss of a position is in opposite direction than the position's direction - if you make a BUY order then the stop loss of it will be a SELL order.

Yes you are right on the stop loss and i changed my mistakes in the first post
,now the problem is about take profit
we use something like these in MQL:
  ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"buy opened",255,0,Lime);
  ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss*Point,Bid-TakeProfit*Point,"sell opened",255,0,Red);

,so in my opinion the java code should be changed like this(changes in Red) :

private IOrder submitOrder(double amount, OrderCommand orderCmd, double takeProfitPips) throws JFException{
double stopLossPrice, takeProfitPrice;
//Calculating stop loss and take profit prices
if (orderCmd == OrderCommand.BUY){
stopLossPrice = history.getLastTick(this.instrument).getBid() - this.stopLossPips * this.instrument.getPipValue();
takeProfitPrice = history.getLastTick(this.instrument).getAsk() + takeProfitPips * this.instrument.getPipValue();
}else {
stopLossPrice = history.getLastTick(this.instrument).getAsk() + this.stopLossPips * this.instrument.getPipValue();
takeProfitPrice = history.getLastTick(this.instrument).getBid() - takeProfitPips * this.instrument.getPipValue();
}
//Submitting an order for the specified instrument at the current market price
return engine.submitOrder(getLabel(orderCmd), this.instrument, orderCmd, amount, 0, 20, stopLossPrice, takeProfitPrice);
}


 
 Post subject: Re: Is there any considerable differences between Jforex and MQL concepts? Post rating: 0   Post Posted: Tue 24 Jul, 2012, 07:27 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
brazandeh wrote:
so in my opinion the java code should be changed like this(changes in Red) :

private IOrder submitOrder(double amount, OrderCommand orderCmd, double takeProfitPips) throws JFException{
double stopLossPrice, takeProfitPrice;
//Calculating stop loss and take profit prices
if (orderCmd == OrderCommand.BUY){
stopLossPrice = history.getLastTick(this.instrument).getBid() - this.stopLossPips * this.instrument.getPipValue();
takeProfitPrice = history.getLastTick(this.instrument).getAsk() + takeProfitPips * this.instrument.getPipValue();
}else {
stopLossPrice = history.getLastTick(this.instrument).getAsk() + this.stopLossPips * this.instrument.getPipValue();
takeProfitPrice = history.getLastTick(this.instrument).getBid() - takeProfitPips * this.instrument.getPipValue();
}
//Submitting an order for the specified instrument at the current market price
return engine.submitOrder(getLabel(orderCmd), this.instrument, orderCmd, amount, 0, 20, stopLossPrice, takeProfitPrice);
}
This is also not true, go to platform and make a manual order on a tick chart with close SL and TP values (say 2 pips) and you will clearly see that both TP and SL get executed by the same offer side (i.e. either by BID or ASK). You can also manually move the SL and TP lines to check that this is the case.


 
 Post subject: Re: Is there any considerable differences between Jforex and MQL concepts? Post rating: 0   Post Posted: Tue 08 Jan, 2013, 06:02 

User rating: 0
Joined: Tue 08 Jan, 2013, 05:36
Posts: 1
Location: Egypt, Alexandria
Dear brazandeh
every position consist of two orders at least, ex. the "Buy position" began with oder the broker to BUY specific Asset (now you acquire-have-this asset),

then you decide to eliminate this asset -regardless that you see that it gain enough profit or you don't want more losses-;So you give the broker the oder to redeem it (Close), now the broker will get your Asset (position) and sell in in the Market

he will sell it in the market at Bid price

conclusion :
Buy order is settled at ASK price
Close Buy order settled at Bid price

Sell order is settled in the market at BID price
Close Sell order settled in the market at ASK price


I hope it's clear to understand, and there is more Tricks but i like to keep it simple.
And i am sorry to reopen this thread but it was the Google result.


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com