Help to program an idea that worked

Forums ProRealTime English forum ProOrder support Help to program an idea that worked

  • This topic has 42 replies, 4 voices, and was last updated 8 years ago by avatarquo.
Viewing 15 posts - 1 through 15 (of 43 total)
  • #12869
    quo

    Hello everyone.

    I have been trading manually since 2011 this method with goods results and i would like to test it in PRT but it takes me long time to get to anywhere.

    I would really appreciate if anyone could help me.

    The idea is:

    1.-Buy when price breaks up an historical maximum

    2.- Once i have bought, i set the stop in the minimum between the historical máximun and when i bought (new maximum)

    If we have a correction (today low is lower than previous low) we have a new historical high, so:

    3.- When the price goes above that point again i move the stop upwards to the lowest of the new two points, ie the lowest of the new two maximums.

    i have attached an example.

    In have built this in PRT, but it doesn´t work 🙁

     

    i know i have used highest of 300 bars instead of the historical high but i think PRT doesn´t allow us to set it.

    (i have been thinking use this code given by Nicolas to find out the maximum price):

     

    any help  would be really appreciated.

    thanks a lot

    #12870
    quo

    ejemplo

    #12896

    Hello quo,

    Firstly, you are not the first one to get stuck with the comparison between current high and the highest one. You need to test the breach of the highest high from at least 1 period in the past, otherwise, you are testing if the current candlestick high is above its own value, it does not make sense:

    Then to set a pending stop order with the calculation you made about your ‘exit’ level, don’t test if the current price is already below it to add it on market. Just add it on market and then price reach this level, the trade will exit.

    I don’t have verify your ‘exit’ variable calculation, maybe there is still a bug with it.

     

    1 user thanked author for this post.
    avatar quo
    #13102
    quo

    Thanks for your help Nicolas, i am better than before but i am still stuck. I can´t codified the logic i have. i give up, too many hours with this 🙁

    Do you know if PRT support can help me?

    thanks

     

    Ignacio

    #13103

    Don’t give up, please don’t give up 😉
    I can help you, maybe you can share me the code you already made?

    #13106

    Hi quo, although I’m not by any means an expert (neither in fact an user except for some screeners) on this PRT platform , as a programming exercice and to leave Nicolas rest a bit,  I’ve just coded a solution based approx. on your description of the strategy.

    Maybe it’s not yet 100% depured and it’s taken me some time too. It’s not as straightforward as your idea so don’t despair if you don’t get it all at first glance.

    Feel free to prove it , tamper with it and comment if you want or need (I’m Spanish… just in case…). For your information, I’ve used a correction in the high not the low of the following bar to define the precedent high as a new historic maximum.

    This is my go, my excuses to the native English speakers for the odd wrong preposition!

     

    2 users thanked author for this post.
    #13168
    quo

    Wow Tikitaka what an effort, thank you very much, amazing.

    I have used this system with monthly graphs. No filter in the entry but a 3% filter at the exit. After a fundamental and sector filter i apply the rules i said. I exclude those trades with a big stop because as i risk a fix ammount the quantity sometimes is too little in these trades. Results 90% profit, 35% winning trades. Want to check through PRT rest of variables (DD,PF,etc).

    I have been tamperig with it and i would like to say:

    1.-Sometimes there is no entry because you put a start date in 2011 and preloads bar of 10.000. I would like the system detect a maximum from the beginning, in fact in the IPO this system works well.

    2.- There isn´t SL or TP

    3.- I don´t use a filter when i enter a position and 3% in the exit, so  i put it directly in the formula. The same with size position, always 2000 cash. No MM to simplify.

    4.- i don´t consider mintradebars necessary.

    For these 4 points i erased your first part (hope i am not spoiling it)

    It looks like gives good entries but it doesn´t go out where it should do. I don´t know why. Maybe was my fault and i didn´t explained it well. I attach the result code and another explanation of the exit process.

    Thanks for your patience. I didn´t know was so complicated. If we hit the exit we´ll have it, and i will have to invite something to all of you. 😉

     

    #13214

    Hi Quo.

    Did you consider using the MFE trailingstop code?

    just add it to the end of yours.

    Cheers Kasper

     

    1 user thanked author for this post.
    avatar quo
    #13231

    Hi quo, I’m back on it. It might take a while.

    No RSVP. Just to keep you informed.

    #13325

    Hello quo, here I come again.

    It’s taken me hours, but finally I’ve got ready the new slimmer version of your strategy, editing out what you don’t need or want and making the needed changes to meet your requirements. Well, at least me thinks. More than 15 years without writing a code line has taken its toll, evidently. That and probably the fact that I am not a boy anymore.

    What has mainly kept me “entertained” for ages, and counting, it’s the trade showed in the attached picture. The position should be closed not at the bar selected by the system but at the previous one. Despite all my efforts, I’ve been unable to pin down where the problem is. It’s a minor issue that doesn’t happen, at least for that stock, in weekly test nor in diary with the exit filter set to 3%, but there it is to haunt me :-). If you or any other guy want to jump in and search for the answer, please be my guest.

    Anyway, never mind the time long or short. This is the code and, apart from that rare case, should do the trick.

    Or will it?

     

    #13405

    Hi,

    Now I’m getting the hack of it.

    Here is the version 2.02 of the strategy: it’s more compact without repeated code and free of the issue mentioned in my previous post!

    Should be the final one in no money management mode, if I’ve understood well your concept of correction.  Indeed the solution was rather simple, but all is well that ends well.

    Cheers

     

    4 users thanked author for this post.
    #13929
    quo

    Hi Kasper, thanks for the suggestion. I use trailing stops in other systems but i only trade stocks and long orders so i use percentages. What add this stop to a simply set trailing%stop 10 por example? Will this new modified code works in long stocks? thanks

     

    #13938
    quo

    Hi Tikitaka, sorry for my late answer, too much work.

    Thanks for your work. I´ve been checking it and it seen it doesn´t work well. Entry is almost always right but the main problem is the exit.

    In graph one (ACX) entry is right but it never exit, i have written what the stop should do.

    In graph 2 ACR entries are wrong (no historical max) and exit take place later.

    I have tried to find out where is the error but is a lost cause.

    thank you anyway, your welcome to come to Almeria and eat some prawns for the effort 🙂

    Cheers

    Nacho

    #14287

    Hi, back in town.

    Bloody hell, you keep trying the system on monthly bars and I keep debugging it only in daily timeframes, where it seemed to be working well. But you’re so right, it doesn’t.

    My time is limited now as I’have just begun painstakingly (a matter of try and error) to make changes to my own manual strategies after two losing months in a row but I’ll try and find where the problem is as soon as possible.

    Cheers and saludos

    #14825

    High quo and all,

    long time no see but as we say in Spanish, “first obligation than devotion” or in better English, business comes before pleasure.

    So, I’ve made some little changes in the code to cope with the fact that, to my big surprise, functions (or constants as PRT calls them), such as barIndex, high and low, seem to behave differently for US stocks and for non-US stocks. Don’t ask me why, your guess is as good as mine. Maybe a bug in ProBacktest? I really don’t know.

    Anyway, I’ve tested the new code on some Spanish (and US) stocks in monthly timeframe, your market and timeframe of election I presume, and  it seems to do OK. Let me a couple of days to test it on daily bars too, for my peace of mind.

    Meanwhile, just for wrapping up all, I’ve still got a doubt about your concept of correction: in the attached picture for instance, when does the correction happen, at the 08-apr-2004 bar or at the 12-apr-2004 one? I’ve been coding the first (low < low[1]) but the second seems more ‘canonical’ (you know, lower highs and lower lows). Please, do clarify.

    Enough for now. Cheers

    3 users thanked author for this post.
Viewing 15 posts - 1 through 15 (of 43 total)

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