Dukascopy
 
 
Wiki JStore Search Login

How to close/cancel/ all open positions on the 28th of every month
 Post subject: How to close/cancel/ all open positions on the 28th of every month Post rating: 0   New post Posted: Mon 03 Aug, 2015, 17:49 
User avatar

User rating: 0
Joined: Wed 22 Feb, 2012, 12:24
Posts: 44
Location: Romania, Bucharest
Because my strategy is in a slow motion and take only 12-16 positions per month i have to upgrade it with a faster one at the end of the month. In this respect i want to close all positions opened on the 28th of a month in order being able to upload a new faster strategy.
I hope you understand .


 
 Post subject: Re: How to close/cancel/ all open positions on the 28th of every month Post rating: 0   New post Posted: Mon 03 Aug, 2015, 23:13 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi...

In my view, you do not need to load a faster strategy... You can have both strategies in one. You check if day => 28...

no ->initial strategy fluxogram
yes -> if (not closed positions boolean variable) -> true -> close all positions -> set variable to false -> second strategy fluxogram
false -> second strategy fluxogram

I hope this help... no time no make some strategy blocks.

Regards

JL


 
 Post subject: Re: How to close/cancel/ all open positions on the 28th of every month Post rating: 0   New post Posted: Tue 04 Aug, 2015, 17:02 
User avatar

User rating: 0
Joined: Wed 22 Feb, 2012, 12:24
Posts: 44
Location: Romania, Bucharest
Thank for your help....but i am still new in Visual IF. I have made some progress, but this issue i don't know to implement at all.
If you don't mind i uploaded a simple strategy in hope you will translate your last message in this VFS. file.
Thanks in advance.


Attachments:
File comment: a simple strategy
May.vfs [32.66 KiB]
Downloaded 78 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: How to close/cancel/ all open positions on the 28th of every month Post rating: 0   New post Posted: Tue 04 Aug, 2015, 18:03 
Visual JForex expert at Dukascopy
User avatar

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

I've inserted the modifications as per your description but did not test the attached file.
Please test and keep us posted.
PS: the lot amount is in millions by default so when you input 10 --> 10millions

Cheers


Attachments:
May_V2.vfs [43.89 KiB]
Downloaded 87 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: How to close/cancel/ all open positions on the 28th of every month Post rating: 0   New post Posted: Tue 04 Aug, 2015, 18:24 
User avatar

User rating: 0
Joined: Wed 22 Feb, 2012, 12:24
Posts: 44
Location: Romania, Bucharest
It works :D . Thank you very much.


 
 Post subject: Re: How to close/cancel/ all open positions on the 28th of every month Post rating: 0   New post Posted: Wed 05 Aug, 2015, 12:10 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi

Regarding my last post i made a prototype of a strategy that can run both of the strategies if you place there the code blocks of them.

You have a variable "myday" where you can set the day of month to close positions and change "strategy".
This way you do not need to replace the strategy.

It's only a prototype, not tested, see the notes on it.

Regards

JL

PS: the example provided from anime do not prevent the strategy to open new orders after 28 00:00. Only closes open positions after this date but you can have orders triggered after that will be closed soon as they are opened...


Attachments:
strat2x.vfs [28.98 KiB]
Downloaded 66 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: How to close/cancel/ all open positions on the 28th of every month Post rating: 0   New post Posted: Wed 05 Aug, 2015, 13:04 
Visual JForex expert at Dukascopy
User avatar

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

Thanks for your interactions in this forum, it is indeed great to see some users sharing their knowledge which gives another view in terms of programming ideas.

The use of Boolean variables is interesting and opens the door to more complicated ideas when correctly implemented. Your example shows the way to use a logical trigger using the variable "Strategy1Run" = True/False but you missed a detail :
- when the date is equal or greater than 28 means the 28th, 29th, 30th and 31st (31st if applicable) the strategy will close all open positions where the need is to close only on the 28th
- You are using OnTick start where the verification that you are doing is simply day check --> It could be made using OnCandle start which will save you a lot of threads and performance when it comes to Live run.
- I believe the same job can be done using a single Boolean variable and not 2 .. can you do it ? ;)
- Now that we are brainstorming... imagine that you don't have the built-in variable "Date and time" nor the block "Get time unit" .. how can you look for the 28th ?? :)

Cheers


 
 Post subject: Re: How to close/cancel/ all open positions on the 28th of every month Post rating: 0   New post Posted: Wed 05 Aug, 2015, 16:17 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi

I used the OnTick node because i don't know the period used by the user on OnCandle ... I know that is more cpu intensive, but that way i covered all possibilities. In the last post i tought about that and i was about how to explain how to use OnCandle using multiple action block at start of OnCandle node where we can use a period more friendly to cpu utilization. But the user says that he don't know much about VJF, so i tried to take the more simple aproach, eventualy not the more correct.

Just a comment about your comments: yes, you close the orders only at day 28, no discution here, but you also close all orders open on that day as you use period 10 min (it will be executed 144 x that day).

Also i have other boolean variable to close the orders only one time - closed_1_strat_orders. That way the close orders is only executed once. After, the close orders is responsability of the other strategy if applicable.

Yes, you can use just one variable, but at that time not thinked about... we can use the first boolean variable used to chose the path of the strategy.

Regarding your question... at least we need some time reference... i supose the existence of the timestamp on candle object... regarding the existence of only a timestamp, we get the timestamp of the montly bar (running bar on candle history), get the timestamp of a candle with a smaller period (10 sec for example), take the diference and if it is greater than 1000ms x 60sec x 60min x 24h x 28days do something. I think you understand the ideia.

Regards

JL

Edit: i place in annex a prototype using OnCandle node and only one boolean variable. Also not tested, just done with block logic.

Edit2: i make a erroneous afirmation before: on "(it will be executed 144 x that day)" it's not true... it will be executed if any order is open during any period different of 10 min period on the 28 day and the order closed (in the better scenario the order only lives 10 sec).


Attachments:
strat2xv2.vfs [29.27 KiB]
Downloaded 75 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: How to close/cancel/ all open positions on the 28th of every month Post rating: 0   New post Posted: Thu 06 Aug, 2015, 11:06 
Visual JForex expert at Dukascopy
User avatar

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

I see... nice workaround!
I used the exit != from 10mn which basically means every 10 seconds checks. It is correct that the check will be made every 10 secs and any open position (not pending order) will be closed. To make this more accurate, we can add a specific time (Hour/Mn) so that the close will be done once every 28th. Another way could be to add an additional IF block that filter out periods on daily basis (Period = day) thus you'll have a single flow per day

Regarding the second question, there is a way to do this without any time stamp actually:
Filter periods as daily / then place a counter that increments every day / Once 28th is reached you close the position
One constraint is to be highlighted here: The strategy should be started at the 1st of the month otherwise the counter will retrieve the wrong day number i.e day date

Cheers


 
 Post subject: Re: How to close/cancel/ all open positions on the 28th of every month Post rating: 0   New post Posted: Thu 06 Aug, 2015, 14:40 
Visual JForex expert at Dukascopy
User avatar

User rating: 288
Joined: Thu 18 Apr, 2013, 09:26
Posts: 1496
Location: Switzerland, Geneva
In the meantime, I have some comments regarding the example posted previously:

- It works only once as you did not reset the variable "strategy1run" back to its initial value once the 28th passed
- what do you mean by your comment [ "on '=' node you place slow strategy blocks. on '!=' node you place fast trategy blocks ]? can you elaborate on "slow/fast strategy blocks" ??

attached a version with corrections ...


Attachments:
strat2x_V3.vfs [28.27 KiB]
Downloaded 76 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: How to close/cancel/ all open positions on the 28th of every month Post rating: 0   New post Posted: Thu 06 Aug, 2015, 21:30 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi

By the question posted by the user, my view is he wants to close all orders at 28º day of the month if any remains open with actual strategy to start another strategy. This because in terms of strategy contest, as the first strategy do not fill the required number of orders (20) to be on top prize winners. Starting a second strategy that opens and closes a number of orders that fill the required gap (12/16 orders from first strategy to 20 at least with second strategy) in a fastest way. My ideia is to provide a prototype that can have both strategies (for the prototype i supose the OnCandle node is used on both strategies). So, i verify the day, if less than 28 or other defined day, it runs on '=' node of the left if where we check strategy1run is allowed. When the day arrives, we try to close all orders and set to false strategy1run... this way, on the left if, the path wil be "!=" node. to achieve this, it's needed to place all strategy 1 blocks connected to '=' as it was conected to oncandle on original strategy and all the second strategy block on '!=' node. With this way no need to manually stop/remove strategy1 to place strategy 2. I do not take care of resetting the strategy1run as it don't is need to strategy contest as every month you need to start the strategy. But reseting to start is easily done, on multiple action node place a if for period monthly and on each received candle resets to true the boolean variable and it will change to "strategy1".

Also it can be used as a starting point to elaborate strategies more complex where several strategies can run at same time depending on conditions we want to check.

I've done a fast look to the example changes you provided and do not understand want is wanted from that prototype (run only one strategy ?)

I hope i make some sense this time

Regards

JL

Image


Attachments:
2015-08-06_2124.png [90.83 KiB]
Downloaded 439 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: How to close/cancel/ all open positions on the 28th of every month Post rating: 0   New post Posted: Fri 07 Aug, 2015, 10:12 
Visual JForex expert at Dukascopy
User avatar

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

Well, thanks for your efforts.
The workaround made here is a way to explore more ways by adding logical triggers for instance for learning and knowledge-sharing purpose regardless of the strategy contest. The goal is to be able to implement ideas in combinations of blocks.

Cheers


 

Jump to:  

  © 1998-2024 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