Coding for first pullback after price crossed MA50

Forums ProRealTime English forum ProOrder support Coding for first pullback after price crossed MA50

This topic contains 19 replies, has 5 voices, and was last updated by avatar robertogozzi 3 months ago.

Currently, there are 0 users and 20 guests visiting this topic.
View all attachments
Viewing 15 posts - 1 through 15 (of 20 total)
  • #100441

    Hi guys,

    I would appreciate some assistance. My favorite trade setup is pulback to MA50 after price crossed MA50 and MA50 is sloping up. Thus an established new trend.

    Any ideas how to code this?



    Could you post some images to clarify?


    Hi Alex, see attached example of retrace.



    RiaanvN you will need to state a % closeness to MA50 (after retrace) for your entry  condition.

    Also I guess an exit condition would be if Close carries on through the MA50 … as it did on the last retrace / black MA50?


    Hello Grahal,

    I would appreciated coding help for following criterias to be met.

    • SMA50 upward sloping for the past 10 bars.
    • SMA50 was downward sloping for at least 10 bars, 50 bars ago. (Range thus between [60] and [50].)
    • Highest pivot low (swing low) for past 50 bars.

    Thanks. Hope to hear from you soon.


    I’ll leave the coding to @alexf so much better than me! (I struggle with my own coding! 🙂 )

    I was only getting you to specify when exactly the entry trigger should occur when I asked … < % closeness to MA50.

    I doubt you would want a specific entry point, e.g. MA50 + 5 points or = MA50 as it might not get to that point and then turn around zoom upwards while waving goodbye to you waiting there to enter … just like you predicted but you didn’t pull the trigger soon enough!? 🙂


    The issue is I don’t see a clear definition of retracement.

    In the picture posted it is clear to human eyes, but an algo need some more specific rules… Like “bitening” of Ma or a new lowest after x bars f. e.



    Yea thats the hard part of coding those types of systems. Price might cross over 50MA 3 candles ago and retrace, or 10 candles or 50 candles then retrace.


    You need to define that price

    • WAS under ma50
    • WAS “high” above ma50
    • is currently not very high above ma50/retracing back to ma50, without it crossing under it(?)

    edit: just a thought: multiple MA’s?


    This is very basic:

    When it detects a crossover it is interpreted as a crossover due to pullback if there has been a previous crossover AT LEAST min candles before and AT MOST max candles before.




    Thanks Roberto! I’m definitely going to try this.



    This is very basic:

    Sheeesh!!!! 🙂 🙂


    Pretty expressive GraHal!


    @robertogozzi … You knew I was just making some humour for a Saturday morning, right??

    Perhaps I should have added … You ain’t seen my basic! 🙂


    I knew that, I was on the same line of humor.

    I wrote BASIC because it lacks trailing stop/break even, money/position management and other amenities!

    1 user thanked author for this post.

    Good results on 10k bars on 1 min TF!  Spread = 4

    Optimise weekly and / or when Gain / Loss ratio drops much below 2.

    The variable settings I chose are well down from the top Gain and are out of sight on attached.  Variable name is Line No (or should be!?).

    I’ll set it going on Demo Fwd Test on Monday.

    Roberto any chance you could do the same on the Short side please pretty please?  Then the whole code will be yours! 

Viewing 15 posts - 1 through 15 (of 20 total)

Create your free account now and post your request to benefit from the help of the community
Register or