Greetings to all members, programmers and trading enthusiasts.
Today I wanted to ask you what are the ways you use to adapt a strategy to a spread that is too high? And in particular, how to select or rank the best signals, in order to prioritize some over others, thus reducing the impact of the spread on a strategy.
Finally I wanted to share with you a simple strategy that works in backtest without a spread on EURUSD 1 minute timeframe (and potentially on other financial instruments), and which I wish could work in real with the spread.
Here is the strategy:
Trend Force Strategy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
defparamcumulateorders=false
//Heikin Ashi calculation
ONCExOpen=Open
xClose=(open+high+low+close)/4
IFBarIndex>0THEN
xOpen=(xOpen[1]+xClose[1])/2
ENDIF
xHigh=max(high,max(xClose,xOpen))
xLow=min(low,min(xClose,xOpen))
xBody=abs(xOpen-xClose)
xUp=xHigh-max(xClose,xOpen)
xDN=min(xClose,xOpen)-xLow
xrange=(xhigh-xlow)
//Trend Force calculation
up=(xhigh-xopen)/xrange
dn=(xlow-xopen)/xrange
sig=(xclose-xopen)/xrange
media=(up+dn)/2
// Support,resistance and signal calculation
ifup>0then
signal=1
supporto=xlow
elsifdn<0then
signal=-1
resistenza=xhigh
endif
BUY1CONTRACTSATresistenzastop
sellshort1contractatsupportostop
Attached you will find an image of the backtest, and the strategy in file form
Your first problem is more “severe” : you need to enter the Broker Fee (Commission). And, what I did below will not be correct for the instrument you chose and which looks to be the EUR/USD Mini which (somehow) I can not find (unless it is a Future). I assumed you are in the PRT-IB version. Also, you will need V12 (PRT-IB version) in order to be able to enter the correct commission amount, plus in V11 the calculation of the commission in backtest is wrong (my screenshot is from V11).
You will see that as soon as you enter the slightest amount of commission, your strategy fails all over (sorry). So that is first because way more important than the spread. But please keep in mind : I assume this is PRT-IB (Interactive Brokers). Maybe I am wrong with that.
Your last two lines should be in an If/Else condition. Now the second line of that may cancel the first.
If this is PRT-IG after all, it will indeed be so that the spread is killing your System. But that is why you post in the first place. 🙂
I think the most common way to modify a code is to adjust the times, so not have the code run at certain times, for example when the spread is too high…
To filter the best signals, you will have to find out, in Demo, when your system performs best, for example in a Bull trend or in a Bear trend or perhaps in a sideways market…
When you know that, you can add code to only trade during a certain period/trend…
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue