MACd auto trading Attempt

Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
    Posts
  • #98412 quote
    DJB1974
    Participant
    New

    Hello there every, new to this group.

    Im attempting to set up an auto trader based on the MACd and i cant work out why its buying and selling at the same time. See attached pic

    Nothing i change seems to make a difference to it, can any body please assist?

    Cheers

     

    DJ

    double-trades.jpg double-trades.jpg
    #98414 quote
    robertogozzi
    Moderator
    Master

    Please post your code so we can help find out any issue.

    We need to be able to replicate your trades.

    You also need to tell us:

    • Instrument
    • Time frame used
    #98426 quote
    DJB1974
    Participant
    New

    Here is my code

    Not sure what u mean by Instrument sorry

    1 min time frame on the any market/chart i apply it too

    hope that helps, if u need more please let me know

    cheers

    DJ

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 0
    
    // Conditions to enter long positions
    indicator1 = MACDline[12,26,9](close)
    indicator2 = ExponentialAverage[9](indicator1)
    c1 = (indicator1 < indicator2)
    
    IF c1 AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator3 = MACDline[12,26,9](close)
    indicator4 = ExponentialAverage[9](indicator3)
    c2 = (indicator3 > indicator4)
    
    IF c2 AND not daysForbiddenEntry THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pTRAILING 10
    SET TARGET pPROFIT 100
    #98427 quote
    DJB1974
    Participant
    New
    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 0
    
    // Conditions to enter long positions
    indicator1 = MACDline[12,26,9](close)
    indicator2 = ExponentialAverage[9](indicator1)
    c1 = (indicator1 < indicator2)
    
    IF c1 AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator3 = MACDline[12,26,9](close)
    indicator4 = ExponentialAverage[9](indicator3)
    c2 = (indicator3 > indicator4)
    
    IF c2 AND not daysForbiddenEntry THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pTRAILING 10
    SET TARGET pPROFIT 100
    #98431 quote
    GraHal
    Participant
    Master

    i cant work out why its buying and selling at the same time

    Your code doesn’t do above on my platform … it does attached.

    EDIT / PS

    What do you have spread set at?

    If you have it set at 10 then it will do what you are experiencing due to your  TS of 10.

    DJ.jpg DJ.jpg
    #98433 quote
    DJB1974
    Participant
    New

    you can see on the chart that its making 2 orders at a time.

    chart.jpg chart.jpg
    #98436 quote
    DJB1974
    Participant
    New

    yet on the closed list there doesnt appear to be multiple transactions at the same time

    closed-list.jpg closed-list.jpg
    #98439 quote
    DJB1974
    Participant
    New

    i asked in another thread what MAE and MFE stand for, so i best get these dumb questions out of the way as well Abs Perf? Relate Per%? what do they mean please?

    Does nbr bars refer to the points/pips of trade?

    Also, i have a trailing stop of 10 set why is it then on the losing trades that the nbr bars showing 10 + shouldnt this close the trade at 10 losing points instead of the 20, 23, 19 that it shows?

    cheers

    DJ

    closed-list-2.jpg closed-list-2.jpg
    #98441 quote
    robertogozzi
    Moderator
    Master

    It’s because your trailing stop is hit, usually within the first bar, since it’s really tight.

    As you can see from my Pic1 (the same as your, but abridged), the first two trades are tagged both as ENTRY first, then as TRAILING STOP on exit. While the third one hit your target profit.

    You can easily spot them on pic2.

    x1.jpg x1.jpg x2.jpg x2.jpg
    #98444 quote
    robertogozzi
    Moderator
    Master

    Mine is on DAX, 1h, that’s what I meant by “instrument“.

    #98454 quote
    DJB1974
    Participant
    New

    so from my coding what do i need to change to stop it happening please?

    whats a more reasonable trailing stop, take profit margin to assist it?

    #98455 quote
    DJB1974
    Participant
    New

    Its interesting to see the same strategy do completely different things , on the left is the asx200 index, which is after hours now, and then on the right the EUR/USD, being a FX trade im guessing the market doesnt shut down like each countries local Stockmarkets.

    same-but-different.jpg same-but-different.jpg
    #98457 quote
    GraHal
    Participant
    Master

    whats a more reasonable trailing stop, take profit margin to assist it?

    Try using the Optimiser to determine above.

    Have you  watched Nicolas videos?

    #98458 quote
    DJB1974
    Participant
    New

    i cant work out why its buying and selling at the same time

    Your code doesn’t do above on my platform … it does attached.

    EDIT / PS

    What do you have spread set at?

    If you have it set at 10 then it will do what you are experiencing due to your TS of 10.

    If i have what part set at 10? the TS or something else?

    #98466 quote
    GraHal
    Participant
    Master

    If i have what part set at 10? the TS or something else?

    See red squiggly line on attached

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

MACd auto trading Attempt


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
DJB1974 @djb1974 Participant
Summary

This topic contains 21 replies,
has 4 voices, and was last updated by jebus89
6 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/14/2019
Status: Active
Attachments: 10 files
Logo Logo
Loading...