OnChart Stochastic as exit factor LONG
Forums › ProRealTime English forum › ProOrder support › OnChart Stochastic as exit factor LONG
- This topic has 17 replies, 4 voices, and was last updated 5 years ago by soulintact.
-
-
01/13/2019 at 11:52 AM #88450Exit factor LONG (BearSTOCH) based on OnChart Stochastic123456789101112131415161718192021222324252627282930313233343536//PRC_OnChart Stochastic | indicator//23.05.2018//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge// --- settingsKPeriod = 26Slowing = 5DPeriod = 5ATRperiod = 20maPeriod = 20maMethod = 0//overBought = 80overSold = 20// --- end of settingsmaPrice = customclosedTR = 0for i = 0 to ATRperiod-1dTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))nextavgRange = 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*avgRangeBuffer5=maValue+(signalValue-50)/100*avgRangeBearSTOCH=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!
01/13/2019 at 1:35 PM #88454Are you sure that it doesn’t open one position and never close it? This would show zero in the strategy report.
1 user thanked author for this post.
01/13/2019 at 2:09 PM #88461Have 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.
1 user thanked author for this post.
01/13/2019 at 5:14 PM #88474Thank 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…
01/13/2019 at 5:38 PM #8847501/13/2019 at 5:42 PM #88476Without 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.
1 user thanked author for this post.
01/13/2019 at 5:59 PM #88479Thank 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.
01/13/2019 at 6:53 PM #88483I 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?
01/13/2019 at 7:22 PM #88484Judging 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 ?
01/14/2019 at 10:36 AM #88527Correct, like it was blocked. Never mind, I just look for a similar indicator 🙂 Thanks for all your time!
01/14/2019 at 11:36 AM #88539Calling OnChart Stochastic123456B3=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…
01/14/2019 at 5:03 PM #88584How to use CALL is shown clearly here:
https://www.prorealcode.com/documentation/call/
Call the indicator in just one line to get the multiple values that it returns in the RETURN line.
1myValue1, myValue2, myValue3 = CALL "myIndicator"[parameter1,parameter2]1 user thanked author for this post.
01/14/2019 at 5:32 PM #88587Thanks, 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 …
1B3, B4, B5=Call "PRC_OnChart Stochastic"[Buffer3,Buffer4,Buffer5]01/14/2019 at 5:49 PM #88589The 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:
1ignored, 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.
2 users thanked author for this post.
01/14/2019 at 7:10 PM #88602Thank you very much Roberto!
-
AuthorPosts
Find exclusive trading pro-tools on