Dukascopy
 
 
Wiki JStore Search Login

Take profit rule - First profitable open
 Post subject: Take profit rule - First profitable open Post rating: 0   New post Posted: Thu 07 Dec, 2017, 23:29 

User rating: 1
Joined: Fri 04 Apr, 2014, 23:12
Posts: 10
Location: Czech Republic,
Hi,

I have successfully built a strategy and finished with building block "Open at Market" but I do not know how to correctly define following TAKE PROFIT rule for LONG trade:

If there is an open trade position, wait until the next bar open is higher than the opening price of the trade and then Take Profit.

Can you pelase help me to define correct building blocks in Visual JForex?

Thank you,
CZforexman


 
 Post subject: Re: Take profit rule - First profitable open Post rating: 1   New post Posted: Fri 08 Dec, 2017, 17:29 
Visual JForex expert at Dukascopy
User avatar

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

Well there is several ways to do that:
You can use: and IF to check the number of open positions =1 this to make sure a position is opened.
Then depending on the position side, you can wait till the candle finishes to check the next open price : Do this with a counter just after the above IF (Counter+1=counter)
Then if counter =1 Get open price from Last candle: Open price and compare it with the previous (use get historical candle to get the previous)
Then IF the above is confirmed --> Set Take pofit.

I'd probably need your strategy in VFS format


 
 Post subject: Re: Take profit rule - First profitable open Post rating: 0   New post Posted: Wed 13 Dec, 2017, 01:08 

User rating: 1
Joined: Fri 04 Apr, 2014, 23:12
Posts: 10
Location: Czech Republic,
Ok, thank you for your replay.

There is one important aspect. The strategy has to check every new OPEN price (daily bars) against the original FILL PRICE of the trade.
If the OPEN price of the new bar is higher than the original FILL price = TAKE PROFIT.

I did not figure out how to easily do that.

Attached I am sending the file.

Additional question: For this type of strategy - is it better to use "onCandle" or "onTick"?

Many Thanks,
CZforexman


 
 Post subject: Re: Take profit rule - First profitable open Post rating: 0   New post Posted: Wed 13 Dec, 2017, 07:50 
User avatar

User rating: 5
Joined: Thu 04 Aug, 2016, 04:51
Posts: 61
Location: CanadaCanada
Greetings CZForexMan,

There are many different available ways for us to setup up the logic for executing what you desire and frankly, the most suitable approach will depend on the overall layout of blocks in your VFS file. Since you have uploaded only a .java version of your strategy, pardon me if my example's setup of blocks happen to conflict with your strategy and if in case it does, then you can change the choice from a "Daily Candle Open Price" to a "Daily Candle Close Price" and retest your strategy.

Also, I am very sure that Mr.Chourou can help you much more better and setup an example of the blocks more accurately for you, but for that he will need the VFS file of your strategy. So please do kindly upload it to your thread here if in case you needed any further assistance.

As for your last question, both OnCandle StartPoint and OnTick StartPoint can be used and neither choice make much of a difference for what you are trying to achieve.

Image


 
 Post subject: Re: Take profit rule - First profitable open Post rating: 0   New post Posted: Thu 14 Dec, 2017, 15:30 

User rating: 1
Joined: Fri 04 Apr, 2014, 23:12
Posts: 10
Location: Czech Republic,
OK, I tried both approaches with the "Counter" and "Position Viewer" but without success. The trade does not get closed.
As mentioned, teh strategy shoud check each new candle if open price of the candle is higher than the fill price.
I think the hell is probably in the detail, so I am uploading VFS file with the basic structure.
Your builds are very much appreciated.


 
 Post subject: Re: Take profit rule - First profitable open Post rating: 0   New post Posted: Thu 14 Dec, 2017, 16:20 
User avatar

User rating: 5
Joined: Thu 04 Aug, 2016, 04:51
Posts: 61
Location: CanadaCanada
Greetings again,

Use a Multiple-Action component after the IF block defining the strategy's default period to separate the logic for opening an Open at Market position and closing it based on the daily candle open price. Otherwise using a continuing loop to close an open position will require all the same conditions that are set in place for opening a position in the first place.

Also the entire layout of blocks for closing an open position based on the daily candle's open price are not set up as explained to you initially by Mr.Chourou or how they are presented in the screenshot above.

Please put some more effort in to your work and if you still couldn't resolve the issue with your strategy, then upload the latest version of your work completed.


Good luck!


 
 Post subject: Re: Take profit rule - First profitable open Post rating: 0   New post Posted: Thu 14 Dec, 2017, 20:42 

User rating: 1
Joined: Fri 04 Apr, 2014, 23:12
Posts: 10
Location: Czech Republic,
Well, I am not a programmer, do try my best but still not working.
My "logic" is probably different to the logic of VJF..

I have attached my latest attempt.


 
 Post subject: Re: Take profit rule - First profitable open Post rating: 0   New post Posted: Fri 15 Dec, 2017, 04:10 
User avatar

User rating: 5
Joined: Thu 04 Aug, 2016, 04:51
Posts: 61
Location: CanadaCanada
Hello,

The great thing about the Visual JForex Flash Editor is that we do not need to be programmers to create our own automated trading strategies but we must be acquainted with it or least, have the basic knowledge of how the VJForex blocks work and there are a ton of materials available for us from which we can learn. The most helpful of all is the "User Guide" .PDF file that can be accessed directly at anytime from the Visual JForex Flash Editor. Also, there are hundreds of threads on the forum here with various good topics, containing example VFS files uploaded by the Dukascopy's own Visual JForex Experts, especially you should look at some of the ones created by Mr.Chourou. Useful past tutorial webinars available on the Dukascopy Youtube channel and articles written by the Dukascopy Community members can greatly benefit you as well to learn about the Visual JForex Flash Editor. Nonetheless, you can make a request from [email protected] for a one-on-one webinar and it is totally free!!

Now, as for your latest changes made to your strategy compared to its first version, I am impressed and I do believe that you are a fast learner. However, I did make some changes to it to the best of my knowledge. Should your strategy still give you any trouble, then please forgive me as I am in the early learning stage as well. Please look at the following screenshot to note the changes made.

Image


 
 Post subject: Re: Take profit rule - First profitable open Post rating: 1   New post Posted: Fri 22 Dec, 2017, 00:09 

User rating: 1
Joined: Fri 04 Apr, 2014, 23:12
Posts: 10
Location: Czech Republic,
Thank you FXRabbit, your input and proposed changes set me to the right direction. I still have to fine-tune a lot but my trades are properly closed now.


 
 Post subject: Re: Take profit rule - First profitable open Post rating: 0   New post Posted: Fri 22 Dec, 2017, 07:36 
User avatar

User rating: 5
Joined: Thu 04 Aug, 2016, 04:51
Posts: 61
Location: CanadaCanada
You are welcome and I am glad to know that I was of assistance to you. :)


 

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