going long on macd line cross over

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #161439 quote
    kevin12345
    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
    robertogozzi
    Moderator
    Master

    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
    Nicolas
    Keymaster
    Master

    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
    kevin12345
    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.

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 kevin12345
5 years ago.

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