Check if two MA's crossed within lasts 120 candles

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #12564 quote
    JohanJohan
    Participant
    Average
    Is there a way to know if two MA’s crossed within the lasts 120 candles?
    #12584 quote
    NicolasNicolas
    Keymaster
    Legend

    Please update your country flag in your profile. Thank you šŸ™‚

    You can make a test with a summation of successful boolean condition:
    test = summation[120](ma1 crosses over ma2)>0
    If test returns “1”, it is true that a moving average crossover has occurred within the last 120 candlesticks.
    grizzly thanked this post
    #12586 quote
    JohanJohan
    Participant
    Average
    I came up with…
    // No trade during consolidation
    if (MA200 crosses under MA400) or (MA200 crosses over MA400) then
    noTradeBar = barIndex[0]
    noTrade = 1
    endif
    
    if (noTradeBar + 120 < barIndex) then
    noTrade = 0
    endif
    
    graph noTrade
    But your code looks a bit more compact šŸ™‚ Going to try it out. Thanks!
Viewing 3 posts - 1 through 3 (of 3 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

Check if two MA's crossed within lasts 120 candles


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Johan @johan_holmberg Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by JohanJohan
10 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/01/2016
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...