OnChart Stochastic as exit factor LONG

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #88450 quote
    soulintact
    Participant
    Senior
    //PRC_OnChart Stochastic | indicator
    //23.05.2018
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    // --- settings
    KPeriod = 26
    Slowing = 5
    DPeriod = 5
    ATRperiod = 20
    maPeriod = 20
    maMethod = 0
    //overBought = 80
    overSold = 20
    // --- end of settings
    
    maPrice = customclose
    
    dTR = 0
    for i = 0 to ATRperiod-1
    dTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))
    next
    
    avgRange = dTR/ATRperiod
    //avgRange = AverageTrueRange[ATRperiod]
    maValue = average[maPeriod,maMethod](maPrice)
    stochValue = Stochastic[Kperiod,Slowing](maPrice)
    signalValue = average[Dperiod,maMethod](stochValue)
    //----
    //Buffer1=maValue
    //Buffer2=maValue+(avgRange*(overBought-50)/100)
    Buffer3=maValue-(avgRange*(50-  overSold)/100)
    Buffer4=maValue+(stochValue -50)/100*avgRange
    Buffer5=maValue+(signalValue-50)/100*avgRange
    
    BearSTOCH=Buffer5>Buffer4 and Buffer5>Buffer3

    I am trying to use the indicator above as an exit factor for LONG position (BearSTOCH), and for some reason it does not work.

    I normally combine different indicators for entry/exit purpose in automatic trading, but as soon I include this one, no trades in simulation mode occur, not even a purchase, that should not be affected as I am only adding a condition in the exit conditions… Anyone with opened eyes today? THANKS!

    #88454 quote
    Vonasi
    Moderator
    Master

    Are you sure that it doesn’t open one position and never close it? This would show zero in the strategy report.

    soulintact thanked this post
    #88461 quote
    GraHal
    Participant
    Master

    Have you got If LongonMarket or If ShortonMarket as part of your Exit Strategy?

    We can – on occasions-  get well weird things happening if we don’t use above.

    soulintact thanked this post
    #88474 quote
    soulintact
    Participant
    Senior

    Thank you Vonasi and GraHal being active on a Sunday!

    Part of the Exit Strategy is: or longonmarket and BearSTOCH

    For the same interval, it normally simulates aprox 30 trades, and zero when I add the extra exit condition as described. If I replace BearSTOCH with any other indicator strategy, it works.  Kind of weird…

    #88475 quote
    Vonasi
    Moderator
    Master

    Have you tried adding:

    	
    DEFPARAM PRELOADBARS = 20
    soulintact thanked this post
    #88476 quote
    GraHal
    Participant
    Master

    Without the full code we are guessing, but how are you judging that there are zero trades?

    Have you looked in the Detailed Report as you may have loads of 0 bar trades which are closing / exiting just as soon as they have opened??

    I’ve had  the above scenario before now and on the equity curve it looks like nothing is happening and zero / no  trades show on the Positions Indicator.

    Just a few more thoughts / ideas to look at.

    soulintact thanked this post
    #88479 quote
    soulintact
    Participant
    Senior

    Thank you both of you!

    Yes I tried adding DEFPARAM PRELOADBARS = 20, but no change

    Judging by probacktesting my system without changing anything except adding the exit condition.

    #88483 quote
    Vonasi
    Moderator
    Master

    I think I’m with GraHal about needing the code as there is no logical reason why just adding the indicator code and an extra exit condition should stop a strategy from opening a position.

    Have you tried CALLing the indicator rather than including the code in your strategy?

    #88484 quote
    GraHal
    Participant
    Master

    Judging by probacktesting my system without changing anything except adding the exit condition.

    So you have nothing at all showing in the Detailed Report as attached ?

    Soul.jpg Soul.jpg
    #88527 quote
    soulintact
    Participant
    Senior

    Correct, like it was blocked. Never mind, I just look for a similar indicator 🙂 Thanks for all your time!

    #88539 quote
    soulintact
    Participant
    Senior
    B3=Call "PRC_OnChart Stochastic"[Buffer3]
    B4=Call "PRC_OnChart Stochastic"[Buffer4]
    B5=Call "PRC_OnChart Stochastic"[Buffer5]
    
    //BullONCHARTSTO=
    BearONCHARTSTO=B5>B3 and (B5>B4)

    Thanks. Must admit that I have not used the call function, and it seems that I am doing something wrong as I get a syntax error…

    syntax-error.png syntax-error.png
    #88584 quote
    Vonasi
    Moderator
    Master

    How to use CALL is shown clearly here:

    CALL

    Call the indicator in just one line to get the multiple values that it returns in the RETURN line.

    myValue1, myValue2, myValue3 = CALL "myIndicator"[parameter1,parameter2]
    soulintact thanked this post
    #88587 quote
    soulintact
    Participant
    Senior

    Thanks, I saw that, and I could still ignore the clearness 🙂

    I did try the below, but missed out something as I got the same syntax error …

    B3, B4, B5=Call "PRC_OnChart Stochastic"[Buffer3,Buffer4,Buffer5]
    #88589 quote
    robertogozzi
    Moderator
    Master

    The indicator, as it is in the library should be CALLed with these parameters (those to the left of “=” can be used or ignored as suits you best). As for the 8 parameters within brackets they can be hard coded inside the indicator itself and, in such case, brackets can be omitted at all. In all cases, whatever variable you are using, no matter where you write it, MUST  have been previously defined:

    ignored, ignored, ignored, ignored, indicator2 = CALL "PRC_OnChart Stochastic"[6, 10, 3, 20, 20, 0, 80, 20](close)

    reading documentation as outlined by Vonasi or browsing the thousands of lines of code in the forum (or watching some training video, here or on Youtube) will help you get the hang of it.

    soulintact and Vonasi thanked this post
    #88602 quote
    soulintact
    Participant
    Senior

    Thank you very much Roberto!

Viewing 15 posts - 1 through 15 (of 18 total)
  • You must be logged in to reply to this topic.

OnChart Stochastic as exit factor LONG


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
soulintact @soulintact Participant
Summary

This topic contains 17 replies,
has 4 voices, and was last updated by soulintact
7 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/13/2019
Status: Active
Attachments: 3 files
Logo Logo
Loading...