I found this strategy description on the web and use my limited knowledge translate to PRT robot, please kindly try, comment and feel free modify to fit for your need.
It is mainly composed of trading criteria based upon a set of 3 moving averages, breakout of recent highest high or lowest low and on a candlesticks pattern.
Settings are optimized (please read the code to find what are the optimized variables). A Walk Forward analysis is attached.
The code also embed:
- a money management position sizing
- a trailing stop based on Max Favorable Excursion (MFE trailing stop)
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
// Big Three Trading Strategy // Original Idea from: http://www.tradingstrategyguides.com/big-three-trading-strategy/ // Market: DAX 30 // Time Frame: 1 Hour // Time Zone: Any // Spread: 2.9 // Version : 2.8 // Revised on 2017-11-14 Defparam preloadbars = 3000 Defparam cumulateorders =false //true //false //// Optional Function Switch ( 1 = Enable 0 = Disable ) //// FixedMinMaxStopLoss = 1 // Optional Function 1 TargetProfit = 1 // Optional Function 2 TimeExit = 1 // Optional Function 3 MFETrailing = 1 // Optional Function 4 MoneyManagement = 0 // Optional Function 5 //// Core Indicator Parameter Setting //// // Moving Average Setting (Original: 20, 40, 80) Fast = 20 // Not Optimize Medium = 40 // Not Optimize Slow = 80 // Not Optimize // Look Back Bar (Original: N/A) CP = 3 // Variables Optimized //// Optional Function //// // 1) Fixed Min Max Stop Loss Setting If FixedMinMaxStopLoss then //Long MaxLong = 80 // by points, Variables Optimized MinLong = 30 // by points, Variables Optimized //Short MaxShort = 60 // by points, Variables Optimized MinShort = 5 // by points, Variables Optimized Endif // 2) Take Profit Setting If TargetProfit then //Long TakeProfitLongRate = 2.6 // by %, Variables Optimized //Short TakeProfitShortRate = 2.5 // by %, Variables Optimized Endif // 3) Time Exit Setting If TimeExit then //Long ONCE maxCandlesLongWithProfit = 78 // by bar, Variables Optimized ONCE maxCandlesLongWithoutProfit = 66 // by bar, Variables Optimized //Short ONCE maxCandlesShortWithProfit = 60 // by bar, Variables Optimized ONCE maxCandlesShortWithoutProfit = 54 // by bar, Variables Optimized Endif // 4) MFE Step Setting If MFETrailing then //Long MFELongStep = 1.5 // by %, Variables Optimized //Short MFEShortStep = 1 // by %, Variables Optimized Endif // 5) Money Management If MoneyManagement then LongRisk = 5 // by %, Variables Optimized ShortRisk = 3 // by %, Variables Optimized CloseBalanceMaxDrop = 50 // by %, Personal preference Capital = 3000 // by $ Equity = Capital + StrategyProfit LongMaxRisk = Round(Equity*LongRisk/100) ShortMaxRisk = Round(Equity*ShortRisk/100) //Max Contract MaxLongContract = 500 // by contract, Variables Optimized MaxShortContract = 100 // by contract, Variables Optimized //Check system account balance If equity<QuitLevel then Quit Endif RecordHighest = MAX(RecordHighest,Equity) QuitLevel = RecordHighest*((100-CloseBalanceMaxDrop)/100) Endif // Core indicator //Big Three MA FMA = Average[Fast](close) //green coloured(0,255,0) MMA = Average[Medium](close) //blue coloured(0,0,255) SMA = Average[Slow](close) //red coloured(255,0,0) // Entry Rules //Buy Signal B1 = low > SMA and low>MMA and low>FMA B2 = high >= highest[CP](high) BC = B1 and B2 //Buy Candle BC1 = Close[1] < Close[2] BC2 = Close > Close[1] BC3 = Close > Open BCandle = BC1 and BC2 and BC3 //Sell Signal S1 = high < FMA and high<MMA and high<SMA S2 = low <= lowest[CP](low) SC = S1 and S2 //Sell Candle SC1 = Close[1] > Close[2] SC2 = Close < Close[1] SC3 = Close < Open SCandle = SC1 and SC2 and SC3 // Exit Rules LongExit = Close crosses under SMA ShortExit = Close crosses over SMA //Long Entry If Not LongonMarket and BC and BCandle then BuyPrice = Close If FixedMinMaxStopLoss then StopLossLong = MIN(MaxLong,MAX(MinLong,(BuyPrice - SMA))) Else StopLossLong = BuyPrice - SMA Endif If TargetProfit then TakeProfitLong = StopLossLong * TakeProfitLongRate TP = TakeProfitLong Endif SL = StopLossLong If MoneyManagement then PositionSizeLong = min(MaxLongContract,(max(2,abs(round((LongMaxRisk/StopLossLong)/PointValue)*pipsize)))) BUY PositionSizeLong CONTRACT AT MARKET Else BUY 2 CONTRACT AT MARKET Endif Endif //Long Exit If LongonMarket and LongExit then sell at market Endif //short entry If Not ShortonMarket and SC and SCandle then SellPrice = Close If FixedMinMaxStopLoss then StopLossShort = MIN(MaxShort,MAX(MinShort,(SMA - SellPrice))) Else StopLossShort = SMA - SellPrice Endif If TargetProfit then TakeProfitShort = StopLossShort * TakeProfitShortRate TP = TakeProfitShort Endif SL = StopLossShort If MoneyManagement then PositionSizeShort = min(MaxShortContract,(max(2,abs(round((ShortMaxRisk/StopLossShort)/PointValue)*pipsize)))) SELLSHORT PositionSizeShort CONTRACT AT MARKET Else SELLSHORT 2 CONTRACT AT MARKET Endif Endif //Short Exit If ShortonMarket and ShortExit then exitshort at market Endif // Time Exit If TimeExit then If LongonMarket then posProfit = (((close - positionprice) * pointvalue) * countofposition) / pipsize elsif ShortonMarket then posProfit = (((positionprice - close) * pointvalue) * countofposition) / pipsize Endif m1 = posProfit > 0 AND (BarIndex - TradeIndex) >= maxCandlesLongWithProfit m2 = posProfit > 0 AND (BarIndex - TradeIndex) >= maxCandlesShortWithProfit m3 = posProfit < 0 AND (BarIndex - TradeIndex) >= maxCandlesLongWithoutProfit m4 = posProfit < 0 AND (BarIndex - TradeIndex) >= maxCandlesShortWithoutProfit // take profit after max candles IF LONGONMARKET AND (m1 OR m3) THEN sell at market endif IF SHORTONMARKET AND (m2 OR m4) THEN exitshort at market endif Endif //MFE Trailing stop If MFETrailing then MFELong = (TakeProfitLong/MFELongStep) MFEShort = (TakeProfitShort/MFEShortStep) If not onmarket then MAXPRICE = 0 MINPRICE = close priceexit = 0 Endif If longonmarket then MAXPRICE = MAX(MAXPRICE,close) If MAXPRICE-tradeprice(1)>=MFELong*pointsize then priceexit = MAXPRICE-MFELong*pointsize Endif Endif If shortonmarket then MINPRICE = MIN(MINPRICE,close) If tradeprice(1)-MINPRICE>=MFEShort*pointsize then priceexit = MINPRICE+MFEShort*pointsize Endif Endif If onmarket and priceexit>0 then EXITSHORT AT priceexit STOP SELL AT priceexit STOP Endif Endif // Stop Loss a SET STOP LOSS SL // Target Profit If TargetProfit then SET TARGET PROFIT TP Endif //graph BuyPrice //graph SellPrice //graph StopLossLong //graph StopLossShort |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Thanks Bin, nice code, I can use several ideas of the way you build it
Thanks Bin, great concentration, i understand the first idea, but may u indicate me the asset where did you run it pls
Hi Mazza
This robot is optimized for DAX30.