how to find the biggest candlestick over the last 10 bars

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #42661 quote
    ck1066
    Participant
    Average

    Hi,

    How do I test the current candlestick is the biggest candle over the last 10 bars? I tried the following but didn’t work

    range>range[10]

    #42666 quote
    robertogozzi
    Moderator
    Master

    You line of code tests the current RANGE with that of the 10th bar before, but there can be greater ones in the middle!

    Try this one:

    y = summation[12](range > range[1])
    GRAPH y AS "y"

    It makes a sum of your condition for the number of bars in brackets. The output is in how many bars your condition is true, even not consecutively. If you need it to be consecutive you have to test the output against the number in brackets to check if they match.

    You could also use FOR…NEXT loops, but it’s far more time consuming!

    I tested it on AudCad DAILY and found a match on May 13th, 2013, but the odd thing is that it seems to output a value which is 2 less than the number in brackets. 12 will found 10, 11 will output 9…

    Sorry, can’t figure out why, you will have to experiment a bit.

    GRAPH is useless for the logic, I used it just for debugging purposes only.

    #42721 quote
    robertogozzi
    Moderator
    Master

    Sorry, but SUMMATION is not the correct instruction, because it checks that each range, from the current one down to the nth one, is greater that the previous. So they need to be consecutively smaller that the previous one.

    So the correct solution is to use FOR… NEXT loops:

    x = 0                        //let's start the count from 0
    
    for i = 1 to 10
       if range > range[i] then  //range never changes, it is always the current
          x = x + 1              //one and it is tested against all previous ten,
       endif                     //no need for them to be always smaller than
    next                         //the previous one, just smaller than the current one!
    
    if x = 10 then               //if x = 10 then all 10 previous ranges are less
       .                         //than the current one
       .
    endif
    Nicolas thanked this post
    #42735 quote
    ck1066
    Participant
    Average

    Thanks Roberto I’ll try your suggestion.

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

how to find the biggest candlestick over the last 10 bars


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
ck1066 @ck1066 Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by ck1066
8 years, 6 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 08/07/2017
Status: Active
Attachments: No files
Logo Logo
Loading...