backtest stocks ath

Forums ProRealTime English forum ProOrder support backtest stocks ath

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

    I want to write a code  for backtesting that buys the highest of the previous bar over a given period (1 week, 1 month, 1 year or more). with a target of 10%. for the stock of my choice. for example, it’s march 2024. i buy the highest reached in april 2024. thanks you

    #230651

    Hi
    here you have an example (please,consider to use a stop loss or another way to exit than just the profit 10%)

    #230663

    Thank you very much for your help IVAN, but I think I misspoke. Attached is a graphic that better explains what I want.

    #230696

    Can you help me please. thanks

    #230701

    Ok. Should by like this.

    #230850

    Thank you very much IVAN, but that’s not exactly it. Here are normally the orders that must be taken. I will take example since 2017 ON APPLE. IVAN if you can start from this example to make the code.
    ATH IN 2017: 44. 30
    I TAKE A POSITION IN 2018 IF I REACH 44.3
    THEN 10% TARGET OR 10% STOP LOSS

    SAME IN 2018: 58.36
    I POSITION MYSELF FOR 2019 AT THIS PRICE AT 58.36

    IN 2019 : HIGH REACHED 73.49
    I’M POSITIONED AT THIS PRICE IN 2020

    2020 : HIGH REACHES 138.78
    ENTER THE 2021 MARKET AT THIS PRICE

    AND FOR ALL 10% TARGET AND 10% STOP LOSS FROM THIS PRICE.

    THANK YOU MR

    #230855

    I hope I’ve expressed myself well.

    #230947

    Ivan m’y Freind ?

    #230953

    First point: about working for any timeframe, just in case, if you’re after an all time high, keep in mind you need to make sure your timeframe is big enough to show all history (yearly or monthly is surely big enough, at the extreme opposite 1mn or (x) seconds might not be for older stocks)

     

    2nd point: keeping in mind first point’s limitation for smaller timeframe, if you have maximum history wanted in your backtest, and considering first bar is barindex=0 then you can try to define your ath with:

    and check it has been reached in the signal candle with:

     

    3rd point is a moderation point: you asked your question in this topic first, the rule about double post applies so your same question posted later on french forum is considered double post and will be deleted (please have a look at yellow box at bottom of this page the “do not double post” rule). To answer your other question there, anyone can reply if they want and when they want, there isn’t on one hand those who only ask and on the other hand those who only answer, it would only lead to those who ask remaining alone in the end, please feel free to help others too when you see questions you know the answer to. Moderators just have extra tools in their hands to keep the forum tidy within their own availability. If the points above didn’t help enough or didn’t help at all, please feel free to carry on the conversation with anyone, moderator or not, but in this topic, not in a duplicate topic, thanks.

     

    #230962

    Hi
    Here you have an example (to be runned in monthly, weekly, daily, …, but not annualy)

    #230964

    JC, I just saw your comment right after I responded… Thanks

    #230970

    thank you IVAN but i’m probably explaining myself badly but that’s not it.  Like janury 2020 time 6 months. Ath 93.095.  code entry in july 91.28. or it must be  93.095 .

     

    And if you take a period spanning 1 year, nothing appears.

    #230977

    Yes, in annualy nothing happens because there is not cross over. As I wrote, this system is to be runned in monthly, weekly, daily, timeframe, but not annualy.
    I have coded a cross over the last year high.
    Sorry but I don’t know what you want… maybe another one can help you.

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