need some insights on my newb system

Viewing 15 posts - 1 through 15 (of 24 total)
  • Author
    Posts
  • #163196 quote
    SweZerk
    Participant
    Junior

    Hello everyone!

    iv recently started to learn how to use simpel code and trying to creat some algos based on what i use when im daytrading.

    this is one of my scripts (very very simpel) that iv tried on dax 2 min backtesting 200k bars

     

    can i backtest it longer somehow? tryed not to curvefit it but it seems that it cant be helped to curvefit it abit.

     

    rn the stoploss and take profit are the same 1:1 but copied the rolling stopploss from this forum, can i make it better somehow? i wanna minimize the drawdowns even if it draw down the gains (not to much i hope hehe)

    here is the code:

    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    // Conditions to enter long positions
    indicator1 = Momentum[1000](close)
    c1 = (indicator1 CROSSES OVER 270)
    
    IF c1 AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator2 = Momentum[1000](close)
    c2 = (indicator2 CROSSES UNDER 0)
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    
    
    
    // Stops and targets
    SET STOP pLOSS 100
    SET TARGET pPROFIT 100
    
    //%trailing stop function
    trailingPercent = .35
    stepPercent = .01
    if onmarket then
    trailingstart = tradeprice(1)*(trailingpercent/100) //trailing will start @trailingstart points profit
    trailingstep = tradeprice(1)*(stepPercent/100) //% step to move the stoploss
    endif
     
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
     
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart THEN
    newSL = tradeprice(1)+trailingstep
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>trailingstep THEN
    newSL = newSL+trailingstep
    ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart THEN
    newSL = tradeprice(1)-trailingstep
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>trailingstep THEN
    newSL = newSL-trailingstep
    ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    
    
    //************************************************************************
    #163204 quote
    GraHal
    Participant
    Master

    Looks good on DJI 1 min at spread = 5 … see attached.

    Try and get the Short side working?

    Swez.jpg Swez.jpg Swez-2.jpg Swez-2.jpg
    #163207 quote
    SweZerk
    Participant
    Junior

    thx allot grahal! ye  i cant have it the same atleast and im to afraid to curvefit it cus its all i read about hehe, any ideas how i would go about it without fixing it for the curv?

    #163208 quote
    GraHal
    Participant
    Master

    Below doesn’t look right?

    Substitute DJI Price in and check it out.

    trailingPercent = .35
    stepPercent = .01
    if onmarket then
    trailingstart = tradeprice(1)*(trailingpercent/100) //trailing will start @trailingstart points profit
    trailingstep = tradeprice(1)*(stepPercent/100) //% step to move the stoploss
    endif
    #163235 quote
    GraHal
    Participant
    Master

    Below doesn’t look right?

    I checked … it does look right after all! 🙂

    #163247 quote
    GraHal
    Participant
    Master

    im to afraid to curvefit it cus its all i read about hehe,

    I agree! 🙂

    I try and keep the curve fitting in step with the current curve / market action!

    I’m going to see how attached works out on Demo Forward Test next week.

    v2.jpg v2.jpg v2-Perf.jpg v2-Perf.jpg Swez-Mom-DJI-M1-v2GH.itf
    #163323 quote
    SweZerk
    Participant
    Junior

    thx allot m8! also woundering how to go about to test stuff on 1m bars? i have some 1min systems that cant realy be backtested correctly

    #163330 quote
    Mattias
    Participant
    Senior

    i wanna minimize the drawdowns even if it draw down the gains (not to much i hope hehe)

     

    Well, one way to get lower the draw-down would be to check if the momentum is coming from below and not just going down and below your 270-level and up again. For example 5 periods

    c1b = (indicator1[5] < 270)

     

    Of course, this is not a guarantee to avoid the mentioned idea above, and it will make fewer trades and less gain. And also – another variable could mean bigger chance for curve fit. But in the backtest I did (did not optimize the variable, just tested with the 5-period), it cut the drawdown in half.

    #163354 quote
    Vonasi
    Moderator
    Master

    Mattias – Please be more careful when using the ‘Quote’ facility. You included all your own text within the quote which made your post very difficult to understand. I have edited your post to tidy it up. You have five minutes after pressing submit to delete or edit your posts if they do not look correct. Please double check your future posts and correct any errors before leaving the page.

    Mattias thanked this post
    #163577 quote
    SweZerk
    Participant
    Junior

    thx for all your insights! trying them all out. rn i run 10 versions of the system.

    i have some questen for one of my other system, rn im building a HF algo (over 300 trades per day) i wanna limit it to the swedish open of omx 09-1730 gmt+1

    is this code right for it? cus it doesent seem to work right for me

    DEFPARAM FLATBEFORE = 090000
    // Cancel all pending orders and close all positions at the "FLATAFTER" time
    DEFPARAM FLATAFTER = 173000
    
    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 090000
    timeEnterBefore = time >= noEntryBeforeTime
    
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 173000
    timeEnterAfter = time < noEntryAfterTime
    
    
    
    #163582 quote
    GraHal
    Participant
    Master

    Sounds like all you need is FlatBefore and FlatAfter and not the rest of the code you show above?

    https://www.prorealcode.com/documentation/flatbefore/

    #163585 quote
    nonetheless
    Participant
    Master

    Personally I prefer to use something like

    CTime = Time >= 090000 and Time < 173000

    (with CTime as an entry condition, obviously)

    This way new trades can only be opened during market hours, but can stay open after the close.

    This also allows you to optimize the Time variables, which you can’t do when using DEFPARAM FLATBEFORE / FLATAFTER

    GraHal thanked this post
    #163594 quote
    SweZerk
    Participant
    Junior

    thx grahal and nonetheless!

    nonetheless code was what i was after and it worked great. the only problem i have left now is that the code is very sensetive so sometimes the broker dont allow some of the orders so it turns of the bot, i dont wanna change the code so is there any adds that prevent that from happening

    #163598 quote
    nonetheless
    Participant
    Master

    What kind of rejection are you getting?

    (go Trading > Order List > Cancelled/Rejected then click in the Status column)

    #163607 quote
    SweZerk
    Participant
    Junior

    Your trading system was stopped because it tried to place a stop order below the minium distance required by your broker.

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

need some insights on my newb system


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
SweZerk @swezerk Participant
Summary

This topic contains 23 replies,
has 6 voices, and was last updated by migelrack
4 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/05/2021
Status: Active
Attachments: 6 files
Logo Logo
Loading...