Comparing Price as condition
Forums › ProRealTime English forum › ProOrder support › Comparing Price as condition
- This topic has 10 replies, 3 voices, and was last updated 9 months ago by JS.
-
-
03/02/2024 at 4:49 AM #229067
Hi I am trying to write a code to compare the price of previous bars and trigger a flag. what is wrong with this condition? It looks like the close[2]>close[3] doesnt return anything and T always become T=1 at 101000.
If time=100000 then
T=0
end if
If close[2]>close[3] and time>101000 then
T=1
Endif
03/02/2024 at 9:17 AM #229069It’s probably easier to say, in text, what you want to achieve?
close[2]>close[3] doesnt return anything
Abobe returns boolean logic, i.e. either 0 or 1.
close[2]>close[3] and time>101000
When close[2]>close[3] is coincident with time>101000 then T will stay at 1 until the next day at 100000 when T will become 0 for a minimum of 1 minute (until this cycle repeats).
03/02/2024 at 10:05 AM #229074T will become 0 for a minimum of 1 minute
Above should have read … T will become 0 for a minimum of 10 minutes.
03/02/2024 at 10:10 AM #22907503/02/2024 at 11:24 AM #22907903/02/2024 at 12:15 PM #229082If you want to check if the last three “closes” where lower, you can also use the following code…
Including the current bar:
Close[0]<Close[1] and Close[1]<Close[2]
Or excluding the current bar:
Close[1]<Close[2] and Close[2]<Close[3]
The code will be (including the current bar):
3 Lower123456789If Time>101000 thenIf Close[0]<Close[1] and Close[1]<Close[2] thenT=1ElseT=0EndIfEndIfReturn T as "T"1 user thanked author for this post.
03/02/2024 at 3:10 PM #229092when I use the condition in strategy for back testing it doesn’t work.
Close[0]<Close[1] and Close[1]<Close[2] doesn’t return anything
The other formula (summation) also not right because i want to compare the closes, there might be a time when close is lower than open but the close is still higher than the privous bar, i need to compare the close of each bar.
03/02/2024 at 3:22 PM #22909303/02/2024 at 3:55 PM #22909403/02/2024 at 11:46 PM #229121Thanks but still not working. I used the below code:
123456789101112if time=100000 thenTL=0endifTL=summation[3](close<close[1])=3if time>101000 and time<140000 and TL=1 and countoflongshares<2 and close>open[1] thenbuy 2 contracts at marketset stop loss lowest[5]-close+10endifif longonmarket and close<open[1] thensell 2 contracts at marketendif03/03/2024 at 12:44 AM #229122 -
AuthorPosts
Find exclusive trading pro-tools on