Coding for first pullback after price crossed MA50

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • #100736 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Ok, I’ll add the short side soon!

    #100737 quote
    GraHalGraHal
    Participant
    Master

    The curve and results for 5th down from the top look just as good!?

    I know it’s only 10k bars, but I’m trying out a different kind of trading … Auto Entry and Manual Exit if / when needed?

    There will be no need for manual exit on this one though if a weekly optimise keeps the Live results above that critical Gain / Loss ratio of 2 ish.

    pullback3.jpg pullback3.jpg
    #100741 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Both sides:

    DEFPARAM CumulateOrders = false
    MinLookBack =  2           //2  crossing must have occured at least these bars before PullBack
    MaxLookBack =  17          //17 crossing must have occured at most  these bars before PullBack
    MA50 = average[50,1](close)//50,1
    //  LONG  side
    x = close crosses over  ma50
    IF x OR (close > MA50 AND low < MA50) THEN //when a pullback occurs...
       IF summation[MinLookBack](x[1]) = 0 THEN
          IF summation[MaxLookBack](x[MinLookBack + 1]) AND Not OnMarket AND close > open THEN
             BUY 1 CONTRACT AT MARKET
             SET STOP   pLOSS   50    //50
             SET TARGET pPROFIT 300   //300
          ENDIF
       ENDIF
    ENDIF
    //  SHORT side
    x = close crosses under ma50
    IF x OR (close < MA50 AND high > MA50) THEN //when a pullback occurs...
       IF summation[MinLookBack](x[1]) = 0 THEN
          IF summation[MaxLookBack](x[MinLookBack + 1]) AND Not OnMarket AND close < open THEN
             SELLSHORT 1 CONTRACT AT MARKET
             SET STOP   pLOSS   50    //50
             SET TARGET pPROFIT 300   //300
          ENDIF
       ENDIF
    ENDIF
    GraHal thanked this post
    #100745 quote
    RiaanvNRiaanvN
    Participant
    Average

    Hello Roberto,

    I have also noticed that with this trade setup the MA20 offers good support. 50% of time after price crosses MA50 the price pullback to MA20 instead. Is it possible for you to add this criteria?

    Price cross MA50 then pullback to MA20 (or MA50).

    #100747 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go (not tested):

    DEFPARAM CumulateOrders = false
    MinLookBack =  2           //2  crossing must have occured at least these bars before PullBack
    MaxLookBack =  17          //17 crossing must have occured at most  these bars before PullBack
    MA50 = average[50,1](close)//50,1
    MA20 = average[20,1](close)//20,1
    //  LONG  side
    x = close crosses over  ma50
    y = close crosses over  ma20
    IF x OR (close > MA50 AND low < MA50) THEN //when a pullback occurs...
       IF summation[MinLookBack](y[1]) = 0 THEN
          IF summation[MaxLookBack](y[MinLookBack + 1]) AND Not OnMarket AND close > open THEN
             BUY 1 CONTRACT AT MARKET
             SET STOP   pLOSS   50    //50
             SET TARGET pPROFIT 300   //300
          ENDIF
       ENDIF
    ENDIF
    //  SHORT side
    x = close crosses under ma50
    y = close crosses under ma20
    IF x OR (close < MA50 AND high > MA50) THEN //when a pullback occurs...
       IF summation[MinLookBack](y[1]) = 0 THEN
          IF summation[MaxLookBack](y[MinLookBack + 1]) AND Not OnMarket AND close < open THEN
             SELLSHORT 1 CONTRACT AT MARKET
             SET STOP   pLOSS   50    //50
             SET TARGET pPROFIT 300   //300
          ENDIF
       ENDIF
    ENDIF
    GraHal and RiaanvN thanked this post
Viewing 5 posts - 16 through 20 (of 20 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Coding for first pullback after price crossed MA50


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
RiaanvN @riaanvn Participant
Summary

This topic contains 19 replies,
has 5 voices, and was last updated by robertogozzirobertogozzi
7 years, 3 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/11/2019
Status: Active
Attachments: 5 files
ProRealCode ProRealCode
Loading...