Problem with array code trying to find best MA period.

Forums ProRealTime English forum ProBuilder support Problem with array code trying to find best MA period.

Viewing 3 posts - 1 through 3 (of 3 total)
  • #131044

    Hi Guys,

    I try to determine what is the best period for average crossing =Bigger pike after a crossing, but I don’t know why there is a problem with my array code

    In fact it don’t determine the best period but only the best period for 10 (in this code)

    Does someone have an idea of my mistake ?

    Thanks guys

     

    #131057

    I’ve edited your topic title – please try to use titles that are not something like ‘Coding help needed’ otherwise we get a forum full of them.

    The problem is that you are checking for the price difference and the cross in the same loop for all averages.

    I would code it like this with a separate array location for each MA. It will still eventually end up going for the highest number because that is the slowest moving average and so takes longer to catch up with price so the gap is bigger. Perhaps you should reset the ‘biggest’ variable at each bar and then check back over the last x bars in a loop to find the best MA.

     

     

    #131090

    Thanks @vonasi 😉

    I solve the problem in a different way (code to find the “best” period)

    Thanks and have a nice day

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

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