Dukascopy
 
 
Wiki JStore Search Login

Position amount 1 long and 1 short
 Post subject: Position amount 1 long and 1 short Post rating: 0   New post Posted: Thu 06 Feb, 2014, 21:26 
User avatar

User rating: 0
Joined: Wed 25 Sep, 2013, 17:33
Posts: 28
Hey guys,
how is it possible to make a strategy for example to only open a maximum of 2 positions, a long one and a short one. So if there is already an open long positions, the strategy couldn't open any more long positions, only if requirements met a short position, same the other way around.

restricting the strategy from opening more than a certain amount of positions is easy though I haven't figured it out yet how to restrict it on a certain amount of short and long positions.

id'll be great if anyone could take the time.

thanks,
artur


 
 Post subject: Re: Position amount 1 long and 1 short Post rating: 0   New post Posted: Fri 07 Feb, 2014, 09:30 
Visual JForex expert at Dukascopy
User avatar

User rating: 27
Joined: Fri 03 May, 2013, 18:25
Posts: 366
Location: GermanyGermany
Greetings!

You can do it by assigning a counter-variable after each Open at market, which lets you count the number of long and short positions.

I do not know what you want to program but this would be the easiest way to do it. There are couple of more possibilities of how this could be done...

Maybe you try to implement that and if you have problems please post the strategy... Maybe we have to do something else in order to make it work (it roughly depends on the logic)

Cheers


 
 Post subject: Re: Position amount 1 long and 1 short Post rating: 0   New post Posted: Fri 07 Feb, 2014, 10:22 
User avatar

User rating: 0
Joined: Wed 25 Sep, 2013, 17:33
Posts: 28
thanks, i'll try ...


 
 Post subject: Re: Position amount 1 long and 1 short Post rating: 0   New post Posted: Thu 13 Mar, 2014, 17:08 
User avatar

User rating: 0
Joined: Wed 25 Sep, 2013, 17:33
Posts: 28
https://screencast.com/t/SBCS5xRn28

What am I doing wrong? My idea is to only allow short trades after long trades and long trades after short trades. I tested the strategy and it stopped opening positions after the first trade.

thx in advance!


 
 Post subject: Re: Position amount 1 long and 1 short Post rating: 0   New post Posted: Fri 14 Mar, 2014, 09:46 
Visual JForex expert at Dukascopy
User avatar

User rating: 27
Joined: Fri 03 May, 2013, 18:25
Posts: 366
Location: GermanyGermany
Greetings!

Ok, in that specific case (like I said before, I do not know the rest of the strat), please have a look at the strat attached. But what you will do, once a position is closed? :P

BTW: If you just want to calculate ALL Long and Short positions each, there is another easy way of how to do it; please find attached.

Cheers :)


Attachments:
count_LS_Pos.vfs [26.33 KiB]
Downloaded 143 times
count_after_fill.vfs [26.71 KiB]
Downloaded 144 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: Position amount 1 long and 1 short Post rating: 0   New post Posted: Fri 14 Mar, 2014, 10:10 
User avatar

User rating: 0
Joined: Wed 25 Sep, 2013, 17:33
Posts: 28
thanks, the idea is to never have two trades in a row open in the same direction. basically to only allow counter positions... even if the strategy receives a heads up for an other long trade after a long trade, it should reject that one until it receives a signal for a short trade and so on.


 

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