Something is missing in my "Friday Sell-off"

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #38879 quote
    Ricx
    Participant
    Junior

    This is my first backtest, just trying to create a simple test to take a look at sell-offs in S&P500 during the last 45 minutes on Fridays.

    It seems that I am missing something as I don’t get any results.. I want to look at in in the 5 minutes timeframe and I’ve put in MA8 and MA16, I want to enter a short position (and vice versa for long) when MA8 crosses under MA16 and I want it to exit the position when price goes over MA8 or 10 minutes after closing time of the stock exchange (which in my case is 22:10 as I’m located in GMT+1). Attached you can see a pic of what I’m looking to capture, however the attached pic is of a Thursday but it is just to show you what I’m looking for.

    What am I missing?

    Thanks in advance for any help! 🙂

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    // The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the "FLATBEFORE" time.
    DEFPARAM FLATBEFORE = 212500
    // Cancel all pending orders and close all positions at the "FLATAFTER" time
    DEFPARAM FLATAFTER = 221000
    
    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 212500
    timeEnterBefore = time >= noEntryBeforeTime
    
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 221000
    timeEnterAfter = time < noEntryAfterTime
    
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 1 OR OpenDayOfWeek = 2 OR OpenDayOfWeek = 3 OR OpenDayOfWeek = 4 OR OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    // Conditions to enter long positions
    indicator1 = Average[8](close)
    indicator2 = Average[16](close)
    c1 = (indicator1 CROSSES OVER indicator2)
    
    IF c1 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator3 = Average[8](close)
    c2 = (close < indicator3)
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator4 = Average[8](close)
    indicator5 = Average[16](close)
    c3 = (indicator4 CROSSES UNDER indicator5)
    
    IF c3 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator6 = Average[8](close)
    c4 = (close > indicator6)
    
    IF c4 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pTRAILING 10
    SET TARGET pPROFIT 30
    Skärmavbild-2017-06-23-kl.-11.22.08.png Skärmavbild-2017-06-23-kl.-11.22.08.png
    #38881 quote
    Nicolas
    Keymaster
    Master

    Something wrong in your conditions:

    graph c1 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry coloured (0,200,0)
    graph c3 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry coloured (200,0,0)

    Don’t return any valid signals in backtests. You should test each of all your conditions, to know which one prevent a signal to be valid.

    #38883 quote
    Ricx
    Participant
    Junior

    Thanks for answering!

    What do you mean by testing all of the conditions? Am I only testing one right now?

    #38884 quote
    GraHal
    Participant
    Master

    I think Nicolas means for you to backtest 1 condition and then include a 2nd condition and then a 3rd etc. When you include a condition which stops trades then you know that is the condition with the error?

    Ricx thanked this post
    #38890 quote
    Nicolas
    Keymaster
    Master

    This is all conditions that trigger a BUY order:

    c1 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry

    All these conditions are not met at the same time and that’s why you never get any long entry. I suggest to GRAPH one condition by one in backtests to know why it happens.

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

Something is missing in my "Friday Sell-off"


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Ricx @ricx Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Nicolas
8 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/23/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...