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.

How to save a market level in a variable
 Post subject: How to save a market level in a variable Post rating: 0   New post Posted: Tue 16 Oct, 2012, 12:29 

User rating: 0
Joined: Tue 16 Oct, 2012, 12:23
Posts: 40
To Dukascopy Forex Support,

I am coding a strategy. I wanted to save the market level at which the strategy opens a trade in a variable. For example, if the strategy takes up a BUY trade for EURUSD at 1.3200, I want to save that value in a variable. Also, I wanted to save another value which is +/- 25 pips to 1.3200 in another variable. Please tell me how to do that.

Thanks. :)

Jimmy.


 
 Post subject: Re: How to save a market level in a variable Post rating: 0   New post Posted: Tue 16 Oct, 2012, 12:53 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
JimmyHowl8 wrote:
I wanted to save the market level at which the strategy opens a trade in a variable.
see https://www.dukascopy.com/client/javadoc/com/dukascopy/api/IOrder.html#getOpenPrice()
JimmyHowl8 wrote:
Also, I wanted to save another value which is +/- 25 pips to 1.3200 in another variable.
double price = 1.3200 - Instrument.EURUSD.getPipValue() * 25;


 
 Post subject: Re: How to save a market level in a variable Post rating: 0   New post Posted: Tue 16 Oct, 2012, 15:05 

User rating: 0
Joined: Tue 16 Oct, 2012, 12:23
Posts: 40
When I define the value at which the trade is opened as

double value = getOpenPrice();

there is an error

The method getOpenPrice() is undefined for the type Strategy.

Do I need to define something else as well first?


 
 Post subject: Re: How to save a market level in a variable Post rating: 0   New post Posted: Tue 16 Oct, 2012, 15:10 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
The method is IOrder.getOpenPrice and it gets applied to an IOrder object.
JimmyHowl8 wrote:
Do I need to define something else as well first?
You need either to create or retrieve the order.


 

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