going long on macd line cross over

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #161439 quote
    kevin12345kevin12345
    Participant
    Average

    hi,

    how to code if i want to go long when there’s a bull candle just before macd line crosses over macd signal line?

     

    thank you

    #161442 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    You can only know that a bar is the one before a crossover occurs AFTER the next one has crossed over.

    Which is late according to your conditions, so there’s no way to code them.

    #161453 quote
    NicolasNicolas
    Keymaster
    Legend

    But by using a simple comparison between previous value to the current one, it is actually possible to test the crossing of these 2:

    timeframe(1 hour) //timeframe of your strategy 
    bull = close[1]>open[1] //previous candle was green
    imacd = macd[12,26,9]
    signal = average[9,1](imacd)
    imacdp = macd[12,26,9][1] 
    signal = average[9,1](imacd)[1]
    
    timeframe(default) //timeframe inferior in order to test intrabar the crossing 
    test = bull and imacd<signal and imacdp>signalp

    no tested, but that’s the idea ^^

    #161466 quote
    kevin12345kevin12345
    Participant
    Average

    sorry i mean bull candle after macd cross over.

Viewing 4 posts - 1 through 4 (of 4 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

going long on macd line cross over


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
kevin12345 @kevin12345 Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/15/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...