How to pick specific 5M candle from higher TF
Page 1 of 732 12 LastLast
Results 1 to 10 of 311

Thread: How to pick specific 5M candle from higher TF

  1. #1
    Hello men

    I am searching for best code for choosing specific 5M candle from higher TF.
    What I mean is that.
    For example I know that candle 2 on 30M chart has cheapest price of previous X-30Min candles... Is there some function I can use for select (select ) from the 30M candle which specific 5M candle that has this cheapest price? Because with this 30M candle there are just 6 x5M candles and just one has that cheapest price.

    THX

  2. #2
    Quote Originally Posted by ;
    You can find the datetime of the close and open of the 30 min candle Then use Ibarshift and iLowest, limiting the scan to involving both datetimes to discover the M5 candle
    Thx Gumrai
    I was thinking to use exact information window but difficulty is if I know openclose period of that 30M how I pick Lowest 5M candle for only this period window? I will only use something like this??? :
    iLowest(NULL, 5, MODE_LOW, CloseTime, OpenTime)

  3. #3
    Quote Originally Posted by ;
    quote Thx I had been thinking to use specific information window but problem is if I know openclose time of the 30M how I pick Lowest 5M candle for just this time pub? I'll only use something similar to this??? : iLowest(NULL, 5, MODE_LOW, CloseTime, OpenTime)
    Not tested in anyhow, but this may give you a beginning point to do everything you want
    Inserted Code int I; //Shift of bar in the higher timeframe datetime opencandle = Time; datetime closecandle = opencandle (Period()*60)-1; int shiftM5first = iBarShift(NULL,PERIOD_M5,opencandle,false); int shiftM5last = iBarShift(NULL,PERIOD_M5,closecandle,false); int M5lowestshift = iLowest(NULL,PERIOD_M5,MODE_LOW,shiftM5first-shiftM5last 1,shiftM5last);
    Edit: appears to be a problem with posting the code. At the second line of the above code, it must be Time,open sg bracket,I,shut sq bracket

  4. #4
    Quote Originally Posted by ;
    quote Thx Gumrai I was thinking to use specific information window but problem is if I understand openclose time of that 30M how I select Lowest 5M candle to get only this time pub? I'll only use something similar to this??? : iLowest(NULL, 5, MODE_LOW, CloseTime, OpenTime)
    if you know it is the lowest of the last X 30m bars then it is also the lowest of the last X*6 5m bars so only select the lowest 5m bar of the last Xwhich is easily done.

    Int TheBar = iLowest(NULL,PERIOD_M5,MODE_LOW,x,0);

    where x = number of bars to search ie X*6

  5. #5
    I've attempted a lot of times to edit my previous article.
    The 2nd line of code ought to be
    datetime opencandle = Time;
    but it simply shows as Time without the for a certain reason.

    WTF!! It doesn't show in this informative article
    it's square brackets with the I integer

  6. #6
    Quote Originally Posted by ;
    I have attempted numerous times to edit my previous article. The 2nd line of code ought to be datetime opencandle = Time; but it just shows as Time minus the for some reason.
    thx Gumrai.
    In this line
    datetime closecandle = opencandle (Period()*60)-1;
    Why did you add also that -1?

  7. #7
    Quote Originally Posted by ;
    quote thx . In this line datetime closecandle = opencandle (Period()*60)-1; Why did you put in too that -1?
    Because without that it would then be the period of the next opened candle on the greater time-frame.

  8. #8
    Quote Originally Posted by ;
    quote Because without that it would then be the time of another opened candle on the higher time-frame.
    understand

    thx Gurmai I'm testing that code today
    that I will inform you how it works for me

  9. #9
    Hi Gumrai

    Your Thought is working but I've one Q. I added Vline to see precisely that candle on Lower TF is that particular (because I am watching chart on Upper TF) but it is not working properly. Alert however no Vline was received by me. Once I switch from Upper TF to reduce TF and again back to Upper TF afterward indi will plot online.
    Can you tell me what can be incorrect from tha Line code?
    .
    .
    Datetime opencandle = iTime(NULL, 30, 2);
    datetime closecandle = opencandle (Stage ()*60)-1;
    int shiftM5first = iBarShift(NULL,5,opencandle,false);
    int shiftM5last = iBarShift(NULL,5,closecandle,false);
    int M5HighestPriceShift = iHighest(NULL,5,MODE_HIGH,shiftM5first-shiftM5last,shiftM5last);
    int M5HighestVolumeShift = iHighest(NULL,5,MODE_VOLUME,shiftM5first-shiftM5last,shiftM5last);
    ObjectCreate(Line Timing [1], OBJ_VLINE, 0, 0, 0, 0, 0);
    ObjectSet(Line Timing [1], OBJPROP_COLOR, Gold);
    ObjectSet(Line Timing [1], OBJPROP_STYLE, STYLE_SOLID);
    ObjectSet(Line Timing [1], OBJPROP_WIDTH, 1);
    ObjectSet(Line Timing [1], OBJPROP_TIME1, iTime(NULL, 5, M5HighestPriceShift));
    ObjectSet(Line Timing [1], OBJPROP_BACK, true);
    Alert(Symbol() Stage () M Candle Amount with Maximum price x= M5HighestPriceShift Volume candle v= M5HighestVolumeShift);

    THX

  10. #10
    It's possible that the M5 values are upgrading, one of the issues with retrieving information from a different interval.
    It may be an idea to test that M5Highestshift! = 0
    When it does and you aren't running this code in an indior, then sleep for 2000ms then begin again
    Once you alter tf to M5 and back, the terminal gets time to fully upgrade M5 data.

    Note:
    Inserted Code int M5HighestPriceShift = iHighest(NULL,5,MODE_HIGH,shiftM5fi rst-shiftM5last,shiftM5last); you now have an area in first and you also missed the 1


    Inserted Code int M5HighestPriceShift = iHighest(NULL,5,MODE_HIGH,shiftM5first-shiftM5last,shiftM5last 1);

    It might also be an idea to bring a condition as this might do strange things if attached to the M5 or M1chart.

    Inserted Code if(Period() gt; PERIOD_M5) //insert code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.