Equity curve trading

How to create strategies and indicators
Message
Author
swannyfx
Posts: 35
Joined: Fri Jun 18, 2010 12:35 am

Equity curve trading

#1 Postby swannyfx » Tue Jul 20, 2010 6:30 am

I use equity curve trading for one of my strategies so that when my equity curve (calculated in pips, not $) crosses below a moving average, I stop trading the system with real money and switch to demo trading. When the equity curve moves back above the moving average, I start trading it with real money again.

I'd like to code this functionality in Forextester but I'm not sure the best way to accomplish it.

From my research, I think I need to use an array to store the equity results and OrderProfitPips to find the result of the closed trades, would that work? Also, how do I emulate the demo trading once the equity curve moves below its moving average? I need to keep track of the theoretical results of the trades so that I know when the equity curve has moved above its moving average again and its time to trade real money. How would I do this?

Any help would be greatly appreciated.

Cheers,
swannyfx

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#2 Postby FT Support » Tue Jul 20, 2010 9:13 am

Hello,

Do you have such system (indicator or EA) coded for MetaTrader?

P.S. To emulate demo and real accounts you can run 2 Forex Tester instances simultaneously.
Check our other product here:
http://www.forexcopier.com

swannyfx
Posts: 35
Joined: Fri Jun 18, 2010 12:35 am

#3 Postby swannyfx » Tue Jul 20, 2010 3:49 pm

I do not have this strategy in MetaTrader, I used Excel in my original testing (not using vb either).

Two instances of ForexTrader could work. Would I be able to access both of them at the same time through the one strategy test? How would I do this?

Thanks.

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#4 Postby FT Support » Wed Jul 21, 2010 6:43 am

You can install your strategy on both terminals and then these strategies can exchange information via files (or you can choose another communication way)
Check our other product here:
http://www.forexcopier.com

swannyfx
Posts: 35
Joined: Fri Jun 18, 2010 12:35 am

#5 Postby swannyfx » Wed Jul 28, 2010 6:27 am

Thanks for the reply. That solution is a little more advanced than my current deplhi programming skills so I think I'll just use a very small (0.01) lot size for now instead.

As for the 2nd part of my problem, I need to keep track of my equity curve in pips and reduce the position size when the equity curve falls below a moving average of itself. I think I need to use an array for this and I've read the arrays section on the delphibasics website but I'm still not sure how to implement it in my code.

I'm confused about how I would set/read the array if I trade off the 1hr chart but only enter 1 trade a day and only check the equity curve is above the moving average when I'm calculating my position size for the day.

Also, how do I set the correct length for the array? Would I use iBars to find the number of daily bars and set the array length to that?

Cheers,
swannyfx

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#6 Postby FT Support » Wed Jul 28, 2010 8:09 am

If you are not sure about array size then you can try to use dynamic arrays (see more details here: http://www.latiumsoftware.com/en/delphi/00048.php)
Check our other product here:
http://www.forexcopier.com

SquareMeal
Posts: 40
Joined: Wed Sep 15, 2010 6:52 am

#7 Postby SquareMeal » Tue Dec 28, 2010 10:21 pm

SwannyFX,

Note: the following discussion does not start off in the order of the eventual code, but it introduces a couple of concepts. At the end, it's all put together in the proper sequence...

I've been doing the same thing you are trying to do. Instead of capturing trade results in an array, I use an exponential moving average. First, I build a PIP index of my trade results: start with 1,000 then add winning pips and subtract losing pips. Next, I calculate an exponential moving average of that index:

PIPindexEMA := (PIPindex*alpha)+(PIPindexEMA*(1-alpha));

I feed alpha in as a parameter, ranging from 0.50 to 0.70 for good results -- of course, it can be optimized.

In order to handle the "first time" execution of the above formula, I initialize PIPindexEMA to -9999 in the Reset section. Then I test for that initial state:

If (PIPindexEMA = -9999) then PIPindexEMA := PIPindex;

...which is then followed by the above EMA formula (example shown later). Otherwise the EMA has to ramp up from zero and is more likely to give you a false signal to trade or stay out.

Now that you have an index of your trade results and an EMA of that index, you can do the test to "Pass or Play" as you stated:

if (PIPindex < PIPindexEMA) then PaperTradeOnly := true;

PaperTradeOnly is a boolean field which you can use to "pretend" you are trading instead of actually sending orders to open (long or short).

Just before an open command (after all set up and entry signal criteria have been met), you do this routine..

[insert statement to save the open long (buy) or open short (sell) price]
If PaperTradeOnly then
begin
[change the OrderHandle to something other than -1 to make
all other logic think you have a trade going]
end
else
begin
[insert the open long or open short statement]
end;

Same technique is applied when it is time to Close the position. Just before the CloseOrder command, insert:

[save the Closing (buy or sell) price]
If PaperTradeOnly then
begin
[change OrderHandle back to -1 to make it look like you closed]
end
else
begin
[issue the Close command]
end;

After the close, it's time to:
calculate your gain or loss in pips (whether real or paper trade)
add the result to the PIPindex
calculate the EMA of the index
and test to see if you should continue paper trading or not...

PIPgain := (SellPrice - BuyPrice)/Point;
PIPindex := PIPindex+PIPgain;
If (PIPindexEMA = -9999) then PIPindexEMA := PIPindex;
PIPindexEMA := (PIPindex*alpha)+(PIPindexEMA*(1-alpha));
If (PIPindex < PIPindexEMA) then PaperTradeOnly := true
else PaperTradeOnly := false;

----------------------------------
I hope this works for you.

Continued success,

SquareMeal
creativity + willful purpose

banson
Posts: 1
Joined: Thu Apr 07, 2011 2:17 am

#8 Postby banson » Thu Apr 07, 2011 3:08 am

as for me i'm going to use forex freebot By Anna Monti for tradng... has anybody heard about it?

SquareMeal
Posts: 40
Joined: Wed Sep 15, 2010 6:52 am

I've heard of it...

#9 Postby SquareMeal » Thu Apr 07, 2011 8:52 am

banson wrote:as for me i'm going to use forex freebot By Anna Monti for tradng... has anybody heard about it?


Yes, I've heard of it.

First, it is FOREX SwissBOT, not freebot. It is free to download, then I'm sure it will cost you something (not to mention potential losses from trading).

Next, it is a product that is totally in a different class from ForexTester. SwissBOT executes its own algorithm -- you get what it gives and nothing more. ForexTester allows you to develop and test your own algorithms.

Next the free version of SwissBOT only works with the EURUSD pair -- perhaps you get more currencies to trade if you pay?

Next SwissBOT only works with M15 and M30 timeframes -- ForexTester is flexible to allowing you to select whatever timeframe you need.

The SwissBOT webpage only shows BACKTEST results. If your BACKTEST results don't look great, you're in trouble at the start. Ask them to provide out-of-sample trading results without cherry-picking the best of those for display... I'm sure they will hand them over.

So, if you want to limit yourself fo Ana Monti's algorithm on the EURUSD then go for it and get what you paid for... but from her picture, she looks like she has about 7 months of experience in FOREX trading.

Finally, I have no affiliation with ForexTester and I am not paid to make these comments. I'm just a satisfied customer. I paid for FT and now I'm designing and testing an algorithm which fits my style of trading -- something I can believe in. And my out-of-sample data looks good too, but don't ask to see it because it's not for sale.

One question: are you affiliated with SwissBOT or Ana Monti any any way? Your posting here seems like a shameless way to use someone else's discussion board to advertise a competing product. Please explain.
creativity + willful purpose


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 19 guests