Retracement breakout with last few candles in Loop

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #212580 quote
    amitoverseas40
    Participant
    Junior

    Hi Team,

     

    1. Anyway I can code the price to buy only if the price reach at the open of bearish candle when condition is met…as of now SELL trade gets opened when condition is met and candle is down , I need that price to retrace to open or therebaouts instead of opening straightaway…on Dow Jones these 5 mins candles are sometimes 100+ points 🙂 I’d rather wait for price to retrace near open etc?
    2. Is there a way to code and point to a specific candle in last few bars..i.e. condition met for a bearish candle 5 or 7 bars ago..price went down as expected and now traced higher than bearish candle thus signalling a reversal…I trade manually since I do not know how to code that…vice versa for Bullish candle...?

     

    Appreciate your help on this..

    #212581 quote
    amitoverseas40
    Participant
    Junior

    Please see attached PIC for example I have colour coded, it took 8 candles for the price to revert…I want someway to track this last candle when condition was met, in this scenario pink/magenta candle –  so when price breaks above this candle, we go long!!

    vice versa for short if blue breaks..

    #212590 quote
    amitoverseas40
    Participant
    Junior

    Please see attached PIC for example I have colour coded, it took 8 candles for the price to revert…I want someway to track this last candle when condition was met, in this scenario pink/magenta candle – so when price breaks above this candle, we go long!!

    vice versa for short if blue breaks..

    Any help please, not sure if it’s possible to have a for loop and track last candle that meets the condition?

    #212591 quote
    Nicolas
    Keymaster
    Master

    Please don’t quote any of your message for each of your reply.

    To check if the close of the current candle breaks one of the candlestick Close X bars ago (from minCandles to maxCandles) and with a retracement > minPoints, use the below code:

    mincandles = 3
    maxcandles = 20
    minPoints = 20
    
    for i = mincandles to maxcandles
    if close>close[i] and close[1]<close[i] and min(close,close[i])-lowest[max(1,i)](low)>minPoints*pointsize then 
    drawarrowup(barindex,low) coloured("green")
    drawsegment(barindex,min(close,close[i]),barindex[i],min(close,close[i])) style(dottedline2)
    break
    endif 
    next
    
    return
    #212596 quote
    amitoverseas40
    Participant
    Junior

    Hi Nicolas, apologies for duplication via quoting.  Thank you for your response, appreciate it. Let me try and revert on the results.

    #212599 quote
    amitoverseas40
    Participant
    Junior

    Hi Nicolas,

     

    My condition is simple: c1=close>high[1]

    All I want is in a loop is when candle goes below , when this condition was met, an arrow should be drawn or segment as you kindly put in the code already.

    I have tried but unable to get the result I expect. Would appreciate your help.

    #212600 quote
    Nicolas
    Keymaster
    Master

    goes below what please?

    #212602 quote
    amitoverseas40
    Participant
    Junior

    Sorry, goes below c1 (condition) i.e. c1=close>high[1]

    So c1 occurred 8 or 10 candles ago , and price was consolidating or going higher, now close is going below c1 after 8-10 candles…I need the arrow/segment at this point please.

    #212603 quote
    Nicolas
    Keymaster
    Master

    I still don’t get it sorry.

    Could you just take a chart and show me the pattern by a simple drawing please?

    #212604 quote
    amitoverseas40
    Participant
    Junior

    Hi Nicolas, sure, and many thanks for your assistance.

    Please see the attached chart, I have tried to explain in a simple possible way according to my brain, hope it’s the same message coming across to you as well .

     

    If you actually observe, there are 2 times candle closed below c1 condition. I have only highlighted last 1 for better visibility. it could be 4 candles or 8 when candle closed below c1.

    #212606 quote
    Nicolas
    Keymaster
    Master

    this version plots c1 conditions tested and the arrow on the candle that close below the Open of the c1 candle.

    minCandles = 3
    
    c1 = close>high[1]
    
    if c1 then 
    trigger=open 
    bar=barindex
    drawtext("c1",barindex,high)
    endif 
    
    if barindex-bar>=minCandles and close crosses under trigger and  trigger>0 then 
    drawarrowdown(barindex,high) coloured("red")
    trigger=0
    endif 
    
    return 
    
    
    amitoverseas40 thanked this post
    #212607 quote
    amitoverseas40
    Participant
    Junior

    minCandles = 3   c1 = close>high[1]   if c1 then trigger=open bar=barindex drawtext(“c1”,barindex,high) endif   if barindex-bar>=minCandles and close crosses under trigger and  trigger>0 then drawarrowdown(barindex,high) coloured(“red”) trigger=0 endif   return

    Hi Nicolas, many many thanks for your help, much appreciate it! All works as expected, finally!

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

Retracement breakout with last few candles in Loop


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 11 replies,
has 2 voices, and was last updated by amitoverseas40
2 years, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/30/2023
Status: Active
Attachments: 3 files
Logo Logo
Loading...