Breakout Strategy on the candle stick – please Help!!

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #62467 quote
    crolakstrading
    Participant
    Senior

    Hi Nicolas and all,

    I have creates a simple breakout strategy.. which triggers on the 1 hour chart.. when the 3am candle stick closed it will put an buy stop order 10 pips above the highest high of that 3am candle.. please see below!!

    it will only trigger if the next candle reach 10pips above the highs? but if 5th candle reach the buy stop order it wont trigger?? please if anyone can help get this sorted?

    aslo how can i add a Stoploss 10pips below the low on the 3am candle??

    please help!!

    DEFPARAM CumulateOrders = False
    tradingtime=(time >= 030000 and time <060000)
    // Timeframe : H1
    
    if time=030000 then
    value=high
    
    // Conditions to enter long positions
    IF NOT LongOnMarket AND tradingtime and value THEN
    EntryPrice = (high) + (10* pipsize)
    BUY 1 CONTRACTS AT EntryPrice STOP
    ENDIF
    
    // Stops and targets : Enter your protection stops and profit targets here
    // points based STOP LOSS and TRAILING STOP
    // initial STOP LOSS
    SET STOP pLOSS 50
    //set target of positions at 50 points
    SET TARGET PROFIT 50
    ENDIF
    
    #62491 quote
    Despair
    Blocked
    Master

    Your condition is only true once. So the strategy will place a stop order that is always valid for one bar. If you want it to be active longer you have to repeat the order.

    crolakstrading thanked this post
    #62529 quote
    crolakstrading
    Participant
    Senior

    thanks but how can i repeat the order? and add a Stoploss 10pips below the low on the 3am candle??

    #62584 quote
    robertogozzi
    Moderator
    Master

    Move ENDIF from line 20 to line 7.

    #62586 quote
    robertogozzi
    Moderator
    Master

    I suggest this modified code

    DEFPARAM CumulateOrders = False
    tradingtime=(time >= 030000 and time <060000)
    // Timeframe : H1
     
    if time=030000 then
       value    = high
       StopLoss = range + (10 * pipsize)   //10 pips below LOW
     ENDIF
     
    // Conditions to enter long positions
    IF NOT LongOnMarket AND tradingtime and value THEN
       BUY 1 CONTRACTS AT Value STOP
       SET STOP LOSS StopLoss
    ENDIF
    //set target of positions at 50 points
    SET TARGET pPROFIT 50

     

    #62591 quote
    crolakstrading
    Participant
    Senior

    hi Roberto,

    Thanks once again for your attention! i have tried to change abit..

    Entryprice should be 10 pips above the high of 3am candle and should work as a stop order lets say if 6 am candle goes higher and the entryprice should be still 10pips high of that 3 am candle high!!

    DEFPARAM CumulateOrders = False
    tradingtime=(time >= 030000 and time <060000)
    // Timeframe : H1
     
    if time=030000 then
    value    = high
    StopLoss = range + (10 * pipsize)   //10 pips below LOW
    EntryPrice = (high) + (10* pipsize)
    ENDIF
     
    // Conditions to enter long positions
    IF NOT LongOnMarket AND tradingtime and value THEN
    BUY 1 CONTRACTS AT EntryPrice STOP
    ENDIF
    IF OnMarket THEN
    SET STOP LOSS StopLoss
    ENDIF
    //set target of positions at 50 points
    SET TARGET pPROFIT 50                 //or SET PROFIT 50 * pipsize

    10pip higher the high of 3am is the entry and 10pip below the low of 3am is stoploss!!

    #62592 quote
    robertogozzi
    Moderator
    Master

    It should work!

    #62627 quote
    crolakstrading
    Participant
    Senior

    seems like it give the Stoploss just the low of the candle.. i have change  StopLoss = range + (20 * pipsize) which gives the right Stoploss!! it will enter perfect at the entryprice but it aslo get another two entries randomly.. not sure why?

    please see pic below:

    DEFPARAM CumulateOrders = False
    tradingtime=(time >= 030000 and time <060000)
    // Timeframe : H1
     
    if time=030000 then
    value    = high
    StopLoss = range + (20 * pipsize)   //10 pips below LOW
    EntryPrice = (high) + (10* pipsize)
    ENDIF
     
    // Conditions to enter long positions
    IF NOT LongOnMarket AND tradingtime and value THEN
    BUY 1 CONTRACTS AT EntryPrice STOP
    ENDIF
    IF OnMarket THEN
    SET STOP LOSS StopLoss
    ENDIF
    //set target of positions at 50 points
    SET TARGET pPROFIT 50                 //or SET PROFIT 50 * pipsize
    #62636 quote
    robertogozzi
    Moderator
    Master

    My fault, just change line 7 so that it reads

    StopLoss = high - (range + (20 * pipsize))

    this should work also with 10 pips offset, rather than 20.

    #62867 quote
    crolakstrading
    Participant
    Senior

    Hi Roberto..

    I have manage to get pretty much the right entry and the stoploss.. thanks. i have change the time period 3am to 9am to trigger..

    so for this now i have added to go short if short triggered.. please if you be kind enough to check below code if its correct? i have attached pic on GBPUSD.. please if you can check this on GBPUSD would be great!!!

    the idea is.. if long triggered the short order should cancel automatically and also if short triggered the long order should cancel.. is this possible??

    DEFPARAM CumulateOrders = False
    tradingtime=(time >= 030000 and time <=090000)
    // Timeframe : H1
     
    if time=030000 then
    value    = high
    value1   = low
    EntryPrice = (high) + (10* pipsize)
    EntryPrice1 = (low) - (10 * pipsize)
    StopLoss = range + (20 * pipsize)   //10 pips below LOW
    StopLoss1 = range + (20 * pipsize)   //10 pips above HIGH
    ENDIF
     
    // Conditions to enter long positions
    IF NOT LongOnMarket AND tradingtime and value THEN
    BUY 1 CONTRACTS AT EntryPrice STOP
    ENDIF
    IF OnMarket THEN
    SET STOP LOSS StopLoss
    ENDIF
    
    // Conditions to enter Short positions
    IF NOT ShortOnMarket AND tradingtime and value1 THEN
    SEllSHORT 1 CONTRACTS AT EntryPrice1 STOP
    ENDIF
    IF OnMarket THEN
    SET STOP LOSS StopLoss1
    ENDIF
    //set target of positions at 50 points
    SET TARGET pPROFIT 50                 //or SET PROFIT 50 * pipsize
    #63221 quote
    crolakstrading
    Participant
    Senior

    ?

    #63252 quote
    Nicolas
    Keymaster
    Master

    It’s not possible to cancel pending order. Since they last only 1 period, the only way for them to get out from market is to wait 1 bar.

    #63272 quote
    crolakstrading
    Participant
    Senior

    ah ok!! if i remove the tradingtime will that mean.. it will trigger any time after 3am.. will it trigger only once either way? its seems like if it gets trigger to go long and the stop loss or the profit target hit with in 3am and 9am.. it will place another order to go long for some reason? any reason why?

    #63284 quote
    robertogozzi
    Moderator
    Master

    ah ok!! if i remove the tradingtime will that mean.. it will trigger any time after 3am… will it trigger only once either way? its seems like if it gets trigger to go long and the stop loss or the profit target hit with in 3am and 9am.. it will place another order to go long for some reason? any reason why?

    No, it will trigger at all time, after 3am and before 3am the following day, then new values will be assigned to variables.
    It may be triggered either ways (and that may happen more than once either way) as long as the Entry prices are hit.

    If you only want to enter ONCE, no matter which direction, then you just have to clear VALUE and VALUE1 when OnMarket.

    If, instead, you want to enter ONCE per direction, then you just have to clear VALUE when LongOnMarket and VALUE1 when ShortOnMarket.

    But it may happen that the trade is opened and closed within the same candle… then you can only tell a trade had been entered by comparing STRATEGYPROFIT at each candlestick. If the two values are not identical, you may assume a trade has been entered and closed in one bar!

    #248873 quote
    crolakstrading
    Participant
    Senior

    DEFPARAM CumulateOrders = False
    // Timeframe : H1
    tradingtime=(time >=090000 and time <=090000)
    if time=090000 then
    value2 = high
    value1 = low
    EntryPrice = (high) + (10* pipsize)
    EntryPrice1 = (low) – (10 * pipsize)
    StopLoss = range + (20 * pipsize) //10 pips below LOW
    StopLoss1 = range + (20 * pipsize) //10 pips above HIGH
    //takeprofit = range + (20 * pipsize) // TP LONG/SHORT

    ENDIF

    // Conditions to enter long positions
    IF NOT LongOnMarket AND tradingtime and value2 THEN
    BUY 0.5 CONTRACTS AT EntryPrice STOP
    ENDIF
    IF OnMarket THEN
    SET STOP LOSS StopLoss
    ENDIF

    // Conditions to enter Short positions
    IF NOT ShortOnMarket AND tradingtime and value1 THEN
    SEllSHORT 0.5 CONTRACTS AT EntryPrice1 STOP
    ENDIF
    IF OnMarket THEN
    SET STOP LOSS StopLoss1
    ENDIF

    // Stops and targets : Enter your protection stops and profit targets here
    // points based STOP LOSS and TRAILING STOP
    // initial STOP LOSS
    //set target of positions at 40 points
    SET TARGET PROFIT 200 //(”takeprofit” must be here if you want to achive 1:1 and remove below coding if not breakeven)
    //************************************************************************
    //trailing stop function
    trailingstart = 15 //trailing will start @trailinstart points profit
    trailingstep = 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
    //************************************************************************

    Hi

    Everyone this is a breakout strategy i was made with Nicolos and Robertos help massively. i’m still learning..

    I have added a trailing SL seems to be working fine. Is there a way that this can be developed in to have a take profit 1:2 or 1:3, meaning if the SL to entry had 30pips range target will be 60pips or 90pips?

    Please, can anyone have a look at this highly appreciated?

    Thank you in advance.

Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.

Breakout Strategy on the candle stick – please Help!!


ProBuilder support

New Reply
Author
Summary

This topic contains 19 replies,
has 2 voices, and was last updated by crolakstrading
6 months, 1 week ago.

Topic Details
Forum: ProBuilder support
Language: English
Started: 02/12/2018
Status: Active
Attachments: 2 files
Logo Logo
Loading...