Extending a limit order
Forums › ProRealTime English forum › ProOrder support › Extending a limit order
- This topic has 16 replies, 3 voices, and was last updated 1 year ago by robertogozzi.
-
-
04/03/2023 at 6:39 PM #212748
Hello folks,
I’m trying to enter the market on a pullback that can occur up to five bars after one of the entry conditions is met.
I would like to enter on the furthermost right bar in this screengrab (when price pulls back to the 15EMA), but it currently doesn’t work. I can tell from the graph drawing that it is because my entry rule of close >=highfractal+7 has become invalid. How can I save this entry rule to memory and allow the system to wait 5 bars for the price to pull back to the EMA?
Thanks in advance for your help 🙂
Current code123456789101112131415161718192021222324252627282930313233343536373839DEFPARAM CumulateOrders = FalseONCE HighCount = UndefinedONCE HighFractal = UndefinedONCE NbBarLimit = 10IF (High > High[1]) AND (High > High[2]) and high= highest[4](high) THENHighLevel = HighMyLimitBuy = ExponentialAverage[15](close)MyIndex = BarindexENDIFIF BarIndex >= MyIndex + NbBarLimit THENMyLimitBuy = 0ENDIFIF (High < HighLevel) THENHighCount = HighCount - 1ELSIF (High >= HighLevel) THENHighCount = 0ENDIFIF HighCount = -1 THENHighFractal = HighLevelELSEHighFractal = HighFractalENDIFIF MyLimitBuy > 0 AND NOT LongOnMarket and close >=highfractal+7 THENBUY 1 perpoint AT MyLimitBuy LIMITENDIFSET STOP pLOSS 10SET TARGET pPROFIT 20graph close >=highfractal+704/14/2023 at 5:13 PM #213306You should post more details about the strategy conditions, along with a screenshot where trigger and entry points are highlighted.
1 user thanked author for this post.
04/14/2023 at 6:13 PM #213314Thank you for bumping this, Roberto.
Rules are:
- New higher high, 7 points or more higher than previous
- Enter when price pulls back to 15ema
I’ve attached a better screengrab showing what ought to be trigger bar and entry bar.
04/16/2023 at 3:19 PM #213355@Mike Boorman
I want to try to understand and help, wich Time Frame for your strategy to do some test ?and maybe also you can change de first groupe of condition to C1 and draw the C1 condition, maybe it’s can be help you :
123456789C1 = (High > High[1]) AND (High > High[2]) and high= highest[4](high)IF C1 THENHighLevel = HighMyLimitBuy = ExponentialAverage[15](close)MyIndex = BarindexENDIFGraph C1 AS "C1"1 user thanked author for this post.
04/16/2023 at 4:40 PM #213361Thanks for the response, @ZeroCafeine
I’ve amended the code like you said and created a screengrab.
I’m working on the DAX 5 minute, April 14 2023.
1 user thanked author for this post.
04/16/2023 at 7:05 PM #213368Hi
I don’t understand every think from your code, if you can explain more what do you want to do,But after cheking your code and try to understand it, I saw a first problem in the line 8 :
12IF (High > High[1]) AND (High > High[2]) and high= highest[4](high) THEN// Last condition : high= highest[4](high)this last condition is useless because it will always be true,
First case : when you use the Highset function on the last 4 candles, don’t forget that you also include the last candle (Candle[0]), so if the High of the last candle is higher than the last 3 then your code means the same thing as this: Highest[0] = High[0] and this is always true, so you don’t need this condition,
Second case : if you don’t want to include the last candle [0] in the Highest fonction, it’s possible but you have to use like this :
1high = highest[4](high[1])in this case you compare the last high with the high of the other candlestick, on the other hand in this case you want the high of the last candle to be equal to the highest high you will find, and then in this case there is a high probability that you will not find this case, it is possible but rare
I hope to be clear and not to be mistaken, if you do not understand I can make you a diagram
04/18/2023 at 11:10 AM #213436I’ve changed the code to the high=highest[4](high[1]) you suggested, but this isn’t the problem. My problem is that I want PRT to remember that the high condition WAS true, and then enter the market once the price drops back to the 15EMA.
I’ve done another screengrab with the new code, pointing to the bar I want to enter (in this case it comes two bars after the high condition is true). How can I enter the market here?
Sample code123456789101112131415161718192021222324252627282930313233343536373839404142DEFPARAM CumulateOrders = FalseONCE HighCount = UndefinedONCE HighFractal = UndefinedONCE NbBarLimit = 5C1 = high= highest[4](high[1])If c1 thenHighLevel = HighMyLimitBuy = ExponentialAverage[15](close)MyIndex = BarindexENDIFIF BarIndex >= MyIndex + NbBarLimit THENMyLimitBuy = 0ENDIFIF (High < HighLevel) THENHighCount = HighCount - 1ELSIF (High >= HighLevel) THENHighCount = 0ENDIFIF HighCount = -1 THENHighFractal = HighLevelELSEHighFractal = HighFractalENDIFIF MyLimitBuy > 0 AND NOT LongOnMarket and close >=highfractal+7 THENBUY 1 perpoint AT MyLimitBuy LIMITENDIFSET STOP pLOSS 10SET TARGET pPROFIT 20//graph highfractalgraph C1 as "C1"04/21/2023 at 12:21 PM #213575@Mike Boorman
I don’t understand what you want to do between line 19 and 29, but maybe this can helo you, change all your buy condition to one condition and graph it like that :
1234567BuyConditions = MyLimitBuy > 0 AND NOT LongOnMarket and close >=highfractal+7IF BuyConditions THENBUY 1 Shares AT MyLimitBuy LIMITENDIFGraph BuyConditions AS "BuyCondition"and you will see on the graphique, your BuyConditions is all the time false so all the time the BuyConditions = 0, So that is maybe why your code no buy anythink
05/02/2023 at 1:48 AM #213961There you go:
12345678910111213141516ONCE Signal = 0Ema15 = average[15,1](close)IF high > (high[1] + 7*PipSize) THENSignal = 1ENDIFIF OnMarket THENSignal = 0ELSEIF Signal = 1 THENIF low <= Ema15 THENBUY 1 Contract at MarketSET STOP pLOSS 50SET TARGET pPROFIT 100ENDIFENDIFENDIF1 user thanked author for this post.
05/04/2023 at 4:28 PM #214137Thank you for your help Roberto. I’ve just run a test. As you can see from the screengrab, signal = 1 even when the market is going down, which isn’t what I want.
If the market is going down with red bars, I can’t understand how the high of the current bar could possibly be greater than the high[1] + 7? But PRT is saying it’s true.
05/07/2023 at 10:59 AM #214257It’s because the SIGNAL is never cleared, unless OnMarket, so if the trend reverses the signals is still retained.
This version will clear the SIGNAL whenever a candle closes BELOW Ema15:
1234567891011121314ONCE Signal = 0Ema15 = average[15,1](close)IF high > (high[1] + 7*PipSize) THENSignal = 1ENDIFIF close < Ema15 THENSignal = 0ENDIFIF Not OnMarket AND Signal AND ((low <= Ema15) AND (min(open,close) >= Ema15)) THENBUY 1 Contract at MarketSET STOP pLOSS 50SET TARGET pPROFIT 100Signal = 0ENDIF1 user thanked author for this post.
05/07/2023 at 9:30 PM #214271Thanks Roberto. It’s getting closer 🙂
I want to be more clever with the previous high. At the moment signal is true if high is +7 from the previous bar, but I’d like it to be +7 from a previous high. I’m not exactly sure how to define the ‘previous high’ I am seeing with my eyes, but I’ve attached a screengrab to show what I mean.
05/22/2023 at 11:34 PM #215039I was trying to understand what’s the issue, but I need your latest code used.
1 user thanked author for this post.
05/23/2023 at 9:12 AM #215049Thanks for you offer of help, Roberto. These are the rules:
-New higher high, 7 points or more higher than last significant high
-Enter when price pulls back to 15ema123456789101112131415161718192021StartTime = 080000Limitentrytime = 230000daysforbiddenentry = OpenDayOfWeek=6 OR OpenDayOfWeek=0Definitehigh=highest[10](high)ONCE Signal = 0Ema15 = average[15,1](close)IF high > (high[1] + 7) THENSignal = 1ENDIFIF close < Ema15 THENSignal = 0ENDIFIF Not OnMarket AND Signal AND ((low <= Ema15) AND (min(open,close) >= Ema15)) and time >=StartTime and time <=LimitEntrytime and not daysForbiddenEntry THENBUY 1 perpoint at MarketSET STOP pLOSS 16SET TARGET pPROFIT 5ENDIFgraph signalThe problem is that ‘signal’ is currently derived from high[1], which is the previous bar. I don’t want to consider the previous bar. I want to consider the previous significant high with a look back. In the screengrab I have attached, I want ‘signal’ to become true on the bar where I have put the left green arrow. Once the signal becomes true, the green arrow to the right should then become an entry when the price pulls back to the 15ema.
Thank you again for your help.
05/23/2023 at 11:23 AM #215057Try replacing line 9 with:
1IF high >= (Definitehigh[1] + 7) THEN1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on