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 1 month ago by avatarJS.
Viewing 11 posts - 1 through 11 (of 11 total)
  • #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

    #229069

    It’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).

    #229074

    T will become 0 for a minimum of 1 minute

    Above should have read … T will become 0 for a minimum of 10 minutes.

    #229075

    I want to have conditions to check if for the last 3 bars the price was closing lower each time and if so then make T=1

    #229079

     

    #229082
    JS

    If 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):

    1 user thanked author for this post.
    #229092

    when 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.

    #229093

    Above wont ‘return’ anything other than True / 1.

    But then you might code …

     

    #229094
    JS

    Maybe someone else can help you…

    You’re clearly a lot further along when you can judge that the formulas are wrong and not working…

    #229121

    Thanks but still not working. I used the below code:

     

    #229122
    JS

    The code doesn’t work because you’ve taken a strange combination of conditions…

    TL=Summation[3](Close<Close[1])=3 in combination with Close>Open[1]

    Try:

    if time>101000 and time<140000 and TL=1 and countoflongshares<2 then

Viewing 11 posts - 1 through 11 (of 11 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login