Total Beginner

Viewing 9 posts - 31 through 39 (of 39 total)
  • Author
    Posts
  • #202041 quote
    JS
    Participant
    Senior
    Hi @Trader Sab

    When I use your new code (Dow Jones, TF 5 min) it does exactly what it’s supposed to do:

    He opens a long position when “Close Crosses Over indicator1”

    He opens a short position when “Close Crosses Under indicator1”

    The “Set Stop Trailing 10” works as it should.

    The indicated times “FlatBefore / FlatAfter” also work well.

    So, I don’t get random positions being opened?

    The last comments about “C3 = True / 1” are based on a misunderstanding with GraHal.

    GraHal tried to explain something completely different, namely the use of the “Graph” instruction.

    Line 27 (with “True” or “1”) can be completely cancelled because line 29 already says “If c3 Then” and that is sufficient…

    GraHal and Trader Sab thanked this post
    Schermafbeelding-2022-10-07-om-04.25.27.jpg Schermafbeelding-2022-10-07-om-04.25.27.jpg
    #202048 quote
    GraHal
    Participant
    Master
    however I got a dismal result
    It can happen, especially when using  – close crosses under / over averages – which are notorious for optimisation to quickly turn from profit to loss. In my version code / .itf I posted … try optimising a variable for the EA period (in place of period = 20) and  you will see what I mean. Let us know how you get on?
    Trader Sab thanked this post
    #202051 quote
    Trader Sab
    Participant
    New
    @GraHal Good morning. Thank you so much for your encouraging words and all the support. I like the optimization you have on the code to make profit and stops more dynamic. I tested both system this morning again and got the results below. I added the DEFPARAM flatbefore / after  back into your code which did not improve the result. I think I have to test it a bit longer to see more results. Compared to the codes you write this very simple and if it is going to work I’d be cuffed. 🙂
    comparing-2-codes-DJI-5m-1k.jpg comparing-2-codes-DJI-5m-1k.jpg comparing-2-codes-DJI-5m-1k-4.jpg comparing-2-codes-DJI-5m-1k-4.jpg Comparison-2-Code-Equity-Curve-DJI-5-min-1K-3.jpg Comparison-2-Code-Equity-Curve-DJI-5-min-1K-3.jpg comparing-2-codes-DJI-5m-1k-3.jpg comparing-2-codes-DJI-5m-1k-3.jpg Comparison-2-Code-Equity-Curve-DJI-5-min-1K-2.jpg Comparison-2-Code-Equity-Curve-DJI-5-min-1K-2.jpg comparing-2-codes-DJI-5m-1k-2.jpg comparing-2-codes-DJI-5m-1k-2.jpg Comparison-2-Code-Equity-Curve-DJI-5-min-1K-1.jpg Comparison-2-Code-Equity-Curve-DJI-5-min-1K-1.jpg comparing-2-codes-DJI-5m-1k-1.jpg comparing-2-codes-DJI-5m-1k-1.jpg Comparison-2-Code-Equity-Curve-DJI-5-min-1K.jpg Comparison-2-Code-Equity-Curve-DJI-5-min-1K.jpg Comparison-2-Code-Equity-Curve-DJI-5-min-1K-4.jpg Comparison-2-Code-Equity-Curve-DJI-5-min-1K-4.jpg
    #202062 quote
    Trader Sab
    Participant
    New
    @GraHal Just to show you what I mean, the code opened a long position at 11 am, where the condition of crossing over EMA20 was not given. I have to specify more clearly the signal but I am not sure how.   BTW sorry for the gazillion attachments in the last post, not sure how this happened.
    Triggered-entry-without-condition-fulfilled.jpg Triggered-entry-without-condition-fulfilled.jpg
    #202065 quote
    GraHal
    Participant
    Master
    If you post the code you are analysing above then I will try it on my platform and we can compare like with like.
    Trader Sab thanked this post
    #202075 quote
    Trader Sab
    Participant
    New
    @GraHal I hope this works, not with the attachments. Thank you in advance for helping me out.
    Sab-EAx-DJI-M5-1K-v1gh-1.itf EMA-20-SYSTEm-DJI.itf
    #202078 quote
    GraHal
    Participant
    Master
    where the condition of crossing over EMA20 was not given
    Your Buy entry condition (in EMA 20 SYSTEm DJI you posted) is NOT crossing over (as you say above); it is >= … see Line 8 below in your full code. Also Set Stop Trailing 10 will never work on DJI … it will whipsaw you in and out of loads of trades and make an overall loss. Remove the TS for now, until you get the rest of the code understood / working.
    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    DEFPARAM FLATBEFORE = 083000
    DEFPARAM FLATAFTER = 220000
    
    // Conditions to enter long positions
    indicator1 = ExponentialAverage[20](close)
    c1 = (close >= indicator1[1])
    
    IF c1 THEN
    BUY 0.5 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator2 = ExponentialAverage[20](close)
    c2 = (close CROSSES UNDER indicator2[1])
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    SET STOP TRAILING 10
    
    // Conditions to enter short positions
    indicator1 = ExponentialAverage[20](close)
    c1 = (close <= indicator1[1])
    
    IF c1 THEN
    SELLSHORT 0.5 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator2 = ExponentialAverage[20](close)
    c2 = (close > indicator2)
    
    IF c2 THEN
    EXITSHORT AT MARKET
    ENDIF
    SET STOP TRAILING 10
    
    #202081 quote
    GraHal
    Participant
    Master
    Remove the TS for now
    Or optimise the TS value using min = 25, max = 250, step = 25
    #202085 quote
    GraHal
    Participant
    Master
    Work to the premise that your code will be working correctly and functioning as the code is written. Have you tried / understood what to do with GRAPH yet? It is a way to show under the equity curve and positions if and when the GRAPH conditions are met. So if you enter GRAPH C1 (just that, nothing more) at the bottom of your code I posted above, then click on backtest, you wll see an extra display appear which shows value = 1 for all bars where c1 = (close >= indicator1[1]).
Viewing 9 posts - 31 through 39 (of 39 total)
  • You must be logged in to reply to this topic.

Total Beginner


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Trader Sab @trader-sab Participant
Summary

This topic contains 38 replies,
has 6 voices, and was last updated by GraHal
3 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/03/2022
Status: Active
Attachments: 27 files
Logo Logo
Loading...