How to count the Buy entry ?
Forums › ProRealTime English forum › ProOrder support › How to count the Buy entry ?
- This topic has 10 replies, 2 voices, and was last updated 1 year ago by ZeroCafeine.
-
-
04/11/2023 at 7:07 PM #213131
Hi All
How to count the buy order will be realy executed and stop buying after 3 time :
1234567891011Defparam cumulateorders = TrueSMA10 = Average[10](close)SMA20 = Average[20](close)SMA100 = Average[100](close)C1 = SMA10 Crosses Over SMA20 AND SMA20 > SMA100IF C1 THENBUY 1 CONTRACTS AT MARKETCount = Count + 1 // Only if the Purchase is executedENDIFor a line number for Snippet also will be ok
Best Reguards,
ZeroCafeine04/11/2023 at 7:16 PM #213137You have to use COUNT in your entry conditions, provided it is cleared when not on market:
1234567891011121314Defparam cumulateorders = TrueIF Not OnMarket THENCount = 0ENDIFSMA10 = Average[10](close)SMA20 = Average[20](close)SMA100 = Average[100](close)C1 = SMA10 Crosses Over SMA20 AND SMA20 > SMA100IF C1 AND (Count < 3) THENBUY 1 CONTRACTS AT MARKETCount = Count + 1 // Only if the Purchase is executedENDIF1 user thanked author for this post.
04/11/2023 at 7:40 PM #213142tks you so much for your quick answer, So I have to think like, I’m or not in market, when I see your answer it’s seems like easy, but I don’t know to think like that, I hope soon 😉
04/11/2023 at 11:16 PM #213152You have to use COUNT in your entry conditions, provided it is cleared when not on market:
tks again for your answers, But Once again, I have phrased my question incorrectly :
– How to count in the case of Limit order ? you can see in the photo, The conditions for the purchase were met except for the price limit
– we can also met the same situation in the case of my Buy order is filled (so at this time we are OnMarket) But if my order is closed because of a stop loss so we will be in the case of Not OnMarket (So Count = 0) even we execute the Buy only one time04/12/2023 at 8:46 AM #213158I found this solution, maybe you have an other idea :
123456789101112131415161718Defparam cumulateorders = Trueif intradaybarindex=0 then // we reset Count every dayCount = 0endifSMA10 = Average[10](close)SMA20 = Average[20](close)SMA100 = Average[100](close)C1 = SMA10 Crosses Over SMA20 AND SMA20 > SMA100IF C1 AND (Count <= 3) THENBUY 1 CONTRACTS AT MARKETENDIFIF OnMarket AND Not OnMarket[1] THENCount = Count + 1 // Like thit we are sure to add 1 only if we are on market and the candle just before we are not on marketENDIF04/12/2023 at 9:03 AM #213160A better solution is to reset COUNT at the beginning of a new trading day:
123IF IntraDayBarIndex = 0 THENCount = 0ENDIFthe issue with pending orders can be addressed with this code, which detects a new entry (to be tallied when there are more positions on market than there were the prior candle:
123456789101112131415161718Defparam cumulateorders = TrueIF IntraDayBarIndex = 0 AND Not OnMarket THENCount = 0ENDIFSMA10 = Average[10](close)SMA20 = Average[20](close)SMA100 = Average[100](close)myPos = abs(CountOfPosition)Count = Count + (myPos > myPos[1])C1 = SMA10 Crosses Over SMA20 AND SMA20 > SMA100IF C1 AND (Count < 3) THENBUY 1 CONTRACTS AT low - 10*PipSize LIMITENDIFset target pprofit 100set stop ploss 10004/12/2023 at 9:12 AM #213161Actually, instead of checking positions, you might use:
1Count = Count + LongTriggered04/12/2023 at 9:38 AM #213163My subconscious found the solution while I slept last night, but with your solution on top of it, I’m lost …. 😅
Actually I’m joking 😊, again thank you for your answer I totally understand your solution and I will try to understand it even better,
About line 15, wouldn’t it be better to use the Close than Low, also maybe the Close +2 pips in limit for exemple
With a buy at Low – 10 pips, do I risk not getting executed and the market going without me ?
04/12/2023 at 1:51 PM #213188in the continuity of my code I realise that if I am in position and I take another position then my line 16 does not work so I had to add this :
12IF OnMarket AND Not OnMarket[1] OR ABS(CountOfPosition) > ABS(CountOfPosition[1]) THENCount = Count + 1ENDIFIt seems to work, I’ll come back at the end of the day to do more tests and compare with your solution @robertogozzi which seems much simpler than mine and I think it does the job
04/12/2023 at 2:21 PM #213190That’s how it takes me more than 4 hours on Wednesday to have 15 minutes of concentration to understand what it is, I’m sick of this temporary office 🤣🤣🤣🤣
Wish me luck
04/13/2023 at 11:21 PM #213259Actually, instead of checking positions, you might use:
1Count = Count + LongTriggeredPerfect 😊
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on