3 Candle Strategy
Forums › ProRealTime English forum › ProOrder support › 3 Candle Strategy
- This topic has 82 replies, 6 voices, and was last updated 4 years ago by Regan2020.
-
-
08/02/2018 at 9:33 AM #77395
Attached are results for Roberto version code
But Roberts code still has the conditions looking at the wrong candles.
08/02/2018 at 10:06 AM #77398It works good on high TF’s. On DAX Daily it yields good profits, but only 6 trades in 8 years!
I have something to point out:
- the higher the TF, the more reliable patterns are (yours, Doji, Hammer, Engulfing, ….); if you are looking for many trades then you must devote to lower TF’s and it is not likely to work!
- are you sure your patterns are good? how did they come to your mind… tests, rumors, what else? Because they seem a bit odd!
- you set your SL and TP based on the current CLOSE, are you sure the SL (say in a LONG position) is really lower (and TP higher) than entry price?
- you never care about the current candle, but THAT is the entry price at which your trade will open.
I mean, maybe you should rethink it a bit… make some changes, or even drop it (I have about 30 running strategies on demo, but I have coded a few hundreds, my trash bin is FULL).
08/02/2018 at 10:22 AM #77399you never care about the current candle, but THAT is the entry price at which your trade will open.
I think we established earlier on that the OP misunderstood how the candle indexing system worked and did not realise that the most recently closed candle was candle zero. However I have modified his code to look at what I believe are the candles he wanted to look at and also changed the indexing in the SL and TP calculations and it still does not work very well. Losses on fast time frames and barely any trades on slower time frames.
08/02/2018 at 1:41 PM #77409Here’s the current code as I think that the System should work:
123456789101112131415161718192021222324252627282930DEFPARAM CumulateOrders = false//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 Kerzel1 = OPEN[2] < CLOSE[2] AND High[2] > High [1] AND High[1] > High AND Low[2] > Low[1] AND Low[1] > Low AND Close >= Close[2]//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 Kerzel2 = OPEN[2] > CLOSE[2] AND High[2] > High [1] AND High[1] > High AND Low[2] > Low[1] AND Low[1] > Low AND Close >= Open[2]//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 ists1 = OPEN[2] < CLOSE[2] AND High[2] < High [1] AND High[1] < High AND Low[2] < Low[1] AND Low[1] < Low AND Close <= Close[2]//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 ists2 =OPEN[2] > CLOSE[2] AND High[2] < High [1] AND High[1] < High AND Low[2] < Low[1] AND Low[1] < Low AND Close <= Open[2]//Kauforder zur Eröffnung der nächsten Kerze wenn Konditionen l1 oder l2 erfüllt sindIF l1 OR l2 AND Not OnMarket THEN //Not OnMarket will prevent SL & TP to be recalculatedSL = (close - low[1]) //difference between current price and LOW of candle 1TP = (high[3] - close) //difference between the HIGH of candle 3 and current price (a lower current price is assumed)BUY 1 SHARES AT MARKET //NextBarOpenSET STOP LOSS SLSET TARGET PROFIT TPENDIF//Verkauforder zur Eröffnung der nächsten Kerze wenn Konditionen s1 oder s2 erfüllt sindIF s1 OR s2 AND Not OnMarket THEN //Not OnMarket will prevent SL & TP to be recalculatedSL = (high[1] - close) //difference between current price and HIGH of candle 1TP = (close - low[3]) //difference between the LOW of candle 3 and current price (a higher current price is assumed)SELLSHORT 1 SHARE AT MARKET //NextBarOpenSET STOP LOSS SLSET TARGET PROFIT TPENDIF08/02/2018 at 2:17 PM #77411did not realise that the most recently closed candle was candle zero.
but we say Close[1] when we want close of the most recently closed candle?? Or have I had it wrong all the time??? 🙂
08/02/2018 at 2:27 PM #77412did not realise that the most recently closed candle was candle zero.
but we say Close[1] when we want close of the most recently closed candle?? Or have I had it wrong all the time??? 🙂
The most recently closed candle is [0], or no brackets at all, (close, high, low, open, range,….), usually it is called the SETUP CANDLE.
08/02/2018 at 2:27 PM #77413Current Candle is always 0…this means that my calculations are based on candles 2,1,0…if condition is met market order is placed and SL/TP are calculated and linked to open position…
I have to rechek if the code is okay…I found a bugDoes this mean that my SL and TP are calculated based when postion is entered?
As an example:
candle 2,1,0 meet the condition and position will be opened on next candle…
for better understanding
candle 2 is now candle 3,
candle 1 is now candle 2,
candle 0 is now candle 1
and candle 0 is the one in which TPP and SL must be calculated…Am I right?
08/02/2018 at 2:31 PM #77414I think that there is still abug within the code, but here an amended version
123456789101112131415161718192021222324252627282930DEFPARAM CumulateOrders = false//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 Kerzel1 = OPEN[2] < CLOSE[2] AND High[2] > High [1] AND High[1] > High AND Low[2] > Low[1] AND Low[1] > Low AND Close >= Close[2]//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 Kerzel2 = OPEN[2] > CLOSE[2] AND High[2] > High [1] AND High[1] > High AND Low[2] > Low[1] AND Low[1] > Low AND Close >= Open[2]//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 ists1 = OPEN[2] < CLOSE[2] AND High[2] < High [1] AND High[1] < High AND Low[2] < Low[1] AND Low[1] < Low AND Close <= Close[2]//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 ists2 =OPEN[2] > CLOSE[2] AND High[2] < High [1] AND High[1] < High AND Low[2] < Low[1] AND Low[1] < Low AND Close <= Close[2]//Kauforder zur Eröffnung der nächsten Kerze wenn Konditionen l1 oder l2 erfüllt sindIF l1 OR l2 AND Not OnMarket THEN //Not OnMarket will prevent SL & TP to be recalculatedSL = (close - low[1]) //difference between current price and LOW of candle 1TP = (high[3] - close) //difference between the HIGH of candle 3 and current price (a lower current price is assumed)BUY 1 SHARES AT MARKET //NextBarOpenSET STOP LOSS SLSET TARGET PROFIT TPENDIF//Verkauforder zur Eröffnung der nächsten Kerze wenn Konditionen s1 oder s2 erfüllt sindIF s1 OR s2 AND Not OnMarket THEN //Not OnMarket will prevent SL & TP to be recalculatedSL = (high[1] - close) //difference between current price and HIGH of candle 1TP = (close - low[3]) //difference between the LOW of candle 3 and current price (a higher current price is assumed)SELLSHORT 1 SHARE AT MARKET //NextBarOpenSET STOP LOSS SLSET TARGET PROFIT TPENDIF08/02/2018 at 3:04 PM #77418Current Candle is always 0…
Yes, but we have to exactly define what CURRENT means, NOT the candle being formed since it cannot be accessed, but the MOST RECENTLY closed one!
Even with MTF support candles can only be accessed at CLOSING time, the only advantage is that we can use lower TF’s to access data while the candle in the bigger picture is being formed!
So, to recap, [0], or no brackets at all, references the most recenty closed candle.
At lines 16-17, 25-26, SL & TP are calculated on CLOSE (or CLOSE[0]). It will become [1] when the new one (where a trade has been opened) will close thus becoming [0] itself. Whenever a candle closes there’s a shift in the numbering (referencing) system, so that [0] ALWAYS references the most recently closed one! That’s the reason you have to calculate SL & TP only once when entering a trade, otherwise they (since they reference CLOSE) would be recalculated each new bar!
08/02/2018 at 3:27 PM #77419I think that this code is now correct:
123456789101112131415161718192021222324252627282930DEFPARAM 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 Kerzel1 = OPEN[2] < CLOSE[2] AND High[2] > High [1] AND High[1] > High AND Low[2] > Low[1] AND Low[1] > Low AND Close >= Close[2]//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 Kerzel2 = OPEN[2] > CLOSE[2] AND High[2] > High [1] AND High[1] > High AND Low[2] > Low[1] AND Low[1] > Low AND Close >= Open[2]//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 ists1 = OPEN[2] < CLOSE[2] AND High[2] < High [1] AND High[1] < High AND Low[2] < Low[1] AND Low[1] < Low AND Close <= Close[2]//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 ists2 =OPEN[2] > CLOSE[2] AND High[2] < High [1] AND High[1] < High AND Low[2] < Low[1] AND Low[1] < Low AND Close <= Close[2]//Kauforder zur Eröffnung der nächsten Kerze wenn Konditionen l1 oder l2 erfüllt sindIF l1 OR l2 AND Not OnMarket THEN //Not OnMarket will prevent SL & TP to be recalculatedSL = (close[1] - low[1]) //difference between current price and LOW of candle 1TP = (high[3] - close[1]) //difference between the HIGH of candle 3 and current price (a lower current price is assumed)BUY 1 SHARES AT MARKET //NextBarOpenSET STOP LOSS SLSET TARGET PROFIT TPENDIF//Verkauforder zur Eröffnung der nächsten Kerze wenn Konditionen s1 oder s2 erfüllt sindIF s1 OR s2 AND Not OnMarket THEN //Not OnMarket will prevent SL & TP to be recalculatedSL = (high[1] - close[1]) //difference between current price and HIGH of candle 1TP = (close[1] - low[3]) //difference between the LOW of candle 3 and current price (a higher current price is assumed)SELLSHORT 1 SHARE AT MARKET //NextBarOpenSET STOP LOSS SLSET TARGET PROFIT TPENDIFthe coments within this codes must be amended from my side….
08/03/2018 at 7:12 AM #77438So, to recap, [0], or no brackets at all, references the most recenty closed candle.
When I use Close (same as Close[0] ) I always thought I was referring to the current / latest price of the candle which is currently forming?
When I want to refer to the close of the most recently closed / ended / finished candle I use Close[1]?
Am I correct or incorrect or have I only read half the above and I am talking at cross-purposes / confusing myself?
I will in any case use Graph to check out my assertions. Kinda basic / worrying I / we are discussing this … no wonder I’m not making any money on my Auto-Systems!!!!!????? 🙂 🙂
08/03/2018 at 7:27 AM #77439I am talking at cross-purposes / confusing myself?
I am confusing myself and I have been right all along!
It’s surprising, being a recent new coder and now having a break for a month or two basic assertions start to slip away.
Close / Close[0] is the current price (if bar not closed) OR closing price of the bar that just closed / same bar which caused my code to just be read (at the end of each closed bar).
If I want to refer to the close of the bar that closed immediately prior to this latest bar then it is Close[1].
Sheeesh … I think I’ll stick to my building and cars at least I can see what is going on!!! haahahaha
08/03/2018 at 8:25 AM #77444I think that some of the confusion may be due to the difference between coding an indicator compared to coding a strategy. In an indicator code bar[0] is the currently forming bar and in strategies it is the last closed bar due to the fact that a strategy does everything at the bar close and indicators change their output values on the fly and so do not wait for bar[0] to be closed.
08/03/2018 at 2:16 PM #7747708/03/2018 at 4:40 PM #77489Aloha @all,
Last question for my understanding…
I think it’s quite a little bit to hard for me to understand which candle is necessary for market entry…I have three candle which have to meet conditions to form an entry. When conditions are correct than a market order incl. SL/TP are placed.
Perhaps attached image shows the way of calculation…and somebody can tell me/us the correct way of calculating.Gracias
-
AuthorPosts
Find exclusive trading pro-tools on