Jump to content
  • 0

PRT Code - Breakout from first candle

Question

Hi all,

Pretty new to PRT, I am looking at an example they give in the docs. From my understanding and some squinting at the charts, this code dosent get the high and low from the opening bars. It actually takes the high and low from the preceding two bars. Am I correct? And if so, how do I get the opening bars?

Suspect code/description in bold.

 

This is a basic breakout intraday trading system that takes only long positions. The initial range is determined
by the highest and lowest points of the first 2 candlesticks of the day
. A support is defined at the lowest point
and a resistance at the highest point.

DEFPARAM CumulateOrders = False
MM = Average[10](close)
MyTarget = 1
EndTime = 170000
IF INTRADAYBARINDEX = 2 THEN
MyResistance = highest[2](high)
MySupport = lowest[2](low)

ENDIF
REM Enter Long:
IF MM > MM[1] AND close CROSSES OVER MyResistance THEN
BUY 1 SHARES AT MARKET
ENDIF
REM Exit Long:
IF time > EndTime THEN
SELL AT MARKET
ENDIF
SELL AT MySupport STOP
SET TARGET %Profit MyTarget

Share this post


Link to post

7 answers to this question

Recommended Posts

  • 0

Try something like this

Its the guys at prorealcode.com that did the job

This is a optimized version for EURUSD 5 min that i did in November only one trade a day and a trailing stop

I dont use it anymore but could be a starting point?

Share this post


Link to post
  • 0

//-------------------------------------------------------------------------
// Main code : AAAAA EU BO 5 min 24 nov skp
//-------------------------------------------------------------------------
DEFPARAM CumulateOrders = false
DEFPARAM FLATBefore     = 150000                       
DEFPARAM FLATAfter      = 210000                        
DEFPARAM PreLoadBars    = 2000

ONCE nLots              = 1
ONCE MaxPrice           = 999999
ONCE MinPrice           = 0
ONCE FirstHour          = 150000 // Start

IF time = FirstHour THEN
MaxPrice = highest[12](high)                        // Highest 12 bars 5 min = 60 min
MinPrice = lowest[12](low)                            // LoWest  
ENDIF
//************************************************************************
//     trailing stop function
trailingstart = 13  //5    trailing will start @trailinstart points profit
trailingstep  = 2  //5    trailing step to move the "stoploss"
//
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
//************************************************************************
//                           LONG
a1 = close > MaxPrice
IF a1 THEN
Buy nLots CONTRACT AT MARKET
MaxPrice = 999999
MinPrice = 0
ENDIF

//                           SHORT
b1 = close < MinPrice
IF b1 THEN
Sellshort nLots CONTRACT AT MARKET
MaxPrice = 999999
MinPrice = 0
ENDIF
SET STOP PLOSS 20

Share this post


Link to post
  • 0

This is a DOW version i have had running on demo on 3 min

But i dont like it, probably another loser in play?

To be honest this breakout systems looks good in theory buy fails when trading them 

Markets change all the time and risk of curvefitting

 

DOW.png

Share this post


Link to post
  • 0

//-------------------------------------------------------------------------
// Main code : BO DOW3 3 min
//-------------------------------------------------------------------------
DEFPARAM CumulateOrders = false
DEFPARAM FLATBefore     = 090000                        //09:00
DEFPARAM FLATAfter      = 210000                         //21:00
DEFPARAM PreLoadBars    = 2000

ONCE nLots              = 1
ONCE MaxPrice           = 999999
ONCE MinPrice           = 0
ONCE FirstHour          = 090000

IF time = FirstHour THEN
MaxPrice = highest[12](high)                          
MinPrice = lowest[12](low)                            
ENDIF
//************************************************************************
//     trailing stop function
trailingstart = 9    //5    trailing will start @trailinstart points profit
trailingstep  = 11   //5    trailing step to move the "stoploss"
//
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
//************************************************************************
//                           LONG
a1 = close > MaxPrice
IF a1 THEN
Buy nLots CONTRACT AT MARKET
MaxPrice = 999999
MinPrice = 0
ENDIF

//                           SHORT
b1 = close < MinPrice
IF b1 THEN
Sellshort nLots CONTRACT AT MARKET
MaxPrice = 999999
MinPrice = 0
ENDIF
SET STOP PLOSS 40
SET TARGET PPROFIT 93
 

Share this post


Link to post
  • 0

And they are sensitive to change in volatility 

Share this post


Link to post
  • 0

Thanks @kodiak!

I will take a look at your code. It looks like a large part of the code is creating/updating stop loss? They have a built in function for that now, so ill probably use that.

I think there is a problem with their example though. They are identifying the opening candles using the IF INTRADAYBARINDEX = 2 THEN, this triggers on the third candle. But it seem to ignore the very first candle and take the high/low of 2nd and 3rd candle. I changed it to INTRADAYBARINDEX = 1, and it correctly uses the 1st and 2nd candle.

Share this post


Link to post
  • 0

Did a backtest on EURUSD

Friday was a winner but had some drawdown lately so its probably time for some tweaking of the settings?

 

EU BT.png

Share this post


Link to post

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
You are posting as a guest. If you have an account, please sign in.
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Member Statistics

    • Total Topics
      8,805
    • Total Posts
      48,391
    • Total Members
      61,180
    Newest Member
    geop5
    Joined 30/03/20 08:36
  • Posts

    • This week is a crucial week for US indices I think especially end of the week. If we are going to see extreme Dow soon, the market will let us know.  The volatility is expected to pick up so money can probably be made in both directions with 1000+ points move again. I personally would not go long for a couple days. There are positions trapped right now going long from last week so I would guess some will be forced to endure some pain, unless they volunteer to take losses.
    • If it moves below $5k to maybe $4k again, it doesn't look like there is a great deal of support. Sure it can double in a short span of time but don't you think this is a very risky trade?
    • as explained earlier in the thread the cumulative risk reward ratio (auto calc'd on a spread sheet) plotted on the chart with the win rate is absolutely fool proof in revealing if a strategy is profitable of not. Also if you make any changes to the strategy the result will show up quickly in the stats so revealing whether the change was advantageous or not. Without hard statistics people have a habit of misleading themselves as to how well they and their strategy are really doing.
×
×