NexusFi: Find Your Edge


Home Menu

 





Beginner Q on CountIF


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,170 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Beginner Q on CountIF

  #1 (permalink)
 Vozdovac 
IL
 
Experience: Advanced
Platform: NinjaTrader
Trading: ES
Posts: 19 since Aug 2011
Thanks Given: 13
Thanks Received: 16

Hi guys,

I'm a beginner with EasyLanguage and I'm simply trying to get a count of the number of Closes above a moving average. Here is the code I have but keep getting an error. Any tips would be appreciated! I believe it has something to do with parenthesis.





Var: Lbkperiod (0);

Value1= CountIF(Close > average(close, lbkperiod));

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
ZombieSqueeze
Platforms and Indicators
Exit Strategy
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

I think it could be so (of course with: Lbkperiod you can choose the preferred value):


Inputs: Lbkperiod( 9 );


Value1= CountIF(Close > average(close, Lbkperiod));

Reply With Quote
  #3 (permalink)
 Vozdovac 
IL
 
Experience: Advanced
Platform: NinjaTrader
Trading: ES
Posts: 19 since Aug 2011
Thanks Given: 13
Thanks Received: 16



Shaban View Post
I think it could be so (of course with: Lbkperiod you can choose the preferred value):


Inputs: Lbkperiod( 9 );


Value1= CountIF(Close > average(close, Lbkperiod));




That's what I had and the error codes I get are:

-',' or')'
-More inputs expected here

Started this thread Reply With Quote
  #4 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

This is the CountIF Function explained by Tradestation:


CountIF (Function)


The CountIF function counts the number of true custom test condition occurrences over some number of bars.

The CountIF function can be used for data mining and testing historical statistical market action. For example, you can ask questions such as, "How many days over the last month have been up days with falling volume, and on the following day how many days were up or down?"
Syntax

CountIF(Test,Length)
Returns (Integer)

The number of true test condition occurrences.
Parameters

Name | Type | Description

Test | TrueFalse | Specifies a bar or indicator condition (True/False expression) that must be TRUE.

Length | Numeric | Sets the number of bars to consider for testing the condition.

Remarks

The input parameters Test can be any bar or multi-data Condition such as Close > Open, High[1] < High[2], Close of Data1 – Close of data2 > 0, or Volume >= 100000. They can also be any mathematical calculation such as High + Low) / 2 > Average(TrueRange,10), or a numeric indicator function such as RSI(C,14) < 30, or ADX(C,14) > 25. It can also be another True/False function.

True/False conditions must contain one of the following operators: =, >=, <=, >, <, <>, crosses above, or crosses below. You can also test multiple conditions in one expression using: OR, and AND. Use parentheses (())to group conditions logically.

The value for the Length input parameter should always be a positive whole number greater than 0.
Examples

Assigns the number of bars where the close is greater than open for the last 12 bars to Value1, then plots Value1:

Value1 = CountIF(Close > Open, 12);

Plot1(Value1, "C > O");

Assigns to Value1 the number of bars where the close is greater than the close of one bar ago, and the volume is greater than the volume of one bar ago, for the last 24 bars, then plots Value1:

Value1 = CountIF(Close > Close[1] AND Volume > Volume[1], 24);

Plot1(Value1, "C+V+");


------------------------------------------------------------

So, not knowing the code that you set up, it might look like this (I put in a random number that you can change)

Inputs: Lbkperiod( 9 );


Value1= CountIF(Close > average(close, Lbkperiod),10);

Reply With Quote




Last Updated on December 29, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts