Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Bbands contrarian strategy (problem solved)!
 Post subject: Bbands contrarian strategy (problem solved)! Post rating: 0   New post Posted: Fri 23 Dec, 2011, 07:36 

User rating: 0
Joined: Sun 22 May, 2011, 23:05
Posts: 12
Location: BR
Hello Support,
I used a bolinger strategy formely posted by you guys and made some changes so I fit my strategy rules.
It is to be a contrarian strategy, so when the price (I used bid price in all I think) hits upper bolinger band (the part of the line that is still being draw over the current candle - I think it's shift 0, but I don't know if it really exists) it triggers a sell order with a stoploss previously set. The same happens if it hits the lower band triggering a buy order. I don't understand why the strategy doesn't work. And also I would like to insert a trailing stop so every time the price goes in my favor 10 pips the stop loss would change with it the same amount (should be configurable in best case).
Thanks in advance and happy hollydays in case we don't get in contact till then!! :D :D


Attachments:
File comment: Fixed strategy....ignore the other file!
BBandStrategy2.java [6.86 KiB]
Downloaded 315 times
File comment: Strategy written so far...
BBandStrategy2.java [6.75 KiB]
Downloaded 289 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: Bbands contrarian strategy (problem solved)! Post rating: 0   New post Posted: Tue 27 Dec, 2011, 10:57 

User rating: 0
Joined: Sun 22 May, 2011, 23:05
Posts: 12
Location: BR
Hello guys!
I thought that it was working but the strategy still doesnt work fine. It doesn't open positions on the right price and sometimes it doesn't open any at all when it crosses the bolinger bands (on both sides). Also I am having trouble to make it open just one position at a time (it sometimes has many opened positions on the same side).

If someone could help me out I'd appreciate it!
Thanks and good luck to everyone!


 
 Post subject: Re: Bbands contrarian strategy (problem solved)! Post rating: 0   New post Posted: Tue 27 Dec, 2011, 12:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Consider logging all the relevant values (i.e. prices, indicator values, messages and orders from onMessage etc.) to see what actually happens, see https://www.dukascopy.com/wiki/ section Strategy API/Console/Logging values.


 
 Post subject: Re: Bbands contrarian strategy (problem solved)! Post rating: 0   New post Posted: Thu 29 Dec, 2011, 19:06 

User rating: 0
Joined: Sun 22 May, 2011, 23:05
Posts: 12
Location: BR
First of all THANK YOU ALL!!
You guys are very helpfull!!!

And sorry but I am not capable of doing that log thing....not yet...
I've just started looking on Java programing this month and started on Jforex last week......and I don't know any other language at all...
Still could have made a couple of strategies and used a lot of things posted here (some by you guys and some buy other users), but far beyond being a good programer... :((

And here is my question, since I'm not able to logging....
Does bolinger bands, trenenvelopes and indicators like that do not return a value on the current candle or on tick time? I noticed that on my strategy casualy the order is not triggered and most of the times (if not always) it happens (maybe) because the current candle has not been finished. For example: strategy is to sell when tick bid price is >= than upper band of bolinger band (shift 0)......but the order is only triggered if the current candle gets finished (and the next candle starts) and the price is still above the upper bband.

Thanks again....and I am going to ask a lot more!! (I'll try my best to not ask stupid things)
THANKS!


 
 Post subject: Re: Bbands contrarian strategy (problem solved)! Post rating: 0   New post Posted: Mon 09 Jan, 2012, 10:58 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
In BBandStrategy2 orders are triggered immediately when the price (not bar) is above (or below) BBAND line.
When BBANDS lines are formed they move up and down. Therefore, there may be a situation when highest price of a finished bar is above the BBAND line but the price itself has not been above BBAND.

Also, please check that same time period is used in chart and in strategy parameters, that are specified when running the strategy.

Logging means printing messages from the program.
This article describes how to do it:
https://www.dukascopy.com/wiki/#IConsole


 

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