Dukascopy
 
 
Wiki JStore Search Login

Closing Positions Based on Indicator States.
 Post subject: Closing Positions Based on Indicator States. Post rating: 0   New post Posted: Wed 10 Sep, 2014, 14:02 

User rating: 1
Joined: Mon 01 Sep, 2014, 13:39
Posts: 34
Location: AustraliaAustralia
Hi,

I am testing some strategies and one is open an order when 2 MAs cross. That's fine, but when I put code to test for the converse, i.e. they cross the other way, I can't seem to be able to close the position.

I am using the Close and Cancel Position component with input being the position opened in the Open at Market component.

Shouldn't Position Amount toggle from 1 to 0 as I open and close a single position?

Thanks,
Chrysos.

Edit: I seem to get this message a lot
11.09.2014 10:53:44 Cannot close order in CREATED, CLOSED or CANCELED state, current state - [CLOSED]
11.09.2014 10:53:44 Cannot close order in CREATED, CLOSED or CANCELED state, current state - [CLOSED]
11.09.2014 10:53:44 Cannot close order in CREATED, CLOSED or CANCELED state, current state - [CLOSED]


 
 Post subject: Re: Closing Positions Based on Indicator States. Post rating: 1   New post Posted: Thu 11 Sep, 2014, 13:38 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Hi there,

It is quite difficult to understand your query, Can you please attach your strategy file and explain what is not working as per your specification ?

Thanks


 
 Post subject: Re: Closing Positions Based on Indicator States. Post rating: 0   New post Posted: Fri 12 Sep, 2014, 02:49 

User rating: 1
Joined: Mon 01 Sep, 2014, 13:39
Posts: 34
Location: AustraliaAustralia
Hello Amine ,

Thank you for responding to my query. I am out at the moment, but shall post my strategy later tonight.

Basically I open a short position when the 5EMA crosses the 34EMA from above and I want to close the position when the 5EMA crosses the 34EMA from below.

I open a long position when the 5EMA crosses the 34EMA from below and want to close the position when the 5EMA crosses the 34EMA from above.

I use a MACD filter so I don’t swing from short to long all the time.

I do not want more than 1 position to be open at any time. So I either have 0 or 1 positions.

Do you have a basic example of opening a position and then closing it on the basis of what some indicators say? I do not want to close on a Take Profit Order and I do use a Stop Loss Order.

Thanks,
Chrysos.


 
 Post subject: Re: Closing Positions Based on Indicator States. Post rating: 1   New post Posted: Fri 12 Sep, 2014, 14:36 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
Hi there,

Here is an example of a strategy that open and close positions based on 2 EMA's cross


Attachments:
Webinar5_11.vfs [39.13 KiB]
Downloaded 219 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: Closing Positions Based on Indicator States. Post rating: 0   New post Posted: Sat 13 Sep, 2014, 02:39 

User rating: 1
Joined: Mon 01 Sep, 2014, 13:39
Posts: 34
Location: AustraliaAustralia
Thanks very much Amine,

This looks like what I want. I shall play around with it.

Cheers,
Chrysos.


 

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