Stopping trading after crossing balance
Forums › ProRealTime English forum › ProOrder support › Stopping trading after crossing balance
- This topic has 13 replies, 3 voices, and was last updated 2 years ago by egyptiantrader.
-
-
10/07/2021 at 9:26 AM #179171
Hi all.
I want to add some code that checks to see if the price is moving above or below a zone perhaps increasing a counter than can be then referred to to stop trading if it’s over a certain number in the last x amount of candles.
The counter must only increase when the price goes from on side to the other not if it goes into the green box and back out the same side.
Thanks in advance.
10/09/2021 at 12:01 PM #179258There you go:
1234567891011121314151617181920Periods = 40Bullish = close > openBearish = close < openHH = highest[Periods](close)LL = lowest[Periods](close)Rng = (HH - LL) / 4IF (HH <> HH[1]) OR (LL <> LL[1]) THENTally = 0ENDIFHItouch = high >= HHLOtouch = low <= LLIF HItouch AND Bullish THENTally = Tally + 1DrawText("#Tally#",BarIndex,HH + Rng)ENDIFIF LOtouch AND Bearish THENTally = Tally + 1DrawText("#Tally#",BarIndex,LL - Rng)ENDIFRETURN HH AS "Top",LL AS "Bottom"The count is cleared anytime one of the two limits changes.
You can embed this code in your strategy (without the last line) and make your trading decisions according to the value retained by TALLY.3 users thanked author for this post.
10/09/2021 at 12:21 PM #179261Link to above added as Log 307 here …
1 user thanked author for this post.
10/09/2021 at 1:06 PM #179262You can also try replacing lines 4-5 with:
12HH = highest[Periods](max(open,close))LL = lowest[Periods](min(open,close))This will make limits change a bit more frequently, thus clearing the count more often.
10/11/2021 at 3:05 PM #179399Thank you.
Would it be possible to not reset the counter if the price goes in then out of the same side? I don’t want it to add to the counter but I also don’t want it to reset.
To be clear I want the counter to increase each time the price goes from one side to the other in a given period.
I have the variables “upper” and Lower set in the code I assume I can just switch HH and LL for my terms?
Thank you for your help, I really appreciate it.
10/13/2021 at 11:32 AM #179572There you go:
123456789101112131415161718192021222324252627282930ONCE Periods = 20ONCE Alternate = 1 //1=only alternate touches, 0=all touchesONCE HItouch = 0ONCE LOtouch = 0ONCE LastType = 0 //1=HItouch, -1=LOtouchBullish = close > openBearish = close < openHH = highest[Periods](close) //highest[Periods](max(open,close))LL = lowest[Periods](close) //lowest[Periods](min(open,close))IF (HH <> HH[1]) OR (LL <> LL[1]) THENTally = 0LastType = 0ENDIFRng = (HH - LL) / 4HItouch = high >= HHLOtouch = low <= LLIF HItouch THENLastType = 1ELSIF LOtouch THENLastType = -1ENDIFIF HItouch AND Bullish AND LastType = 1 AND ((Tally = 0) OR (Not Alternate) OR (Alternate AND (LastType <> 1))) THENTally = Tally + 1DrawText("#Tally#",BarIndex,HH + Rng)ENDIFIF LOtouch AND Bearish AND LastType = -1 AND ((Tally = 0) OR (Not Alternate) OR (Alternate AND (LastType <> -1))) THENTally = Tally + 1DrawText("#Tally#",BarIndex,LL - Rng)ENDIFRETURN HH AS "Top",LL AS "Bottom"I think this won’t be useful as it is coded, since it hardly counts higher than 1.
You need to define another way to spot the area, other than using close (I used CLOSE as you posted no hints about the definition of that area).1 user thanked author for this post.
10/14/2021 at 9:24 AM #179654Thanks. I should be able to adjust to fit into my algo.
Can you recommend a good teacher/course/tutorials where I can improve my coding? I’m about halfway through the advanced course and it’s getting to the stage where it’s becoming hard to follow without having exercises etc to practice the previous chapters.
I’m only about a month into coding, I feel like I’m maybe missing some background knowledge on concepts etc.
10/14/2021 at 10:10 AM #179662Sorry, I don’t know of any course.
Maybe you can find some on the Marketplace https://market.prorealcode.com/?prcmaf=9f7907cc&from=home.
1 user thanked author for this post.
10/15/2021 at 8:35 AM #179707Maybe you are trying to get in too deep too quick?
Have you coded up a simple strategy all on your own?
Using the Assisted Creation tool is good also as then you can see what the code should be and you can then duplicate a System and modify it. If your modified system system does not run, you can easily compare to the original system which will still run etc.
1 user thanked author for this post.
10/19/2021 at 6:59 PM #179981Hi. I have created several simple systems and got them working as expected. I now want to move on to more advanced coding/concepts that i can use to create a profitable strategy. I think this would be a much quicker process with a mentor/tutor or a course that had some problems/questions set that needed to be coded and feedback on the code you produce.
Maybe a programming course that uses a different language with the same concepts?
10/19/2021 at 7:47 PM #179987Did you see these …
https://market.prorealcode.com/product-category/private-courses/
1 user thanked author for this post.
10/20/2021 at 6:56 AM #179997Idea for you … have a go at coding these two strategies and then compare your code to what is / will be provided by our resident and kind Coding Wizard Roberto?
https://www.prorealcode.com/topic/coding-request-for-ema9-wma30-strategy/
https://www.prorealcode.com/topic/ea-with-multiple-bb/#post-179993
2 users thanked author for this post.
10/20/2021 at 8:39 AM #180000Yes I saw those courses but i was looking for recommendations and maybe something a bit more comprehensive.
10/20/2021 at 8:42 AM #180001Thanks, I’ll give it a go. Should be interesting/funny what I come up with compared to Roberto and I’m sure I’ll learn something. Great suggestion, thanks.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on