Jump to content
  • 0

PRT Code - Breakout from first candle


Bopperz

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

Link to comment

7 answers to this question

Recommended Posts

  • 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

Link to comment
  • 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
 

Link to comment
  • 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.

Link to comment

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
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.

  • General Statistics

    • Total Topics
      16,260
    • Total Posts
      77,838
    • Total Members
      64,492
    • Most Online
      7,522
      10/06/21 10:53

    Newest Member
    VinodK
    Joined 24/10/21 22:22
  • Posts

    • Hi @MattKlis, 30-15 mins before opening your order should go through, make sure that you place a Good 'till cancelled expiry , as a Day expiry won't go through. More details on pre-market trading here. If you need assistance placing the order please call us or use our live chat feature on the IG website. All the best - Arvin  
    • Hi @Rustyledge, Your request was submitted. All the best - Arvin
    • Hi  I have purchased UPD share with IG market few years ago. UPD was delisted from ASX. Then move to private in USA - with Computershare. I am not sure, if I need to do something similar? I have not received any Computershare document. Please advise 
×
×
  • Create New...