Forums › ProRealTime English forum › ProOrder support › Maximum number of lines of code in a strategy? › Reply To: Maximum number of lines of code in a strategy?
02/09/2019 at 11:07 PM
#90951
Having read my last post I came to the conclusion that it is a bit confusing! So here is a tiny section of my strategy to give an idea of what I am doing and maybe clarify it a little:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
best = 0 for pstart = 1 to 40 ps = pstart * 10 //strategy010010 x010010 = 10// simulated x y010010 = 10// simulated y c1s010010 = (simulated price action condition) c2s010010 = (simulated indicator long entry condition using simulated x and y value) c3s010010 = (simulated indicator short entry condition using simulated x + y value) if c1s010010 and c2s010010 then tots010010 = tots010010 + (close - open) endif if not c1s010010 and c3s010010 then tots010010 = tots010010 + (open - close) endif best = max((tots010010 - tots010010[ps])/ps , best) if ((tots010010 - tots010010[ps])/ps) = best then x = x010010 y = y010010 p = ps endif //strategy010020 x010020 = 10 //simulated x y010020 = 20 //simulated y c1s010020 = (simulated price action condition) c2s010020 = (simulated indicator long entry condition using simulated x and y value) c3s010020 = (simulated indicator short entry condition using simulated x + y value) if c1s010020 and c2s010020 then tots010020 = tots010020 + (close - open) endif if not c1s010020 and c3s010020 then tots010020 = tots010020 + (open - close) endif best = max((tots010020 - tots010020[ps])/ps , best) if ((tots010020 - tots010020[ps])/ps) = best then x = x010020 y = y010020 p = ps endif //strategy010030 x010030 = 10 //simulated x y010030 = 30 //simulated y c1s010030 = (simulated price action condition) c2s010030 = (simulated indicator long entry condition using simulated x and y value) c3s010030 = (simulated indicator short entry condition using simulated x + y value) if c1s010030 and c2s010030 then tots010030 = tots010030 + (close - open) endif if not c1s010030 and c3s010030 then tots010030 = tots010030 + (open - close) endif best = max((tots010030 - tots010030[ps])/ps , best) if ((tots010030 - tots010030[ps])/ps) = best then x = x010030 y = y010030 p = ps endif // // // //and on and on with more simulations for every combination of x and y that you wnat to use for auto optimizing. 10 to 200 step 10 = 400 combinations in totzl! // // // next //Real Strategy c1 = (price action condition) c2 = (indicator long entry condition using best x and y) c3 = (indicator short entry condition using best x + y) sell at market exitshort at market if c1 and c2 then buy 1 contract at market endif if not c1 and c3 then sellshort 1 contract at market endif next graph x coloured(128,0,0) graph y coloured(0,128,0) graph p coloured(0,0,0) |
I have truncated the code to remove 9900 repeating lines just so that you can see the bones of what I am testing.
The plan is to turn it into an indicator that simulates trades and provides a value for x and y that a strategy can use to trade via CALLing the indicator.