Jump to content
  • 0

PRT Code - Breakout from first candle


Bopperz

Question

Posted

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

7 answers to this question

Recommended Posts

  • 0
Posted

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?

  • 0
Posted

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

  • 0
Posted

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

  • 0
Posted

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

  • 0
Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • image.png

  • Posts

    • Did anyone from here file a suit against IG for XRP delisting ??.. how come they are now allowing a product relayed to ripple … I hope someone is active out on this front 
    • I’ve been exploring RWA (Real-World Asset) projects to focus on this festive season. Currently, I hold ONDO and QNT, but INK Finance (Quill) has caught my attention due to its robust and versatile features. Here’s why:     INK Finance acts as financial infrastructure for protocols, DAOs, and RWA originators, enabling them to:   - Earn yield.   - Manage treasuries.   - Tokenize real-world assets (RWAs) with a focus on compliance and integrity.     The platform provides a scalable solution for web3 DAOs, protocols, and asset managers, empowering them to:   - Customize asset management and governance frameworks through a no-code interface.   - Establish on-chain credit and financial competence.     INK Finance offers a comprehensive, frictionless solution for organized financial activities, combining scalability and customizability.     With its token now available on BingX Spot, I’m planning to take a position around the support zone, that is being respected, looking at the chart below, if the price of QUILL break my bearish trendline on the chart, I will ape in to hold long term, with the current market trend and how are are going into the altcoin season, I'm hoping it'll break the ATH. Trade QUILL Here Sign up on BingX Here  
    • I tried out Ink Finance ($QUILL), and it feels like a game changer for anyone managing DAOs or looking into RWA tokenization and with the no-code framework makes it super accessible, even for traders like me. Also, seeing how it bridges traditional finance and Web3 has been eye-opening and It’s amazing how far DeFi tools have come this one looks tailored for scalability and compliance. Currently listed on BingX, and I’m excited to see where it goes from here. If you’re into DAOs or crypto governance, this is worth checking out.  
×
×
  • Create New...
us