Beginner Q on CountIF - futures io
futures io



Beginner Q on CountIF


Discussion in EasyLanguage Programming

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




Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Beginner Q on CountIF

(login for full post details)
  #1 (permalink)
 Vozdovac 
IL
 
Experience: Advanced
Platform: NinjaTrader
Trading: ES
 
Posts: 19 since Aug 2011
Thanks: 13 given, 16 received

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 futures io?
Multi Time Frame High/Low/Median levels
NinjaTrader
NT8 Order Management Strategy
The Elite Circle
Anyone ever use "Seasonax" website?
Trading Reviews and Vendors
Market on Close data within IB
Platforms and Indicators
Demo accounts order fill
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Is anyone actually making money?
52 thanks
An embarrassing, honest confession
37 thanks
Sierra vs. Ninja : why I chose .....
8 thanks
Machine Learning Journal
5 thanks
Institutional Grade Massive Data Dump for Quant Research …
5 thanks
 
(login for full post details)
  #2 (permalink)
Shaban
Turin + Italy
 
 
Posts: 178 since Feb 2020
Thanks: 20 given, 108 received

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
 
(login for full post details)
  #3 (permalink)
 Vozdovac 
IL
 
Experience: Advanced
Platform: NinjaTrader
Trading: ES
 
Posts: 19 since Aug 2011
Thanks: 13 given, 16 received



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
 
(login for full post details)
  #4 (permalink)
Shaban
Turin + Italy
 
 
Posts: 178 since Feb 2020
Thanks: 20 given, 108 received

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


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Beginner Q on CountIF


Last Updated on December 29, 2022


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2023 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
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.
no new posts