MACD Assistance please

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #101662 quote
    DJB1974
    Participant
    New

    Hi im trying to use the probuilder to create a simple Macd auto strategy that will open both long and short positions on the FX market, but the simple help screen wants to turn each trade off when it makes a new 1.

    Knowing that the FX market bounces up and down quite a bit, my aim is to set a take profit point of say 50, and then at some point the trades will close out given the continual up/down nature of the market, im not really concerned with how many open orders it might create initially, but over time all orders should close out. Its just a theory for now, but would like to try it out on the demo b4 going live if it gives some decent results, basically in theory all trades will close out at a profit, its just a matter of time, and its that time factor i want to test.

    you can see on the attached chart pic, its creating an order every tic basically, but looking at the Macd chart, theres only 4 times it crosses

    heres the code that i have started with, any help would be much appreciated.

    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 = MACD[6,13,8](close)
    c1 = (indicator1 >= indicator1)
    
    IF c1 AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator2 = MACD[6,13,8](close)
    c2 = (indicator2 >= indicator2)
    
    IF c2 AND not daysForbiddenEntry THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Stops and targets
    SET TARGET pPROFIT 50
    clip2.jpg clip2.jpg
    #101665 quote
    robertogozzi
    Moderator
    Master

    Conditions C1 and C2 are ALWAYS true, because each bar the indicator is = to itself!

    You should change the conditions.

    Writing >= is useless, just use = since no indicator can be > itself!

    The first candle enters a Long position, since Long’s are evaluated first despite C2 is also true, the next candle Long’s are ignored, despite C1 being true, because you can’t cumulate orders, but C2 is true so it closes any open Long position and enters a Short positions and so on.

    It simply does a Close & Reverse each candle.

    You should define better conditions to suit your needs.

    #101673 quote
    GraHal
    Participant
    Master

    All good and true advice from Roberto … now you now why it didn’t work.

    Try below … should get you going to test your theory out and move forward onto a better strategy (as Roberto advises).

    You will need deep pockets though! 🙂

    // Definition of code parameters
    DEFPARAM CumulateOrders = TRUE // 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 = MACD[6,13,8](close)
    c1 = (indicator1 > indicator1[1])
     
    IF c1 AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
     
    // Conditions to enter short positions
    indicator2 = MACD[6,13,8](close)
    c2 = (indicator2 < indicator2[1])
     
    IF c2 AND not daysForbiddenEntry THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
     
    // Stops and targets
    SET TARGET pPROFIT 50
    DJB1974 thanked this post
    #101674 quote
    robertogozzi
    Moderator
    Master

    Good point GraHal, thank you!

    DJB1974 and GraHal thanked this post
    #101683 quote
    DJB1974
    Participant
    New

    cool thanks guys, i knew it would be some thing small, will test run it.

    Cheers

    DJ

    #101685 quote
    GraHal
    Participant
    Master

    Backtest with fixed spread = 1.5 (on eurusd for example) and tick by tick mode selected  else you will get misleading results.

    Best you come back on here with any code and results before put real money at risk … we don’t want you to get wiped out. 🙁

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

MACD Assistance please


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
DJB1974 @djb1974 Participant
Summary

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

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