Announcement

Collapse
No announcement yet.

Long-Short Ratio

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Long-Short Ratio

    Hello,

    I'm looking for the possibility to count the numbers of the last 30 Candlesticks, how much is it rising, falling or unchanged? The result (15 rising - 10 falling - 5 unchanged) should be indicated to realtime in the 5 minutes Chart?

    Thank you for your assistance in advance.

  • #2
    Rodondo
    You will need an efs to do that. In the script first declare three local variables (ie inside of function main) which you will use as the counters

    PHP Code:
    var CntrUP 0;
    var 
    CntrDN 0;
    var 
    CntrUNCH 0
    After that you run a for loop that looks back the desired number of bars (in this case 30 as per your example), verifies each condition and increments the appropriate counter if the condition returns true

    PHP Code:
    if(getBarState()==BARSTATE_NEWBAR){
        for(var 
    i=1i<=30i++){
            if(
    close(-i)>close(-(i+1))) CntrUP++;
            if(
    close(-i)<close(-(i+1))) CntrDN++;
            if(
    close(-i)==close(-(i+1))) CntrUNCH++;
        }

    You can then use the variables CntrUP, CntrDN and CntrUNCH in the return statement or to write the totals to the chart.
    Alex

    Comment


    • #3
      Hello Alex,
      thanks a lot for your very quickly answer.
      Do I need for the efs the GET Studies? If yes I don't have it.

      Kind regards
      Rodondo

      Comment


      • #4
        Rodondo
        You do not need the AdvancedGET Studies to run an EFS unless this is using specific AdvancedGET functions or studies.
        Alex

        Comment

        Working...
        X