Previous bar low from highest bar achieved !
Forums › ProRealTime English forum › ProOrder support › Previous bar low from highest bar achieved !
- This topic has 7 replies, 3 voices, and was last updated 3 years ago by Slowlyslowly.
-
-
07/01/2020 at 8:42 PM #138016
Hi
how would you code wanting a break of the previous bar low On the bar prior to the highest bar since the code was activated ? And if a new highest bar was achieved it then moves to recognise the new bar as the highest so targets the bar previous low ?
07/02/2020 at 3:32 PM #13810607/02/2020 at 3:53 PM #138109This is what I coded, provided I could correctly understand what you meant:
12345678910111213141516171819IF BarIndex = 0 THEN// initialization of variablesMyHI = highMyBAR = 0Entry = 0ELSE// find new HIGH (MyHI), if any, and eventually update bar index (MyBAR)MyHI = max(MyHI,high)MyBAR = max(MyBAR,BarIndex * (MyHI <> MyHI[1]))ENDIFIF BarIndex > 3 THEN//we need at least 3 bars:// 1 = the HIGHest// 2 = the bar prior to the HIGHEST// 3 = the LOW of the bar PRIOR to #2i = BarIndex - MyBAREntry = low[i - 2]ENDIF// ENTRY is the price you want to break1 user thanked author for this post.
07/02/2020 at 4:00 PM #138110Try adding this indicator to your chart, to display a histogram whenever a new HIGH is found (start with 200 units, to make sure you don’t have to scroll backwards too far):
1234567891011121314151617181920212223IF BarIndex = 0 THEN// initialization of variablesMyHI = highMyBAR = 0//Entry = 0ELSE// find new HIGH (MyHI), if any, and eventually update bar index (MyBAR)MyHI = max(MyHI,high)MyBAR = max(MyBAR,BarIndex * (MyHI <> MyHI[1]))ENDIFIF BarIndex > 3 THEN//we need at least 3 bars:// 1 = the HIGHest// 2 = the bar prior to the HIGHEST// 3 = the LOW of the bar PRIOR to #2//i = BarIndex - MyBAR//Entry = low[i - 2]ENDIFx = 0IF MyHI <> MyHI[1] THENx = 1ENDIFRETURN x AS "Signal"1 user thanked author for this post.
07/02/2020 at 4:04 PM #138113Thanks GRAHAL, good idea I’ve now uploaded screen shots – first shows initial set up it takes the highest new bar SINCE code activated. and would trigger a sell when the low of the previous bar is hit . If a new higher bar is achieved it ignores the previous and resets with this new bar and takes the previous bar low as the trigger.
07/03/2020 at 8:53 AM #138218Roberto
Is it also possible that if the previous bar close is NOT lower than the current bar close nothing is triggered and it looks back to find a previous bar close that is lower than the current bar to activate on ?
07/03/2020 at 12:26 PM #138271There you go:
123IF close[1] >= close THEN// add here the code preventing an event from being triggeredENDIF07/04/2020 at 12:14 PM #138386Roberto
The code just enters on the first bar close from when the code is activated, every time – seems to be no relation to your code just added a c1 and c2 ?
test code1234567891011121314151617181920212223242526272829303132// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0IF BarIndex = 0 THEN// initialization of variablesMyHI = highMyBAR = 0Entry = 0ELSE// find new HIGH (MyHI), if any, and eventually update bar index (MyBAR)MyHI = max(MyHI,high)MyBAR = max(MyBAR,BarIndex * (MyHI <> MyHI[1]))ENDIFIF BarIndex > 3 THEN//we need at least 3 bars:// 1 = the HIGHest// 2 = the bar prior to the HIGHEST// 3 = the LOW of the bar PRIOR to #2i = BarIndex - MyBAREntry = low[i - 2]c1= myhi>6535c2=entry-2ENDIFif not daysforbiddenentry and c1 and c2 thenSELLSHORT 3 perpoint AT MARKET// ENTRY is the price you want to break// Stops and targetsSET STOP pLOSS 100SET TARGET pPROFIT 100endif?? am i doing something wrong ?
-
AuthorPosts
Find exclusive trading pro-tools on