Machine Learning in ProOrder ProRealTime
Forums › ProRealTime English forum › ProOrder support › Machine Learning in ProOrder ProRealTime
- This topic has 454 replies, 32 voices, and was last updated 2 years ago by Khaled.
Tagged: machine learning
-
-
04/26/2020 at 1:10 AM #128113
When I, (if I), get the Robustness Tester to be able to switch on an off
Just a suggestion … I’ve never bothered with the on/off. I do the optimisation, add the vrt code, do the test, then strip it out again and forget about it – no longer needed. Personally, I don’t like having stuff cluttering up the code for no purpose, just in case it throws up some unintended side effect.
04/26/2020 at 7:01 AM #128123For example having used the larger Trailing Stop at 200 to max 300 and had no trouble backtesting Dow Daily 2015 to present, when I went back the smaller previous ranges (10 to 150 for both the Stop and the BoxSize) I immediately got a tbt warning.
It’s due to below …
So if – due to settings / values for TP and SL – there are more than 2,500 instances of TP and SL being hit in the same bar then we get the warning message that tbt has reached it’s limit.
04/26/2020 at 10:50 AM #128172Hi Paul, cheers, not sure why I added them, probably something wasn’t working, it was during a process of trying different things, like your new rules, without While and Wend. They were originally derived from the DocTrading rules from his Pure Renko strategy. Not being a coder I wasn’t sure that the Buy / Sell Stop would be activated unless the condition had been stated first.
Good tip for the tbt issues, thanks.
Yes that might be a good idea because Renko ML2 didn’t perform as well as I expected, not like Ehlers Universal Oscillator ML2 that I’ve posted on this thread and which had ValueX for the Longs and ValueY for the Shorts, nor the Renko ML1 ValueX Trailing Stop. So many combinations and new discoveries to be uncovered… 😀
04/26/2020 at 11:10 AM #128177@Bard Hi, Nice job btw on the ML engine! I’ve started work on it with trying various combinations.
Setup is a.t.m. focused on opening a trade in the lower spread timezone.
I included the reentry when in loss on a new same signal to create more trades.
Going nowhere a.t.m. regardless timeframe but anyway have a look 🙂
edit parameter MaxIncrement2 is wrongly setup.
edit2; removing the once or the complete line
12345renkoMaxL = ROUND(close / boxSizeL) * boxSizeLrenkoMinL = renkoMaxL - boxSizeLrenkoMaxS = ROUND(close / boxSizeS) * boxSizeSrenkoMinS = renkoMaxS - boxSizeSand still does calculations?
04/26/2020 at 11:36 AM #128180Thanks Nonetheless,
I don’t like having stuff cluttering up the code for no purpose, just in case it throws up some unintended side effect.
Like 5 x the profits, which is what happened when I thought it was turned off but wasn’t. Would be nice to get Vonasi’s additional on/off switch code working or otherwise I’ll probably end up settling for VRT and non VRT versions to save time from having to delete VRT and re-add his code to just one system.
04/26/2020 at 11:42 AM #128182due to settings / values for TP and SL – there are more than 2,500 instances of TP and SL being hit in the same bar then we get the warning message that tbt has reached it’s limit.
Do you think that it’s possible that there are 2,500 instances of the (ML1, ValueX) Stop Loss being triggered in the same daily candle? Btw TP in all “my” systems TP have always been set at 500, just thought.. that in itself could do with an ML code… Where does it end? 😬 Lol.
04/26/2020 at 12:15 PM #128189Do you think that it’s possible that there are 2,500 instances of the (ML1, ValueX) Stop Loss being triggered in the same daily candle?
Only if ML1 and ValueX are variables for TP and SL as that is all the tbt is concerned with.
PS
Btw if you select text and then click the ‘Quote’ button then the person who you are Quotng will show up in blue (as above) as a link … then if anybody wants to go back to the post all they have to do is click on the blue link.
Luckily (in your post above) I remembered my own comments else I would not know who you are talking to! 🙂 🙂
04/26/2020 at 12:25 PM #128191Would be nice to get Vonasi’s additional on/off switch code working
Are you following @Vonasi 2 x instructions below??
Maybe you are getting problems because you are following just one of the 2 x instructions??
Just an idea anyway, as you seem to have tried everything.Also your strategy code may be using a variable in Vonasi VRT code and that is why you get 5 x profits with the VRT code but not without??
You need to click on the blue Vonasi below and read his original post as the code (which I tried to copy for you) has come out garbled and I have to go now, sorry.
Alternatively add something like this to your code and then you can simply turn the robustness tester on and off via one variable at the top of the code without the need to search through the code to find the right line to add or remove // from. 1 2 3 4 5 6 7 8 9 RobustnessTest = 0 (robustness test code here) if not RobustnessTest then tradeon = 1 endif (strategy code here)
04/26/2020 at 1:10 PM #128193Should your heuristic code work on strategies that switch position from Long to Short with no bars not onmarket ?
Yip that is the problem. Solution;
Replace this:
123If onmarket[1] = 1 and onmarket = 0 Thenoptimize = optimize + 1EndIfWith This:
123If (onmarket[1] = 1 and onmarket = 0) or (longonmarket[1] = 1 and longonmarket and countoflongshares < countoflongshares[1]) or (longonmarket[1] = 1 and longonmarket and countoflongshares > countoflongshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares < countofshortshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares > countofshortshares[1]) or (longonmarket[1] and shortonmarket) or (shortonmarket[1] and longonmarket) Thenoptimize = optimize + 1EndIf04/26/2020 at 1:14 PM #12819404/26/2020 at 1:26 PM #128195this seems a fix
123456789101112131415161718192021HeuristicsCycleLimit = 2once HeuristicsCycle = 0once HeuristicsAlgo1 = 1once HeuristicsAlgo2 = 0If HeuristicsCycle >= HeuristicsCycleLimit ThenIf HeuristicsAlgo1 = 1 ThenHeuristicsAlgo2 = 1HeuristicsAlgo1 = 0ElsIf HeuristicsAlgo2 = 1 ThenHeuristicsAlgo1 = 1HeuristicsAlgo2 = 0EndIfHeuristicsCycle = 0elseStartingValue = 40StartingValue2= 30once ValueX = StartingValueonce ValueY = StartingValue2EndIfand change below
123456789//StartingValue = 40 //100, 10 BoxsizeIncrement = 5 //20, 10MaxIncrement = 15 //10 Limit of no of increments either up or downReps = 3 //Number of trades to use for analysis //2MaxValue = 40 //300, 150 //Maximum allowed valueMinValue = 15 //Minimum allowed value//once valueX = StartingValuesame valuey
04/26/2020 at 1:33 PM #128196<p class=”p1″><span class=”s1″>Cheers, I couldn’t have done it without GraHal’s tip to use a text comparison website (to compare Juanj’s code with my often non working “exact copy” code that turned out more often than not, not to be so exact or a copy). </span></p>
Short and Long Boxsizes: That would certainly make logical sense, have larger range boxes for strong uptrends to capture larger chunks of profit and then a smaller shorter range box for the minor corrections. Be interesting to test.I figured out why 1M ML2 CycLimRes v2 didn’t trade, and excuse the brutal editing of your sophisticated code, but I just had to go back step by set to first principles to see what was stopping it from trading. First cut was the stop loss – made no difference, as still no trades. Then I took out the “flat before,” still no difference, but when I took out “ctime” it took trades but not profitably and also GraphY was flat whereas Value X was being optimised. More alterations to the settings fixed it and although it’s still taking plenty of trades despite going back to some similar settings, it’s not that profitable. Putting back the stop loss code cut the nos of trades from 233 to just 14. As I said it’d be really interesting to test it more to see if the Long/Short boxsize logic works. Altering setting definitely caused some tbt warnings. Some instruments even this attached version would not trade on like Wheat or Gold.
1 user thanked author for this post.
04/26/2020 at 1:49 PM #128201you have the same problem with valuey Bard,
you could try this layout with both fixes
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216//Settings 1 & 2StartingValue = 40 //100, 10 BoxsizeIncrement = 5 //20, 10MaxIncrement = 15 //10 Limit of no of increments either up or downReps = 3 //Number of trades to use for analysis //2MaxValue = 40 //300, 150 //Maximum allowed valueMinValue = 15 //Minimum allowed valueStartingValue2= 30 //100, 50 Stop LossIncrement2 = 5 //5, 10MaxIncrement2 = 15 //30 Limit of no of increments either up/down //4Reps2 = 3 //2 Nos of trades to use for analysis //3MaxValue2 = 30 //300, 200 Maximum allowed valueMinValue2 = 15 //Minimum allowed valueHeuristicsCycleLimit = 2once HeuristicsCycle = 0once HeuristicsAlgo1 = 1once HeuristicsAlgo2 = 0If HeuristicsCycle >= HeuristicsCycleLimit ThenIf HeuristicsAlgo1 = 1 ThenHeuristicsAlgo2 = 1HeuristicsAlgo1 = 0ElsIf HeuristicsAlgo2 = 1 ThenHeuristicsAlgo1 = 1HeuristicsAlgo2 = 0EndIfHeuristicsCycle = 0elseonce ValueX = StartingValueonce ValueY = StartingValue2EndIfIf HeuristicsAlgo1 = 1 Then//Heuristics Algorithm 1 StartIf (onmarket[1] = 1 and onmarket = 0) or (longonmarket[1] = 1 and longonmarket and countoflongshares < countoflongshares[1]) or (longonmarket[1] = 1 and longonmarket and countoflongshares > countoflongshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares < countofshortshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares > countofshortshares[1]) or (longonmarket[1] and shortonmarket) or (shortonmarket[1] and longonmarket) Thenoptimise = optimise + 1EndIf//once valueX = StartingValueonce PIncPos = 1 //Positive Increment Positiononce NIncPos = 1 //Negative Increment Positiononce optimise = 0 //Initialize Heuristicks Engine Counter (Must be Incremented at Position Start or Exit)once Mode1 = 1 //Switches between negative and positive increments//once WinCountB = 3 //Initialize Best Win Count//GRAPH WinCountB coloured (0,0,0) AS "WinCountB"//once StratAvgB = 4353 //Initialize Best Avg Strategy Profit//GRAPH StratAvgB coloured (0,0,0) AS "StratAvgB"If optimise = Reps ThenWinCountA = 0 //Initialize current Win CountStratAvgA = 0 //Initialize current Avg Strategy ProfitHeuristicsCycle = HeuristicsCycle + 1For i = 1 to Reps DoIf positionperf(i) > 0 ThenWinCountA = WinCountA + 1 //Increment Current WinCountEndIfStratAvgA = StratAvgA + (((PositionPerf(i)*countofposition[i]*Close)*-1)*-1)NextStratAvgA = StratAvgA/Reps //Calculate Current Avg Strategy Profit//Graph (PositionPerf(1)*countofposition[1]*100000)*-1 as "PosPerf1"//Graph (PositionPerf(2)*countofposition[2]*100000)*-1 as "PosPerf2"//Graph StratAvgA*-1 as "StratAvgA"//once BestA = 300//GRAPH BestA coloured (0,0,0) AS "BestA"If StratAvgA >= StratAvgB ThenStratAvgB = StratAvgA //Update Best Strategy ProfitBestA = ValueXEndIf//once BestB = 300//GRAPH BestB coloured (0,0,0) AS "BestB"If WinCountA >= WinCountB ThenWinCountB = WinCountA //Update Best Win CountBestB = ValueXEndIfIf WinCountA > WinCountB and StratAvgA > StratAvgB ThenMode1 = 0ElsIf WinCountA < WinCountB and StratAvgA < StratAvgB and Mode1 = 1 ThenValueX = ValueX - (Increment*NIncPos)NIncPos = NIncPos + 1Mode1 = 2ElsIf WinCountA >= WinCountB or StratAvgA >= StratAvgB and Mode1 = 1 ThenValueX = ValueX + (Increment*PIncPos)PIncPos = PIncPos + 1Mode1 = 1ElsIf WinCountA < WinCountB and StratAvgA < StratAvgB and Mode1 = 2 ThenValueX = ValueX + (Increment*PIncPos)PIncPos = PIncPos + 1Mode1 = 1ElsIf WinCountA >= WinCountB or StratAvgA >= StratAvgB and Mode1 = 2 ThenValueX = ValueX - (Increment*NIncPos)NIncPos = NIncPos + 1Mode1 = 2EndIfIf NIncPos > MaxIncrement or PIncPos > MaxIncrement ThenIf BestA = BestB ThenValueX = BestAElseIf reps >= 10 ThenWeightedScore = 10ElseWeightedScore = round((reps/100)*100)EndIfValueX = round(((BestA*(20-WeightedScore)) + (BestB*WeightedScore))/20) //Lower Reps = Less weight assigned to Win%EndIfNIncPos = 1PIncPos = 1ElsIf ValueX > MaxValue ThenValueX = MaxValueElsIf ValueX < MinValue ThenValueX = MinValueEndIFoptimise = 0EndIf// Heuristics Algorithm 1 EndElsIf HeuristicsAlgo2 = 1 Then// Heuristics Algorithm 2 StartIf (onmarket[1] = 1 and onmarket = 0) or (longonmarket[1] = 1 and longonmarket and countoflongshares < countoflongshares[1]) or (longonmarket[1] = 1 and longonmarket and countoflongshares > countoflongshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares < countofshortshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares > countofshortshares[1]) or (longonmarket[1] and shortonmarket) or (shortonmarket[1] and longonmarket) Thenoptimise2 = optimise2 + 1EndIf//once ValueY = StartingValue2once PIncPos2 = 1 //Positive Increment Positiononce NIncPos2 = 1 //Negative Increment Positiononce optimise2 = 0 //Initialize Heuristicks Engine Counter (Must be Incremented at Position Start or Exit)once Mode2 = 1 //Switches between negative and positive increments//once WinCountB2 = 3 //Initialize Best Win Count//GRAPH WinCountB2 coloured (0,0,0) AS "WinCountB2"//once StratAvgB2 = 4353 //Initialize Best Avg Strategy Profit//GRAPH StratAvgB2 coloured (0,0,0) AS "StratAvgB2"If optimise2 = Reps2 ThenWinCountA2 = 0 //Initialize current Win CountStratAvgA2 = 0 //Initialize current Avg Strategy ProfitHeuristicsCycle = HeuristicsCycle + 1For i2 = 1 to Reps2 DoIf positionperf(i2) > 0 ThenWinCountA2 = WinCountA2 + 1 //Increment Current WinCountEndIfStratAvgA2 = StratAvgA2 + (((PositionPerf(i2)*countofposition[i2]*Close)*-1)*-1)NextStratAvgA2 = StratAvgA2/Reps2 //Calculate Current Avg Strategy Profit//Graph (PositionPerf(1)*countofposition[1]*100000)*-1 as "PosPerf1-2"//Graph (PositionPerf(2)*countofposition[2]*100000)*-1 as "PosPerf2-2"//Graph StratAvgA2*-1 as "StratAvgA2"//once BestA2 = 300//GRAPH BestA2 coloured (0,0,0) AS "BestA2"If StratAvgA2 >= StratAvgB2 ThenStratAvgB2 = StratAvgA2 //Update Best Strategy ProfitBestA2 = ValueYEndIf//once BestB2 = 300//GRAPH BestB2 coloured (0,0,0) AS "BestB2"If WinCountA2 >= WinCountB2 ThenWinCountB2 = WinCountA2 //Update Best Win CountBestB2 = ValueYEndIfIf WinCountA2 > WinCountB2 and StratAvgA2 > StratAvgB2 ThenMode2 = 0ElsIf WinCountA2 < WinCountB2 and StratAvgA2 < StratAvgB2 and Mode2 = 1 ThenValueY = ValueY - (Increment2*NIncPos2)NIncPos2 = NIncPos2 + 1Mode2 = 2ElsIf WinCountA2 >= WinCountB2 or StratAvgA2 >= StratAvgB2 and Mode2 = 1 ThenValueY = ValueY + (Increment2*PIncPos2)PIncPos2 = PIncPos2 + 1Mode2 = 1ElsIf WinCountA2 < WinCountB2 and StratAvgA2 < StratAvgB2 and Mode2 = 2 ThenValueY = ValueY + (Increment2*PIncPos2)PIncPos2 = PIncPos2 + 1Mode2 = 1ElsIf WinCountA2 >= WinCountB2 or StratAvgA2 >= StratAvgB2 and Mode2 = 2 ThenValueY = ValueY - (Increment2*NIncPos2)NIncPos2 = NIncPos2 + 1Mode2 = 2EndIfIf NIncPos2 > MaxIncrement2 or PIncPos2 > MaxIncrement2 ThenIf BestA2 = BestB2 ThenValueY = BestA2ElseIf reps2 >= 10 ThenWeightedScore2 = 10ElseWeightedScore2 = round((reps2/100)*100)EndIfValueY = round(((BestA2*(20-WeightedScore2)) + (BestB2*WeightedScore2))/20) //Lower Reps = Less weight assigned to Win%EndIfNIncPos2 = 1PIncPos2 = 1ElsIf ValueY > MaxValue2 ThenValueY = MaxValue2ElsIf ValueY < MinValue2 ThenValueY = MinValue2EndIFoptimise2 = 0EndIf// Heuristics Algorithm 2 EndEndif04/26/2020 at 1:49 PM #128202Would be nice to get Vonasi’s additional on/off switch code working
Did you read below (click on blue link below) … Vonasi got logical results with and without his VRT code?
returned one result that was identical to with the VRT code in the strategy but turned off.
04/26/2020 at 2:02 PM #128205I’m not sure ValueY is “broken” when it flatlines, I think it’s more to do with the settings that the code. Let me take a look at the code above.
Meanwhile can you please check the logic of your Long/Short BoxSize idea with my very simple entry conditions in Renko ML2 v3 below because the results are good not just on the Dow and £/$ but also on other instruments. I like to think a system is robust if it’s simple and can be applied to other markets particularly when you don’t have to alter settings to adjust for volatility. Great job.
Paul/Bard Renko ML2 Long/Short BoxSize with simplifies Entries and Exits123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285//-------------------------------------------------------------------------// Main code : Nneless Renko DJI 1Month v3 Machine Learning (ML2)//https://www.prorealcode.com/topic/machine-learning-in-proorder/page/3/#post-121130//-------------------------------------------------------------------------//https://www.prorealcode.com/topic/why-is-backtesting-so-unreliable/#post-110889// Definition of code parameters//DEFPARAM CumulateOrders = False // Cumulating positions deactivated//defparam preloadbars = 1000//defparam flatbefore = 080000//defparam flatafter = 215500////once tradetype = 1 // [1]long&short;[2]long;[3]short////once reenter = 1//once positionperftype = 1 // [0] reenter always; [1] reenter positionperf < 0//ctime=time>=080000 and time<180000n=1HeuristicsCycleLimit = 2once HeuristicsCycle = 0once HeuristicsAlgo1 = 1once HeuristicsAlgo2 = 0If HeuristicsCycle >= HeuristicsCycleLimit ThenIf HeuristicsAlgo1 = 1 ThenHeuristicsAlgo2 = 1HeuristicsAlgo1 = 0ElsIf HeuristicsAlgo2 = 1 ThenHeuristicsAlgo1 = 1HeuristicsAlgo2 = 0EndIfHeuristicsCycle = 0EndIfIf HeuristicsAlgo1 = 1 then//Heuristics Algorithm 1 StartIf onmarket[1] = 1 and onmarket = 0 Thenoptimise = optimise + 1Endif//Settings 1 & 2StartingValue = 40 //5, 100, 10 BoxsizeIncrement = 10 //5, 20, 10MaxIncrement = 10 //5, 10 Limit of no of increments either up or downReps = 2 //1 Number of trades to use for analysis //2MaxValue = 200 //20, 300, 150 //Maximum allowed valueMinValue = 5 //5, Minimum allowed valueStartingValue2= 40 //5, 100, 50 Stop LossIncrement2 = 10 //5, 10MaxIncrement2 = 10 //1, 30 Limit of no of increments either up/down //4Reps2 = 2 //1, 2 Nos of trades to use for analysis //3MaxValue2 = 200 //20, 300, 200 Maximum allowed valueMinValue2 = 5 //5, Minimum allowed valueonce ValueX = StartingValueonce PIncPos = 1 //Positive Increment Positiononce NIncPos = 1 //Negative Increment Positiononce optimise = 0 //Initialize Heuristicks Engine Counter (Must be Incremented at Position Start or Exit)once Mode1 = 1 //Switches between negative and positive increments//once WinCountB = 3 //Initialize Best Win Count//GRAPH WinCountB coloured (0,0,0) AS "WinCountB"//once StratAvgB = 4353 //Initialize Best Avg Strategy Profit//GRAPH StratAvgB coloured (0,0,0) AS "StratAvgB"If optimise = Reps ThenWinCountA = 0 //Initialize current Win CountStratAvgA = 0 //Initialize current Avg Strategy ProfitHeuristicsCycle = HeuristicsCycle + 1For i = 1 to Reps DoIf positionperf(i) > 0 ThenWinCountA = WinCountA + 1 //Increment Current WinCountEndIfStratAvgA = StratAvgA + (((PositionPerf(i)*countofposition[i]*Close)*-1)*-1)NextStratAvgA = StratAvgA/Reps //Calculate Current Avg Strategy Profit//Graph (PositionPerf(1)*countofposition[1]*100000)*-1 as "PosPerf1"//Graph (PositionPerf(2)*countofposition[2]*100000)*-1 as "PosPerf2"//Graph StratAvgA*-1 as "StratAvgA"//once BestA = 300//GRAPH BestA coloured (0,0,0) AS "BestA"If StratAvgA >= StratAvgB ThenStratAvgB = StratAvgA //Update Best Strategy ProfitBestA = ValueXEndIf//once BestB = 300//GRAPH BestB coloured (0,0,0) AS "BestB"If WinCountA >= WinCountB ThenWinCountB = WinCountA //Update Best Win CountBestB = ValueXEndIfIf WinCountA > WinCountB and StratAvgA > StratAvgB ThenMode1 = 0ElsIf WinCountA < WinCountB and StratAvgA < StratAvgB and Mode1 = 1 ThenValueX = ValueX - (Increment*NIncPos)NIncPos = NIncPos + 1Mode1 = 2ElsIf WinCountA >= WinCountB or StratAvgA >= StratAvgB and Mode1 = 1 ThenValueX = ValueX + (Increment*PIncPos)PIncPos = PIncPos + 1Mode1 = 1ElsIf WinCountA < WinCountB and StratAvgA < StratAvgB and Mode1 = 2 ThenValueX = ValueX + (Increment*PIncPos)PIncPos = PIncPos + 1Mode1 = 1ElsIf WinCountA >= WinCountB or StratAvgA >= StratAvgB and Mode1 = 2 ThenValueX = ValueX - (Increment*NIncPos)NIncPos = NIncPos + 1Mode1 = 2EndIfIf NIncPos > MaxIncrement or PIncPos > MaxIncrement ThenIf BestA = BestB ThenValueX = BestAElseIf reps >= 10 ThenWeightedScore = 10ElseWeightedScore = round((reps/100)*100)EndIfValueX = round(((BestA*(20-WeightedScore)) + (BestB*WeightedScore))/20) //Lower Reps = Less weight assigned to Win%EndIfNIncPos = 1PIncPos = 1ElsIf ValueX > MaxValue ThenValueX = MaxValueElsIf ValueX < MinValue ThenValueX = MinValueEndIFoptimise = 0EndIf// Heuristics Algorithm 1 EndElsIf HeuristicsAlgo2 = 1 Then// Heuristics Algorithm 2 StartIf onmarket[1] = 1 and onmarket = 0 Thenoptimise2 = optimise2 + 1Endif//Settings 2once ValueY = StartingValue2once PIncPos2 = 1 //Positive Increment Positiononce NIncPos2 = 1 //Negative Increment Positiononce optimise2 = 0 //Initialize Heuristicks Engine Counter (Must be Incremented at Position Start or Exit)once Mode2 = 1 //Switches between negative and positive increments//once WinCountB2 = 3 //Initialize Best Win Count//GRAPH WinCountB2 coloured (0,0,0) AS "WinCountB2"//once StratAvgB2 = 4353 //Initialize Best Avg Strategy Profit//GRAPH StratAvgB2 coloured (0,0,0) AS "StratAvgB2"If optimise2 = Reps2 ThenWinCountA2 = 0 //Initialize current Win CountStratAvgA2 = 0 //Initialize current Avg Strategy ProfitHeuristicsCycle = HeuristicsCycle + 1For i2 = 1 to Reps2 DoIf positionperf(i2) > 0 ThenWinCountA2 = WinCountA2 + 1 //Increment Current WinCountEndIfStratAvgA2 = StratAvgA2 + (((PositionPerf(i2)*countofposition[i2]*Close)*-1)*-1)NextStratAvgA2 = StratAvgA2/Reps2 //Calculate Current Avg Strategy Profit//Graph (PositionPerf(1)*countofposition[1]*100000)*-1 as "PosPerf1-2"//Graph (PositionPerf(2)*countofposition[2]*100000)*-1 as "PosPerf2-2"//Graph StratAvgA2*-1 as "StratAvgA2"//once BestA2 = 300//GRAPH BestA2 coloured (0,0,0) AS "BestA2"If StratAvgA2 >= StratAvgB2 ThenStratAvgB2 = StratAvgA2 //Update Best Strategy ProfitBestA2 = ValueYEndIf//once BestB2 = 300//GRAPH BestB2 coloured (0,0,0) AS "BestB2"If WinCountA2 >= WinCountB2 ThenWinCountB2 = WinCountA2 //Update Best Win CountBestB2 = ValueYEndIfIf WinCountA2 > WinCountB2 and StratAvgA2 > StratAvgB2 ThenMode2 = 0ElsIf WinCountA2 < WinCountB2 and StratAvgA2 < StratAvgB2 and Mode2 = 1 ThenValueY = ValueY - (Increment2*NIncPos2)NIncPos2 = NIncPos2 + 1Mode2 = 2ElsIf WinCountA2 >= WinCountB2 or StratAvgA2 >= StratAvgB2 and Mode2 = 1 ThenValueY = ValueY + (Increment2*PIncPos2)PIncPos2 = PIncPos2 + 1Mode2 = 1ElsIf WinCountA2 < WinCountB2 and StratAvgA2 < StratAvgB2 and Mode2 = 2 ThenValueY = ValueY + (Increment2*PIncPos2)PIncPos2 = PIncPos2 + 1Mode2 = 1ElsIf WinCountA2 >= WinCountB2 or StratAvgA2 >= StratAvgB2 and Mode2 = 2 ThenValueY = ValueY - (Increment2*NIncPos2)NIncPos2 = NIncPos2 + 1Mode2 = 2EndIfIf NIncPos2 > MaxIncrement2 or PIncPos2 > MaxIncrement2 ThenIf BestA2 = BestB2 ThenValueY = BestA2ElseIf reps2 >= 10 ThenWeightedScore2 = 10ElseWeightedScore2 = round((reps2/100)*100)EndIfValueY = round(((BestA2*(20-WeightedScore2)) + (BestB2*WeightedScore2))/20) //Lower Reps = Less weight assigned to Win%EndIfNIncPos2 = 1PIncPos2 = 1ElsIf ValueY > MaxValue2 ThenValueY = MaxValue2ElsIf ValueY < MinValue2 ThenValueY = MinValue2EndIFoptimise2 = 0EndIf// Heuristics Algorithm 2 EndEndifboxSizeL = ValueXboxSizeS = ValueYrenkoMaxL = ROUND(close / boxSizeL) * boxSizeLrenkoMinL = renkoMaxL - boxSizeLrenkoMaxS = ROUND(close / boxSizeS) * boxSizeSrenkoMinS = renkoMaxS - boxSizeSIF high > renkoMaxL + boxSizeL THENrenkoMaxL = renkoMaxL + boxSizeLrenkoMinL = renkoMinL + boxSizeLendifif low < renkoMinS - boxSizeS THENrenkoMaxS = renkoMaxS - boxSizeSrenkoMinS = renkoMinS - boxSizeSENDIF////c1 = renkoMaxL + boxSizeL//c2 = renkoMinS - boxSizeS// Conditions to enter long positions//If c1 thenBuy N CONTRACT at renkoMaxL + boxSizeL stop//EndIf// Conditions to enter short positions//If c2 thenSellshort N CONTRACT at renkoMinS - boxSizeS stop//EndIf// Stops and targets//SET STOP %loss 0.5Set stop ptrailing 50 //100SET TARGET PPROFIT 500 //Orig 150 //Best 500graphonprice renkomaxl + boxsizel coloured(0,200,0) as "renkomax"graphonprice renkomins - boxsizes coloured(200,0,0) as "renkomin"GRAPH ValueX coloured(0,255,0)GRAPH ValueY coloured(255,0,0)//graphonprice newsl coloured(0,0,255,255) as "trailingstop atr"Edit: What does adding once ValueX = StartingValue etc, do that it wasn’t doing before that code was added? Cheers.
-
AuthorPosts
Find exclusive trading pro-tools on