Dukascopy
 
 
Wiki JStore Search Login

1 long & 1 short position only
 Post subject: 1 long & 1 short position only Post rating: 0   New post Posted: Sun 07 Sep, 2014, 23:17 

User rating: 0
Joined: Tue 26 Aug, 2014, 21:19
Posts: 15
Location: United KingdomUnited Kingdom
Hello

I've learnt how to limit the number of open positions to 1.

However, I can't figure out how to limit the number of open positions to 1 long and 1 short at any time & then open no more orders?

Thanks :)


 
 Post subject: Re: 1 long & 1 short position only Post rating: 0   New post Posted: Tue 09 Sep, 2014, 15:09 
Visual JForex expert at Dukascopy
User avatar

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

There is several ways to do this depending on your strategy; Here is one way for instance: You need to use the position viewer block and store the variable related to your open positions then use the the Boolean variable "Position is Long" to differentiate long/short positions.


 
 Post subject: Re: 1 long & 1 short position only Post rating: 0   New post Posted: Wed 10 Sep, 2014, 08:14 

User rating: 0
Joined: Tue 26 Aug, 2014, 21:19
Posts: 15
Location: United KingdomUnited Kingdom
thank you, I will experiment :)


 
 Post subject: Re: 1 long & 1 short position only Post rating: 0   New post Posted: Wed 10 Sep, 2014, 13:03 

User rating: 0
Joined: Tue 26 Aug, 2014, 21:19
Posts: 15
Location: United KingdomUnited Kingdom
Hi

I am experimenting with no luck & I can't post .vfs because the board is full so here is a picture.

Strategy is working opening pending orders so if a position is long or short is already defined...

Its just I would like only one short & one long open at any time,

so maybe it has to be if a sell position is open then no more sell pending orders are placed, but one buy order can still be placed and then no more until a position hits a stop loss?

Any more help gratefully received :)

Thank you!

Image


 
 Post subject: Re: 1 long & 1 short position only Post rating: 0   New post Posted: Fri 12 Sep, 2014, 10:15 

User rating: 0
Joined: Tue 26 Aug, 2014, 21:19
Posts: 15
Location: United KingdomUnited Kingdom
Hello, still struggling with this :)

I have added the blocks below to the strategy, but it closes the old position when a new one is filled... I have tried using the variable Pending Positions amount in the positions viewer but that doesn't work.

What am i doing wrong?

Thanks :D

Image

Sorry these variables are My_Pos.Position is Long true and the other false

and Pending Positions. Positions Amount = 1


 
 Post subject: Re: 1 long & 1 short position only Post rating: 0   New post Posted: Fri 12 Sep, 2014, 12:03 

User rating: 0
Joined: Tue 26 Aug, 2014, 21:19
Posts: 15
Location: United KingdomUnited Kingdom
Tried to define pending long or short and cancel/close if more than 1

Not working :( :)

Image


 
 Post subject: Re: 1 long & 1 short position only Post rating: 0   New post Posted: Fri 12 Sep, 2014, 13:05 

User rating: 0
Joined: Tue 26 Aug, 2014, 21:19
Posts: 15
Location: United KingdomUnited Kingdom
am I getting warmer?

Image


 
 Post subject: Re: 1 long & 1 short position only Post rating: 0   New post Posted: Fri 12 Sep, 2014, 13:25 
Visual JForex expert at Dukascopy
User avatar

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

Sorry for the late reply

If your need is to limit Long & Short positions only to one then this is it :)


Attachments:
LongVsShort.vfs [28.34 KiB]
Downloaded 187 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: 1 long & 1 short position only Post rating: 0   New post Posted: Fri 12 Sep, 2014, 14:35 

User rating: 0
Joined: Tue 26 Aug, 2014, 21:19
Posts: 15
Location: United KingdomUnited Kingdom
Hi Amine :)

Many thanks for the reply, this almost works but it doesn't place new orders after a position is stopped.

I tried it with my strategy too and it only works once.. I'd like to be able to place a new pending short if the short gets stopped and a new pending long when the long stops but still only one position per side, is that possible?

Thanks for your time!


 
 Post subject: Re: 1 long & 1 short position only Post rating: 0   New post Posted: Fri 12 Sep, 2014, 14:43 
Visual JForex expert at Dukascopy
User avatar

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

Then you have to reset the logic variables (Booleans) back to their initial value in order to trade again.
Check the attached example, you may need to add your trading period filter ...


Attachments:
OC.vfs [36.6 KiB]
Downloaded 180 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: 1 long & 1 short position only Post rating: 0   New post Posted: Fri 12 Sep, 2014, 22:03 

User rating: 0
Joined: Tue 26 Aug, 2014, 21:19
Posts: 15
Location: United KingdomUnited Kingdom
Hi Amine! That is so great!! I don't understand how the assign blocks work but thank you :) :D


 

Jump to:  

cron
  © 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