Simple MACD crossover strategy

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #152356 quote
    Rich
    Participant
    New

    Hello all, another beginner here looking for help as I try to learn more about PRT – falling at the first hurdle as this is my first dabble with programming!

    I’m trying to make a simple MACD crossover strategy that buys long when the MACD line crosses over the MACD signal line and sells short when the MACD line crosses back under the signal line. Profit target is 200, stop loss 100. I’ve looked at the online guide and other forum posts but can’t get this working – can anyone help me to fix it please?

    MacLine = MACDline[12,26,9](close)
    MacSig = ExponentialAverage[9](MacSig)
    
    IF MacLine CROSSES UNDER MacSig THEN
    BUY 1 contract AT MARKET
    ENDIF
    IF MacLine CROSSES OVER MacSig THEN
    SELLSHORT 1 contract AT MARKET
    ENDIF
    SET TARGET pPROFIT 200
    SET STOP pLOSS 100

    Very simple for most of you I’m sure! Thanks 🙂

    #152358 quote
    Monochrome
    Participant
    Senior

    2nd line

    MacSig = ExponentialAverage[9](macline)

    macline not macsig

    Rich thanked this post
    #152360 quote
    Rich
    Participant
    New

    Thanks Monochrome, it worked but then it sold when it should buy and bought when it should sell so switched ‘crosses over’ with ‘crosses under’ and vice versa. Seems strange that way round but does what I expect now.

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

Simple MACD crossover strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Rich @rich Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Rich
5 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/01/2020
Status: Active
Attachments: No files
Logo Logo
Loading...