Hi all,
I've been working on an EA using pivots and it proved to be truly amazingly accurate in predicting overall movement of the signal under normal market conditions.
After working on a number of versions and posting the ex4 file in forex-tsd and strategybuilderFX, I was able to develop ver 4 which is less risky and has a dynamic stoploss mechanism.
The idea is to establish an emergency exit strategy as follows: after waiting for a specific number of bars (time here relevant to chart period), you conclude that time is running out and an exit is a better idea, so try to exit the soonest with the minimum loss possible. The time to wait is defined in the parameter (wait_time_b4_SL).
After that number of bars has passed and we're still not in a profitable status, then wait until you arrive to a point that would have minimum loss. The tolerated loss is increased in time, i.e., the more we wait the more likely the trend is way opposite to our predictions (some news event triggered massive rise/fall in price), so we would accept a larger loss. But in the long-run, this loss could always be recovered (unless a war or so takes place).
Just as the stoploss is dynamic, so is the takeprofit. I'm using the famous saying: "let your profits run & cut your losses".
One thing you will note is that the stoploss feature is based on time, just as everything else in a pivot strategy. Remember, we are not using EMAs, bands and stuff, we are using the pivot assumption/theory that the market will always adjust itself in time. I could have assigned a value for stoploss, but that does not conform to the nature of the use of pivots, which assumes that within a specific timeframe, the price is expected to return to the pivot.
So this version is a way ahead of the rest in that it protects your loss no matter what happens because of a news event, this version will allow you to deal with that unusual hike/nosedive in price and sacrifice some losses to get you going again.
Other than that, the other features are more or less the same as the earlier versions. But to be fair, let me describe here the user-set parameters used in this version:
Lots // number of lots to trade (usually, 1 lot is $10k): not limited but default is 1.
TrailingStop // the amount of the trailing stop needed to maximize profit (unlimited default is 55)
aggression_level; // how aggressive do you want the program to act in terms of taking trades. For example, in a highly aggressive level, any broken pivot line will be a trade opportunity. But in less aggressive levels, we are going to trade only if S2 and lower or P2 and higher lines are broken in a specific direction. (the value ranges from 1 to 12 and 10 is default).
wait_time_b4_SL; // the number of bars (minutes for a regular 1M chart) to wait before starting an exit strategy. It may take longer than wait_time_b4_SL before the order is actually closed because a function will be called to minimize the potential loss.
MAGIC; // the magic number could be specified by the trader for the ability to track trades of different charts.
VolatilityToleranceLevel; // This is what I like to keep 1 for now. It’s a risky market and you won’t want to lose your money. I only put it here to allow gamblers to raise it to double/triple their profit or loss for that matter (ranges from 1 to 10)
tp_limit; // how many times is a trailing point allowed. I put this here because I know for sure that some brokers don’t allow more than 5 successive tp modifications for a specific order. The default is 5 but obviously, it’s a good idea to raise it up to 50 or more if your broker is kind enough to allow you to do so. It will definitely enhance your profit.
pivot_span; // this is the number of bars that are used to calculate a specific pivot. Obviously it means that the last 100 bars will define your pivot line. I found this to be more useful than hours because of different timezones. (default=100)
Do check it out and see if it would work well on your account.
I can’t reiterate enough that this is still an EXPERIMENT so don’t go beyond forward testing with this. Also note that this version is usable without any time limitations (unlike earlier versions) but it is also good to come back here and check for updates.
The source code of this EA is only available to those who support it. I’m not greedy or asking for money. But those who know programming and can help improve it and who are also eager to help develop this specific EA is welcome to contact me so I can send the source code. I am not seeking money unlike some may suggest.
One very important note is the fact that you should always follow the progress of the EA if you start forward testing because there is no static stoploss. If there was a power outage or a technical problem that resulted in resetting your computer or the server, the EA will be useless and you have to follow the last order yourself. The SL is there but it is dynamic and requires your EA program to run all the time.
One more thing:
I noticed that some who started forward testing noted that new orders weren’t made in different currencies at the same time. I still couldn’t figure that out. But I added a condition that if the magic number is different, a new order can indeed take place. So if you apply different magic numbers to different charts, I hope you’ll be able to have simultaneous orders in different currencies.
Let’s hope this would be a positive improvement in the EA. You can test it (backtest, forward testing) using any time frame. But I only used M1 & M5 so far. Make sure you change the wait_time_b4_SL accordingly (lower value for higher timeframes).
I almost forgot to mention that attached you will find the backtest results –based on default parameter values- for the EURUSD (M1) from April 6, 2005 to December 31 2005 (almost 8 months). The effects of the dynamic stoploss feature are obvious in August, which witnessed a strong opposite trend –probably due to news events at the time. The modeling quality is terrible, I know… But I assume it won’t be a hell different from a 90% modeling quality.
Here's the graph:
I really miss the 0% loss results of previous versions. But for the longer term I think this version is better. But you can still have 0% if you set the wait_time_b4_SL parameter to a high amount (let's say 1,000,000).
Note that unlike earlier versions, there are almost no gaps in this test, meaning that almost every trade day there were some trades. Thanks to the new dynamic stoploss feature.
Another important note is to realize this EA is intraweek not intraday. It's not a scalping method. It requires time to operate effectively. So don't panic or worry if it closes with loss on a specific day. Upon the opening of the next trading day, it should resume as normal.
I would like to ask programmers here if there is a way to freeze a status (numbers, signals, variables) of the EA before weekends and resume everything with the old data on Mondays. Is there a way to do that. I imagine if we close the EA and start on Monday, some information would be lost (including time pending since last order). Otherwise, there could be a function to retrieve those data when the EA starts with a pending order in place.
I've been working on an EA using pivots and it proved to be truly amazingly accurate in predicting overall movement of the signal under normal market conditions.
After working on a number of versions and posting the ex4 file in forex-tsd and strategybuilderFX, I was able to develop ver 4 which is less risky and has a dynamic stoploss mechanism.
The idea is to establish an emergency exit strategy as follows: after waiting for a specific number of bars (time here relevant to chart period), you conclude that time is running out and an exit is a better idea, so try to exit the soonest with the minimum loss possible. The time to wait is defined in the parameter (wait_time_b4_SL).
After that number of bars has passed and we're still not in a profitable status, then wait until you arrive to a point that would have minimum loss. The tolerated loss is increased in time, i.e., the more we wait the more likely the trend is way opposite to our predictions (some news event triggered massive rise/fall in price), so we would accept a larger loss. But in the long-run, this loss could always be recovered (unless a war or so takes place).
Just as the stoploss is dynamic, so is the takeprofit. I'm using the famous saying: "let your profits run & cut your losses".
One thing you will note is that the stoploss feature is based on time, just as everything else in a pivot strategy. Remember, we are not using EMAs, bands and stuff, we are using the pivot assumption/theory that the market will always adjust itself in time. I could have assigned a value for stoploss, but that does not conform to the nature of the use of pivots, which assumes that within a specific timeframe, the price is expected to return to the pivot.
So this version is a way ahead of the rest in that it protects your loss no matter what happens because of a news event, this version will allow you to deal with that unusual hike/nosedive in price and sacrifice some losses to get you going again.
Other than that, the other features are more or less the same as the earlier versions. But to be fair, let me describe here the user-set parameters used in this version:
Lots // number of lots to trade (usually, 1 lot is $10k): not limited but default is 1.
TrailingStop // the amount of the trailing stop needed to maximize profit (unlimited default is 55)
aggression_level; // how aggressive do you want the program to act in terms of taking trades. For example, in a highly aggressive level, any broken pivot line will be a trade opportunity. But in less aggressive levels, we are going to trade only if S2 and lower or P2 and higher lines are broken in a specific direction. (the value ranges from 1 to 12 and 10 is default).
wait_time_b4_SL; // the number of bars (minutes for a regular 1M chart) to wait before starting an exit strategy. It may take longer than wait_time_b4_SL before the order is actually closed because a function will be called to minimize the potential loss.
MAGIC; // the magic number could be specified by the trader for the ability to track trades of different charts.
VolatilityToleranceLevel; // This is what I like to keep 1 for now. It’s a risky market and you won’t want to lose your money. I only put it here to allow gamblers to raise it to double/triple their profit or loss for that matter (ranges from 1 to 10)
tp_limit; // how many times is a trailing point allowed. I put this here because I know for sure that some brokers don’t allow more than 5 successive tp modifications for a specific order. The default is 5 but obviously, it’s a good idea to raise it up to 50 or more if your broker is kind enough to allow you to do so. It will definitely enhance your profit.
pivot_span; // this is the number of bars that are used to calculate a specific pivot. Obviously it means that the last 100 bars will define your pivot line. I found this to be more useful than hours because of different timezones. (default=100)
Do check it out and see if it would work well on your account.
I can’t reiterate enough that this is still an EXPERIMENT so don’t go beyond forward testing with this. Also note that this version is usable without any time limitations (unlike earlier versions) but it is also good to come back here and check for updates.
The source code of this EA is only available to those who support it. I’m not greedy or asking for money. But those who know programming and can help improve it and who are also eager to help develop this specific EA is welcome to contact me so I can send the source code. I am not seeking money unlike some may suggest.
One very important note is the fact that you should always follow the progress of the EA if you start forward testing because there is no static stoploss. If there was a power outage or a technical problem that resulted in resetting your computer or the server, the EA will be useless and you have to follow the last order yourself. The SL is there but it is dynamic and requires your EA program to run all the time.
One more thing:
I noticed that some who started forward testing noted that new orders weren’t made in different currencies at the same time. I still couldn’t figure that out. But I added a condition that if the magic number is different, a new order can indeed take place. So if you apply different magic numbers to different charts, I hope you’ll be able to have simultaneous orders in different currencies.
Let’s hope this would be a positive improvement in the EA. You can test it (backtest, forward testing) using any time frame. But I only used M1 & M5 so far. Make sure you change the wait_time_b4_SL accordingly (lower value for higher timeframes).
I almost forgot to mention that attached you will find the backtest results –based on default parameter values- for the EURUSD (M1) from April 6, 2005 to December 31 2005 (almost 8 months). The effects of the dynamic stoploss feature are obvious in August, which witnessed a strong opposite trend –probably due to news events at the time. The modeling quality is terrible, I know… But I assume it won’t be a hell different from a 90% modeling quality.
Here's the graph:
http://img50.imageshack.us/img50/347...ytester7rh.gif
I really miss the 0% loss results of previous versions. But for the longer term I think this version is better. But you can still have 0% if you set the wait_time_b4_SL parameter to a high amount (let's say 1,000,000).
Note that unlike earlier versions, there are almost no gaps in this test, meaning that almost every trade day there were some trades. Thanks to the new dynamic stoploss feature.
Another important note is to realize this EA is intraweek not intraday. It's not a scalping method. It requires time to operate effectively. So don't panic or worry if it closes with loss on a specific day. Upon the opening of the next trading day, it should resume as normal.
I would like to ask programmers here if there is a way to freeze a status (numbers, signals, variables) of the EA before weekends and resume everything with the old data on Mondays. Is there a way to do that. I imagine if we close the EA and start on Monday, some information would be lost (including time pending since last order). Otherwise, there could be a function to retrieve those data when the EA starts with a pending order in place.
Attached File(s)
PivotMagic-v4_with_dynamic_SL.zip
16 KB
|
1,514 downloads
TestResults_PivotMagic_v4_EURUSD.zip
16 KB
|
1,076 downloads