3 Candle Strategy

Viewing 15 posts - 31 through 45 (of 83 total)
  • Author
    Posts
  • #77326 quote
    GraHal
    Participant
    Master

    As you already spotted what is not correct, make it easier for us 🙂 … which of the conditions for a Buy have not been met correctly?

    #77336 quote
    Marc
    Participant
    Average

    As you can see in my attachment the low of third candle is deeper than candle before…Ths condition wasn’t met for a sell order..

    #77338 quote
    Marc
    Participant
    Average

    Please ignore above post and find another pic which shows two example orders…both lost…and I do not really know why

    Neue-Bitmap-1.jpg Neue-Bitmap-1.jpg
    #77340 quote
    GraHal
    Participant
    Master

    I’m sorry, but I’m a little slow on the uptake. To me that little bit of the Chart you show looks like a Buy Order with the trigger being the high of the 3rd candle??

    the low of third candle is deeper than candle before…Ths condition wasn’t met for a sell order..

    So for a sell order you don’t want the low of the third candle lower than the candle before … is that what you are saying? I’m confused by … Ths condition wasn’t met for a sell order.

    Somebody else will probably pop in who can see exactly what you are saying? 🙂

    Idea – it be good if you copied the bit of the code you are referring to?

    #77341 quote
    Marc
    Participant
    Average

    Hi GraHal,

    here’s the code and a screenshot.

    DEFPARAM CumulateOrders = true
    
    //Buy-Condition l1: Kerze vor 3 Perioden muss bullish sein und es müssen 3 Kerzen mit tieferen Hochs und tieferen Tiefs folgen und der Schlusskurs der vorherigen Kerze muss größer sein als der Schlusskurs der ersten Kerze
    l1 = OPEN[3] < CLOSE[3] AND High[3] > High [2] AND High[2] > High[1] AND Low[3] > Low[2] AND Low[2] > Low[1] AND Close[1] >= Close[3]
    
    //Buy-Condition l2: Kerze vor 3 Perioden muss bearish sein und es müssen 3 Kerzen mit tieferen Hochs und tieferen Tiefs folgen und der Schlusskurs der vorherigen Kerze ist größer als das Open der ersten Kerze
    l2 = OPEN[3] > CLOSE[3] AND High[3] > High [2] AND High[2] > High[1] AND Low[3] > Low[2] AND Low[2] > Low[1] AND Close[1] >= Open[3]
    
    //Sell-Condition s1: Kerze vor 3 Perioden muss bullish sein und es müssen 3 Kerzen mit höheren Hochs und höheren Tiefs und der SK der vorherigen Kerze ist kleiner als der SK's der ersten Kerze, wenn der SK von Kerze 1 kleiner als das Close ist
    s1 = OPEN[3] < CLOSE[3] AND High[3] < High [2] AND High[2] < High[1] AND Low[3] < Low[2] AND Low[2] < Low[1] AND Close[1] <= Close[3]
    //Sell-Condition s2: Kerze vor 3 Perioden muss bearish sein und es müssen 3 Kerzen mit höheren hoch und hheren Tiefs und der SK der vorherigen Kerze ist kleiner als der SK's der ersten Kerze, wenn der SK von Kerze 1 kleiner als das Close ist
    s2 =OPEN[3] > CLOSE[3] AND High[3] < High [2] AND High[2] < High[1] AND Low[3] < Low[2] AND Low[2] < Low[1] AND Close[1] <= Open[3]
    
    //Kauforder zur Eröffnung der nächsten Kerze wenn Konditionen l1 oder l2 erfüllt sind
    IF l1 OR l2 THEN
    BUY 1 SHARES AT MARKET NextBarOpen
    ENDIF
    
    //Verkauforder zur Eröffnung der nächsten Kerze wenn Konditionen s1 oder s2 erfüllt sind
    IF s1 OR s2 THEN
    SELLSHORT 1 SHARE AT MARKET NextBarOpen
    ENDIF
    
    //For LONG trades:
    IF LongOnMarket THEN
    SET STOP LOSS (close - low[1])       //difference betwee current price and LOW of candle 3
    SET TARGET PROFIT (high[3] - close)  //difference between the HIGH of candle 1 and current price (a lower current price is assumed)
    EndIF
    //For SHORT trades:
    IF ShortOnMarket THEN
    SET STOP LOSS (high[1] - close)     //difference betwee current price and HIGHof candle 3
    SET TARGET PROFIT (close - low[3])  //difference between the LOW of candle 1 and current price (a higher current price is assumed)
    EndIf
    Long-Entry.jpg Long-Entry.jpg
    #77366 quote
    GraHal
    Participant
    Master

    If anybody else can see / understand what is wrong / not happening here then feel free to step in and help Marc.

    #77367 quote
    Vonasi
    Moderator
    Master

    The last image appears to meet your condition l2.

    Are you aware that the candles are indexed like this?

    [attachment file=77368]

    GraHal and Marc thanked this post
    Screenshot_7.png Screenshot_7.png
    #77375 quote
    Marc
    Participant
    Average

    Hi Vonasi,

    I thought that the code works the following way:
    candle 1, candle 2 and candle 3 meet the conditions. If they are in line with the strategy candle 0 shall be executing market order candle. TP and SL shall be linked with highs or lows of candle 1-3.
    Du you understand what I mean?

     

    Regards Marc

    #77376 quote
    Vonasi
    Moderator
    Master

    Candle zero is the last closed candle. It is at the close of this candle that all decisions are made based on your code. The trade is opened at the open of the next candle.

    It is as I showed in the image that I posted. Your strategy ignores the most recently closed candle and bases all its decisions on the three candles before. Subtract 1 from all your candle index numbers and maybe the strategy will trade how you think it should.

    GraHal thanked this post
    #77377 quote
    robertogozzi
    Moderator
    Master

    The last image appears to meet your condition l2.

    l1

    #77378 quote
    robertogozzi
    Moderator
    Master

    You must save your SL and TP and set them only once, otherwise they might change at any future bar, as Vonasi explained:

    DEFPARAM CumulateOrders = true
     
    //Buy-Condition l1: Kerze vor 3 Perioden muss bullish sein und es müssen 3 Kerzen mit tieferen Hochs und tieferen Tiefs folgen und der Schlusskurs der vorherigen Kerze muss größer sein als der Schlusskurs der ersten Kerze
    l1 = OPEN[3] < CLOSE[3] AND High[3] > High [2] AND High[2] > High[1] AND Low[3] > Low[2] AND Low[2] > Low[1] AND Close[1] >= Close[3]
     
    //Buy-Condition l2: Kerze vor 3 Perioden muss bearish sein und es müssen 3 Kerzen mit tieferen Hochs und tieferen Tiefs folgen und der Schlusskurs der vorherigen Kerze ist größer als das Open der ersten Kerze
    l2 = OPEN[3] > CLOSE[3] AND High[3] > High [2] AND High[2] > High[1] AND Low[3] > Low[2] AND Low[2] > Low[1] AND Close[1] >= Open[3]
     
    //Sell-Condition s1: Kerze vor 3 Perioden muss bullish sein und es müssen 3 Kerzen mit höheren Hochs und höheren Tiefs und der SK der vorherigen Kerze ist kleiner als der SK's der ersten Kerze, wenn der SK von Kerze 1 kleiner als das Close ist
    s1 = OPEN[3] < CLOSE[3] AND High[3] < High [2] AND High[2] < High[1] AND Low[3] < Low[2] AND Low[2] < Low[1] AND Close[1] <= Close[3]
    //Sell-Condition s2: Kerze vor 3 Perioden muss bearish sein und es müssen 3 Kerzen mit höheren hoch und hheren Tiefs und der SK der vorherigen Kerze ist kleiner als der SK's der ersten Kerze, wenn der SK von Kerze 1 kleiner als das Close ist
    s2 =OPEN[3] > CLOSE[3] AND High[3] < High [2] AND High[2] < High[1] AND Low[3] < Low[2] AND Low[2] < Low[1] AND Close[1] <= Open[3]
     
    //Kauforder zur Eröffnung der nächsten Kerze wenn Konditionen l1 oder l2 erfüllt sind
    IF l1 OR l2 AND Not OnMarket THEN       //Not OnMarket will prevent SL & TP to be recalculated
       SL = (close - low[1])                //difference between current price and LOW of candle 1
       TP = (high[3] - close)               //difference between the HIGH of candle 3 and current price (a lower current price is assumed)
       BUY 1 SHARES AT MARKET //NextBarOpen
       SET STOP   LOSS   SL
       SET TARGET PROFIT TP
    ENDIF
     
    //Verkauforder zur Eröffnung der nächsten Kerze wenn Konditionen s1 oder s2 erfüllt sind
    IF s1 OR s2 AND Not OnMarket THEN      //Not OnMarket will prevent SL & TP to be recalculated
       SL = (high[1] - close)              //difference between current price and HIGH of candle 1
       TP = (close - low[3])               //difference between the LOW of candle 3 and current price (a higher current price is assumed)
       SELLSHORT 1 SHARE AT MARKET //NextBarOpen
       SET STOP   LOSS   SL
       SET TARGET PROFIT TP
    ENDIF
    GraHal thanked this post
    #77388 quote
    Marc
    Participant
    Average

    It still looks mad -.-

    Perhaps the strategy is not really that good

    #77389 quote
    Vonasi
    Moderator
    Master

    l1

    My mistake – I got my open[3] < or > close[3] condition mixed up as I always write it the other way round – close before open!

    #77390 quote
    Vonasi
    Moderator
    Master

    It still looks mad -.-

    Perhaps the strategy is not really that good

    Or maybe it is better on a different market and a different time frame? But usually if it feels like a failure straight out of the box it usually is!

    #77392 quote
    GraHal
    Participant
    Master

    @Marc looks like maybe you should work on it on 4H TF on DJI?

    Attached are results for Roberto version code

    Marc-4.jpg Marc-4.jpg
Viewing 15 posts - 31 through 45 (of 83 total)
  • You must be logged in to reply to this topic.

3 Candle Strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Marc @mast83 Participant
Summary

This topic contains 82 replies,
has 6 voices, and was last updated by Regan2020
5 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/25/2018
Status: Active
Attachments: 23 files
Logo Logo
Loading...