INDICATOR ENTRY/EXIT - Bollinger Band with Moving Average 2-line Crossover Filter
Forex Bollinger Band Reversal Strategy with Trend filter
Entry Rule: Wait until price falls below the lower Bollinger band or above the upper band. When price subsequently crosses back above the lower band and closes there, place a buy stop entry order at the last value for the lower band. When price crosses back below the upper band, place a sell stop entry order at the last value for the upper band.
Filter: If "fastlength" and "medlength" inputs are used, strategy may only go long if the "fastlength"-period Simple Moving Average is above the "mediumlength". It may only go short if the opposite is true. "fastlength" and "medlength" are set to 0 by default, which leaves them off. Changing these to non-zero values activates the use of the filter in this Strategy Advisor.
Stop Loss: None by default. It may be entered using "StopLoss" input.
Take Profit: None by default. It may be entered using "ProfitTarget" input.
Exit Rule: The trade is taken out by the opposite signal. Thus if we are long due a cross above the lower band, a cross below the upper band would close the existing long position and establish a short position. The reverse is also true.
Directions: Download the attached .zip file. Go to the directory under which you've unzipped the contents of the file. Open the "BollingerMAFilter.fxd" file and when prompted by the Strategy Language Editor, hit "OK" to import the file. Once you have imported the Strategy Advisor, open the "BollingerMAFilter.fxw" file included in the attached zip to see examples on how you may use this in your charts.
This is an example Strategy Advisor provided for educational purposes only. This has not been coded as a standalone strategy for live trading and is for illustrative purposes only. Though the author has done his best to ensure accuracy and that said code is built to specifications, there is no implicit or explicit guarantee that this code is correct. Past performance is absolutely not a guarantee of future results, and many strategies are built with the benefit of hindsight.
Last edited by Lucas Izidoro; 11-24-2010 at 09:17 AM.
David Rodriguez is the author of Forex Trading Signals and Forex Trading Weekly Forecast on DailyFX.com.
Thanks this is just the example I needed
I have been trying to set up a very similar strat. I am sure this will help me in my quest to learn C#.
Thanks for the feedback. If you have questions on Strategy Trader-specific functions/classes be sure to post them on the forum and I'm sure our moderators and fellow forum members can help you out.
David Rodriguez is the author of Forex Trading Signals and Forex Trading Weekly Forecast on DailyFX.com.
Nice backtest results for sure. For what it's worth, I realized after the fact that my transaction cost assumptions were a bit aggressive. Thus you could assume something like 3 pips and still have a fairly reasonable estimate of real-world transaction costs.
David Rodriguez is the author of Forex Trading Signals and Forex Trading Weekly Forecast on DailyFX.com.
...but why cost assumptions? The usual way is to backtest the strategy with bid/ask prices, which should approximate the different spread throughout the day, right?
...but why cost assumptions? The usual way is to backtest the strategy with bid/ask prices, which should approximate the different spread throughout the day, right?
yes, but to save time when writing these article and researching these topics, I will run it only on bid data so as to run faster optimizations. I'm willing to allow for a minor loss in absolute accuracy for faster backtests, and frankly nothing ever substitutes live trading conditions. Thus I feel doing bid/ask backtests gives you a false sense of confidence in the backtest results.
David Rodriguez is the author of Forex Trading Signals and Forex Trading Weekly Forecast on DailyFX.com.
yes, but to save time when writing these article and researching these topics, I will run it only on bid data so as to run faster optimizations. I'm willing to allow for a minor loss in absolute accuracy for faster backtests, and frankly nothing ever substitutes live trading conditions. Thus I feel doing bid/ask backtests gives you a false sense of confidence in the backtest results.
It would be equally wrong to ruin the backtest as much as possible in order not to have "false sense of security".
According to the code, stoploss is simply the literal price difference you're wanting to set the stop at. When the SL is generated the target price is calulated by subtracting that stoploss input value from the entry price. In your example, .0001 is going to throw a stoploss at 1 pip. In other words, it'll typically hit right after the order is placed. If you were using a yen pair, you'd want to set in terms of pips for yen, i.e. .01
I'd like to ask for some help.
I was talking with Anthony Park, he told me that maybe you could help me with this problem.
If I go to 'Format Strategy Advisor' then 'Format', and I'm trying to enter a profit target or a stop loss like Anthony said ( .0005 for example) I have an error message :
"Input string was not in a correct format"
If I type 0,0005 it is ok, but I don't know how many pip does it means, if it means something valid at all.
So please let me know how to enter the StopLoss and ProfitTarget.
Exit Rule: The trade is taken out by the opposite signal. Thus if we are long due a cross above the lower band, a cross below the upper band would close the existing long position and establish a short position. The reverse is also tru
could you modify this rule to be :
exit rule : only with stop or limit is met , with only one position open ( if we were long due a cross above the lower band ,a cross below the upper band would not close the existing long position and would not establish a short position until the long position meted stop or limit , then the expert could take a new position due a crossing
I'd like to ask for some help.
I was talking with Anthony Park, he told me that maybe you could help me with this problem.
If I go to 'Format Strategy Advisor' then 'Format', and I'm trying to enter a profit target or a stop loss like Anthony said ( .0005 for example) I have an error message :
"Input string was not in a correct format"
If I type 0,0005 it is ok, but I don't know how many pip does it means, if it means something valid at all.
So please let me know how to enter the StopLoss and ProfitTarget.
Thank you!
Croaker
Having chatted with Anthony, it appears you have some internatinoal numbering system on your PC that's different from what the strategy was intended. It's strange, but if 0,0005 works for you, simply continue to use it where you would normally put in 0.0005. Run the strategy on a demo, and then check the trades and just verify that the strategy closes at it's intended price/pip distance.
Disclaimer: Trading foreign exchange on margin carries a high level of risk, and may not be suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to trade foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with foreign exchange trading, and seek advice from an independent financial advisor if you have any doubts. Any opinions, news, research, analyses, prices, or other information contained on this website is provided as general market commentary and does not constitute investment advice. Forex Capital Markets LLC. will not accept liability for any loss or damage, including without limitation to, any loss of profit, which may arise directly or indirectly from use of or reliance on such information.