Previous candles with trend

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #128517 quote
    trevor
    Participant
    Senior

    Hi. Have been trying to code for the current candle and previous candle(s) being in the direction of my moving averages.

    I set up 3 strategies. First strategy was the close of the current candle before opening a trade (c4)

    Second strategy was the current candle and the previous candle [1]

    Third strategy was the current candle and the 2 previous candles.

     

    In the attachment, you can see the current candle (before opening the trade) was in the direction of the moving averages.

    But the previous ones,[1] and [2], were not.

     

    c4 = (close > open)
    c5 = (close > open[1])
    c6 = (close > open[2])
    
    IF c1 AND c2 AND c3 AND c4 AND c5 AND c6 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF

    Trading in demo mode. This did not work (see attachment).

    The  code was created in the program using simplified creation. So it should work.

    What am  I doing wrong? Any help greatly appreciated.

    Thanks in advance.

    previous-candles-code.png previous-candles-code.png
    #128519 quote
    trevor
    Participant
    Senior

    Note: I ran all 3 strategies and they all started the trade. Only the current candle (before trade) was correct

    #128527 quote
    Vonasi
    Moderator
    Master

    Your question is a bit confusing because you left the part about the averages out of it. In your image there are three averages – two going up and one going down!

    Your code only compares the close of the current candle to the opening prices of the previous candles. If you want to know if they were red or green then you need to do this:

    c4 = summation[3](close > open) = 3 //3 greens
    c5 = summation[3](close < open) = 3 //3 reds
    
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Previous candles with trend


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/28/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...