Help please – is this loop correct?

Forums ProRealTime English forum ProOrder support Help please – is this loop correct?

Viewing 13 posts - 1 through 13 (of 13 total)
  • #183925

    Hello folks!

     

    I’d like my system to exit long if the MA changes direction at any period between two limits: 50 and 100. Is the following loop correct?

    Please note the instruction “graph PeriodEL” shows a constant result of 101. Is it normal?

    (can’t insert the code, the icon is missing in the toolbar)

     

    Many Thanks

    #183927

    Please note the instruction “graph PeriodEL” shows a constant result of 101. Is it normal?

    Hi Khaled – I did not check the functionality of your loop, but the 101 is normal. The interpreter / compiler will always first add the increment, before it notices that it crosses your set limit (the 100) and then exits. Thus indeed, under the loop you will always observe one increment-step (1 in your case) too high.

    1 user thanked author for this post.
    #183928

    cond1EL = (((Average[PeriodEL](close)[2]<Average[PeriodEL](close)[1] and Average[PeriodEL](close)<Average[PeriodEL](close)[1])))

    But that should be inside of the loop. Then it may do what you want. 🙂

    1 user thanked author for this post.
    #183933

    I think this code may only work in backtest, because in autotrading it will immediately stopped, as the first time PeriodEL retains 0, and NO indicator allows 0 as the number of periods.

    What use is the LOOP? Why should you want to check 51 times the same condition and place 51 orders whent it’s true?

     

    1 user thanked author for this post.
    #183939

    What use is the LOOP? Why should you want to check 51 times the same condition and place 51 orders whent it’s true?

    I am not Khaled, but the condition would change if Khaled only put the condition within the loop (I can’t guarantee that this is his intention, but it looks like it or else you are right ;-)).
    Next, he doesn’t place 51 orders, as his orders are Exits under the condition of OnMarket. Your stipulation, however, would be correct, knowing that the If OnMarket should be the condition to enter the loop to begin with.

    Suggestion :

     

     

    1 user thanked author for this post.
    #183940

    Roberto and Peter, thank you for your input. Much appreciated.

    What I’m trying to do is to EXIT a Long trade when the EndPointMA changes direction on a higher TF. And this condition should apply for any period between 50 and 100. Example if EndPointMA[50] doesn’t give exit signal, but the EndPointMA[89] gives signal, then Exit Long. In the backtest, the best PERIODS are comprised between 50 and 100, specifically 58, 79, 86, 95, 96, 97, 98, 99 and 100.

    I put this in a system and got errors, which I solved (trial and erros) as below.

    Any better method to reach the same result?

    Is the BREAK instruction in the right position?

    is There a way to GRAPH the exact PERIOD at which the Exit took place?

    Thanks a lot and have a nice day!

     

     

    #183944

    Ligne 10 of the code above should read “sell at market” instead of “Long=1”. I copied the code of the indicator instead of the system.

    #183953

    Next, he doesn’t place 51 orders, as his orders are Exits under the condition of OnMarket

    You’re right. Sorry, I misread that line of code.

     

    1 user thanked author for this post.
    #183957

    Is there a way to make it better? Thanks

    #183962

    Is the BREAK instruction in the right position?

    I think it is.

    With this If you are over-doing it. So yes, this is good habit (for performance), but it will influence your averages. Thus :
    1+2+3 / 3 is really not the same as 2+3+3 / 3.
    I hope this example is clear ? … and of not, you’ll get the gist. 🙂

    1 user thanked author for this post.
    #184020

    What I thought was a solution doesn’t work as expected.

    My problem: I’d like to exit a trade as follows. However, the backtest gives optimal PeriodMAL0 : 58, 75, 79 and 93 to 100.

    I’d like to find a way to tell the system to pick one of these values and nothing in between. How can I do that please?

    Also, is there a way to ask the system to continuously find the optimal PeriodMAL0? a sort of Machine Learning. I tried the few codes on the forum (ML of JuanJ), but no good result.

    Thanks a million.

     

    #184030

    Try this one:

    1 user thanked author for this post.
    #184031

    Thank you Roberto!

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

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