Select best signals of a strategy to adapt it to the spread

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #226741 quote
    davidelaferla
    Participant
    Average

    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:

    
    defparam cumulateorders=false
    
    //Heikin Ashi calculation
    ONCE xOpen = Open
    xClose = (open + high + low + close) / 4
    IF BarIndex > 0 THEN
    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
    if up>0 then
    signal=1
    supporto=xlow
    elsif dn<0 then
    signal=-1
    resistenza=xhigh
    endif
    
    BUY 1 CONTRACTS AT resistenza stop
    sellshort 1 contract at supporto stop

    Attached you will find an image of the backtest, and the strategy in file form

    Trend-Force.itf Eurusd-Force-Strategy-Backtest.png Eurusd-Force-Strategy-Backtest.png
    #226744 quote
    PeterSt
    Participant
    Master

    Hi there !

    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. 🙂

    Regards,
    Peter

    image_2024-01-23_064526687.png image_2024-01-23_064526687.png
    #226804 quote
    JS
    Participant
    Senior

    Hi @davidelaferla

    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…

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Select best signals of a strategy to adapt it to the spread


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by JS
2 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/23/2024
Status: Active
Attachments: 3 files
Logo Logo
Loading...