Hi crew,
Here I have taken a 1 min trade to a 5 min version that looks ok. It was a challenge to myself to create something with less limitations ie. time, hard stops etc. I cannot get it to run however and believe it’s to do with the MTF. I have used this feature to filter many trades but never had a problem.
I can have it in my live portfolio but does not execute or get rejected, can someone please take a look? It should be trading in this environment.
There is further work to be done on it’s entry, but for the most part seems ok.
// Definition of code parameters
DEFPARAM CumulateOrders = false // Cumulating positions deactivated
// The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the "FLATBEFORE" time.
DEFPARAM Preloadbars = 10000
//Read market strucure
timeframe (30 minute,updateonclose)
indicator1 = ExponentialAverage[100]
c1 = (close < indicator2[1])
// Conditions to enter long positions
timeframe (default)
c2 = (close < low[3])
indicator2 = Average[1000](close)
c3 = (indicator2 <= indicator2[100])
c4= (close <= indicator2)
Indicator3 = ExponentialAverage[10]
Indicator4 = ExponentialAverage[20]
c5 = (Indicator4 CROSSES OVER indicator3)
Once MaxLoss = 50
Once TempProfit = 0
Once TradeON = 1
If IntraDayBarIndex = 0 Then
TempProfit = StrategyProfit
TradeON = 1
Endif
If TempProfit - StrategyProfit >= MaxLoss then
TradeON = 0
Endif
IF c1 AND c2 AND c3 AND c4 AND c5 AND TradeOn THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
indicator5 = ExponentialAverage[50](close)
c6 = (close CROSSES Under indicator5[0])
indicator6 = Volume
c7 = (indicator6 < 2000[3]) //volume specific to current NDQ environment. Needs % version for robustness
c8 = (close < open[2]) //boosts profits!
IF c6 OR c7 AND c8 THEN
SELL AT MARKET
ENDIF
Line 10 should read:
c1 = (close < indicator1[1]) //instead of c1 = (close < indicator2[1])
and line 47 should read:
IF OnMarket AND (c6 OR c7 AND c8) THEN
Line 10 should read:
<!– Crayon Syntax Highlighter v_2.7.2_beta –>
<textarea class=”crayon-plain print-no” style=”tab-size: 4; font-size: 14px !important; line-height: 16px !important; z-index: 0; opacity: 0; overflow: hidden;” readonly=”readonly” wrap=”soft” data-settings=”dblclick”>c1 = (close < indicator1[1]) //instead of c1 = (close < indicator2[1])</textarea>
<table class=”crayon-table”>
<tbody>
<tr class=”crayon-row”>
<td class=”crayon-nums ” data-settings=”show”>
</td>
<td class=”crayon-code”>
c1 <span class=”crayon-o”>=</span> (<span class=”crayon-st”>close</span> <span class=”crayon-o”><</span> indicator1<span class=”crayon-o”>[</span><span class=”crayon-cn”>1</span><span class=”crayon-o”>]</span>) <span class=”crayon-c”>//instead of c1 = (close < indicator2[1])</span>
</td>
</tr>
</tbody>
</table>
<!– [Format Time: 0.0002 seconds] –> and line 47 should read:
<!– Crayon Syntax Highlighter v_2.7.2_beta –>
<textarea class=”crayon-plain print-no” style=”tab-size: 4; font-size: 14px !important; line-height: 16px !important; z-index: 0; opacity: 0; overflow: hidden;” readonly=”readonly” wrap=”soft” data-settings=”dblclick”>IF OnMarket AND (c6 OR c7 AND c8) THEN</textarea>
<table class=”crayon-table”>
<tbody>
<tr class=”crayon-row”>
<td class=”crayon-nums ” data-settings=”show”>
</td>
<td class=”crayon-code”>
<span class=”crayon-st”>IF</span> <span class=”crayon-st”>OnMarket</span> <span class=”crayon-st”>AND</span> (c6 <span class=”crayon-st”>OR</span> c7 <span class=”crayon-st”>AND</span> c8) <span class=”crayon-st”>THEN</span>
</td>
</tr>
</tbody>
</table>
<!– [Format Time: 0.0002 seconds] –>
Thanks, and thanks for the MAX loss code I use it in everything and it has kept me safe.
I liked the back test results with the failed code much better!
Uh, back to the drawing board…I’ll poke around with it a bit longer. The 1 min version has been in profit for 6 months so I’m sure there is something in the concept of this counter trend trade.
The 30min TF filter is neither here nor there to be honest. If I code the bot correctly it’s for the bin.
Regards the Exit conditions of my inactive code (c6 OR c7 AND c8), without correct format of “IF OnMarket THEN” What exactly have I asked it to do?
Because it does something which makes it amazing = 10%DD and 60%WR, 50% Annualized. It goes ballistic in a ‘bear mrkt’ and holds itself in a grinding trend.
Be honest, is this fools gold? Anyone?
Cheers CC
File attached is incorrect code and what I thought I was building!
“IF OnMarket THEN” simply makes SELL (which means exit from a Long position) only IF ONMARKET, otherwise your code will end up BUYing in line 36, then SELLing immediately in line 48 before any position is even opened (and you will be returned empty reports).
Beear in mind that backtests are only based (and optimized for) the past. There’s no forecasting skill in it!
So, it’s wise to let any code run in autotradimg on a demo account for several months before letting it manage real money!