NexusFi: Find Your Edge


Home Menu

 





Confused about "Currentbar", using Ichimoku Cloud


Discussion in EasyLanguage Programming

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




 
Search this Thread

Confused about "Currentbar", using Ichimoku Cloud

  #1 (permalink)
WPITrader
Boston
 
Posts: 5 since Mar 2015
Thanks Given: 0
Thanks Received: 0

Hi all,

I'm new to the forum, and have joined because I am a college student working on a year long junior project that involves developing an automated trading system. Everything that I have learned in regards to EasyLanguage is self taught, and i've found that some of the syntax can be kind of difficult.

So to get down to my question:
It may seem very amateur, but I can assure that I have really looked in a lot of different corners of the internet for this answer, but it is still unclear to me. I am creating a strategy program that involves the Ichimoku Cloud indicator. Simply put, when certain lines of the indicator cross above or below other certain lines, it will give me a long or short signal. Whether or not I take the position is determined on whether the indication holds true for a certain amount of bars. I thought that this can be done by using "Currentbar > (number of bars to meet condition)". The number that is put will be the number of closed bars that are needed to confirm the indicator, after the initial crossing of the Ichimoku lines, and enter a position.
ex: If Currentbar > 3 and Close[Chikou_Offset] > TopOfCloud and Close[Chikou_Offset] > BottomOfCloud then
Buy next bar at market
With this code, I am trying to take a long position if the Chikou_Offset line crosses above both lines of the cloud and stays like that for 3 bars after the initial cross.

I am not sure if I am using this function the right way, but I am having a lot of trouble with my strategy code not entering the market a certain number of bars after the initial signal, confirming the signal. If anyone could give me some pointer or tips on this particular subject I would be very grateful. I feel like this is simple, but yet It just isn't working like I need it to. Thank you very much in advanced.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
MC PL editor upgrade
MultiCharts
Better Renko Gaps
The Elite Circle
 
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
25 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
  #3 (permalink)
 
Hulk's Avatar
 Hulk 
Texas, USA
 
Experience: Advanced
Platform: TT, Custom
Trading: Futures, Spreads
Posts: 369 since May 2014
Thanks Given: 731
Thanks Received: 901



WPITrader View Post
Whether or not I take the position is determined on whether the indication holds true for a certain amount of bars. I thought that this can be done by using "Currentbar > (number of bars to meet condition)". The number that is put will be the number of closed bars that are needed to confirm the indicator, after the initial crossing of the Ichimoku lines, and enter a position.
ex: If Currentbar > 3 and Close[Chikou_Offset] > TopOfCloud and Close[Chikou_Offset] > BottomOfCloud then
Buy next bar at market
With this code, I am trying to take a long position if the Chikou_Offset line crosses above both lines of the cloud and stays like that for 3 bars after the initial cross.

Option 1: Store your condition true bar number in a variable:

 
Code
Vars:
    LongConditionBarNumber(0);

...

If (LongConditionBarNumber = 0 and Close[Chikou_Offset] > TopOfCloud and Close[Chikou_Offset] > BottomOfCloud) then
    LongConditionBarNumber = BarNumber
Else
    LongConditionBarNumber = 0;

if (LongConditionBarNumber > 0 and BarNumber-LongConditionBarNumber > 3) then begin
    Buy Next Bar at Market;
    LongConditionBarNumber = 0;
end;

Option 2: Look back on the entire condition
 
Code
Vars:
    BarsToWait(3);

...

If (Close[Chikou_Offset+BarsToWait] > TopOfCloud[BarsToWait] and Close[Chikou_Offset+BarsToWait] > BottomOfCloud[BarsToWait]) then
    Buy Next Bar at Market;

Option 3: Store true/false condition in a boolean variable
 
Code
Vars:
    LongCondition(False);

...

LongCondition =  Close[Chikou_Offset] > TopOfCloud and Close[Chikou_Offset] > BottomOfCloud);

if (LongCondition[3]) then begin
    Buy Next Bar at Market;
    LongCondition = False;
end;
I havent verified any of this code so there might be syntax errors but this should be good enough to give you a general idea about how you can approach your problem.

Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
WPITrader
Boston
 
Posts: 5 since Mar 2015
Thanks Given: 0
Thanks Received: 0

Thanks a ton Hulk. I am currently trying out option 3. Do you think there is a specific benefit to each, or one in particular? Or do they all do the same thing?

Thank you again.

Reply With Quote
  #5 (permalink)
WPITrader
Boston
 
Posts: 5 since Mar 2015
Thanks Given: 0
Thanks Received: 0


Hulk View Post
Option 1: Store your condition true bar number in a variable:

 
Code
Vars:
    LongConditionBarNumber(0);

...

If (LongConditionBarNumber = 0 and Close[Chikou_Offset] > TopOfCloud and Close[Chikou_Offset] > BottomOfCloud) then
    LongConditionBarNumber = BarNumber
Else
    LongConditionBarNumber = 0;

if (LongConditionBarNumber > 0 and BarNumber-LongConditionBarNumber > 3) then begin
    Buy Next Bar at Market;
    LongConditionBarNumber = 0;
end;

Option 2: Look back on the entire condition
 
Code
Vars:
    BarsToWait(3);

...

If (Close[Chikou_Offset+BarsToWait] > TopOfCloud[BarsToWait] and Close[Chikou_Offset+BarsToWait] > BottomOfCloud[BarsToWait]) then
    Buy Next Bar at Market;

Option 3: Store true/false condition in a boolean variable
 
Code
Vars:
    LongCondition(False);

...

LongCondition =  Close[Chikou_Offset] > TopOfCloud and Close[Chikou_Offset] > BottomOfCloud);

if (LongCondition[3]) then begin
    Buy Next Bar at Market;
    LongCondition = False;
end;
I havent verified any of this code so there might be syntax errors but this should be good enough to give you a general idea about how you can approach your problem.

So after trying all three, the 2nd one has been able to generate orders. The 1st and 3rd when put in did make any order entries, and I'm still trying to figure out why.

As for the second one, it works! A problem I am running into though is that both the buy and sell signals are being generated in the same bar. I guess I need the variable to reset after an order has been made and a position is take? I did already go to rightclick > Format strategies > select my strategy and format > and I don't have intrabar trading enabled.
Any ideas?
Thanks

EDIT:
One thing that I have been thinking about is whether I am getting trouble from the line I am referring to for an indication. The "Chikou" line is the close of the current price offset 26 days in the past, for those who aren't familiar with Ichi Clous. Since this line is offset in the past, does the coding change? I am getting entries and exits in really odd places. The entries are places where it is perfectly apparent that the conditions haven't been met.

Reply With Quote
  #6 (permalink)
 
Hulk's Avatar
 Hulk 
Texas, USA
 
Experience: Advanced
Platform: TT, Custom
Trading: Futures, Spreads
Posts: 369 since May 2014
Thanks Given: 731
Thanks Received: 901


WPITrader View Post
So after trying all three, the 2nd one has been able to generate orders. The 1st and 3rd when put in did make any order entries, and I'm still trying to figure out why.

I was just trying to show you different ways of programming checks for conditions that were true a few bars ago. If any one works for you, just use that.


WPITrader View Post
As for the second one, it works! A problem I am running into though is that both the buy and sell signals are being generated in the same bar. I guess I need the variable to reset after an order has been made and a position is take? I did already go to rightclick > Format strategies > select my strategy and format > and I don't have intrabar trading enabled.
Any ideas?
Thanks

It does not look like it has anything to do with intrabarordergeneration (IIOG). Probably has to do with both long and short conditions being true at the same time.


WPITrader View Post

EDIT:
One thing that I have been thinking about is whether I am getting trouble from the line I am referring to for an indication. The "Chikou" line is the close of the current price offset 26 days in the past, for those who aren't familiar with Ichi Clous. Since this line is offset in the past, does the coding change? I am getting entries and exits in really odd places. The entries are places where it is perfectly apparent that the conditions haven't been met.

Sorry, I havent the slightest clue what a "Chikou" or an "Ichi Clous" is. I can give you pointers on programming related stuff but you are on your own as far as your strategy is concerned.

Visit my NexusFi Trade Journal Reply With Quote
  #7 (permalink)
WPITrader
Boston
 
Posts: 5 since Mar 2015
Thanks Given: 0
Thanks Received: 0


Hulk View Post
I was just trying to show you different ways of programming checks for conditions that were true a few bars ago. If any one works for you, just use that.


It does not look like it has anything to do with intrabarordergeneration (IIOG). Probably has to do with both long and short conditions being true at the same time.



Sorry, I havent the slightest clue what a "Chikou" or an "Ichi Clous" is. I can give you pointers on programming related stuff but you are on your own as far as your strategy is concerned.

Oh ok. well so far 2 out the 3 work. I do understand the syntax you are using though, very helpful, and it's logic I haven't thought of yet.

As far as the Chikou, and I misspelled, "Ichi Cloud"(not clous), It's ok. Ichimokou Cloud is the type analysis I'm using.

For the "Chikou" , or in English, "lagging", this is a lagging line, that plots the close of the current price, 26 bars back. So forgetting about the type of analysis it is for a sec, if I was to make a buy and sell signal based off of a line that is plotted 26 bars behind the current bar, what would be my coding to refer to this offset line, and check if it has satisfied a condition?
Thanks

Reply With Quote
  #8 (permalink)
 
Hulk's Avatar
 Hulk 
Texas, USA
 
Experience: Advanced
Platform: TT, Custom
Trading: Futures, Spreads
Posts: 369 since May 2014
Thanks Given: 731
Thanks Received: 901


WPITrader View Post
if I was to make a buy and sell signal based off of a line that is plotted 26 bars behind the current bar, what would be my coding to refer to this offset line, and check if it has satisfied a condition?
Thanks

Try to store the conditions in true/false variables and then check if those variables are true or false to enter a position. If you want to check if those conditions were true 3 bars ago, you can check that using "[3]" suffixed to the variable name or "[26]" suffixed if you were checking for the condition 26 bars ago.

Use the print statement to print the values of the variables for each bar, this is one way of "debugging" in EL (unless they allow actual breakpoints now, I dont know) that I have used extensively to troubleshoot. The sample below prints the bar date/time first and then whatever variable values you want separated by the pipe "|" symbol.

 
Code
	Print(Bardatetime[0].ToString(), " | ", Variable1, " | ", Variable2, " | ", ...);

Visit my NexusFi Trade Journal Reply With Quote
  #9 (permalink)
WPITrader
Boston
 
Posts: 5 since Mar 2015
Thanks Given: 0
Thanks Received: 0


Hulk View Post
Try to store the conditions in true/false variables and then check if those variables are true or false to enter a position. If you want to check if those conditions were true 3 bars ago, you can check that using "[3]" suffixed to the variable name or "[26]" suffixed if you were checking for the condition 26 bars ago.

Use the print statement to print the values of the variables for each bar, this is one way of "debugging" in EL (unless they allow actual breakpoints now, I dont know) that I have used extensively to troubleshoot. The sample below prints the bar date/time first and then whatever variable values you want separated by the pipe "|" symbol.

 
Code
	Print(Bardatetime[0].ToString(), " | ", Variable1, " | ", Variable2, " | ", ...);



sorry it's taken me a little a while to respond.

For that print statement, do I have to make a new variable for the "Bardatetime", or should I put in the bar, date and time I want to check? and in what format? The only reason I ask is because when I copy in the code, I replace the "Variable1" and "Variable2" with the actual variable names, but it says that it doesn't recognize "Bardatetime", and is an unknown variable.

for the offset line I'm trying to reference for my entries, I want to make a decision based off the current close if it was 26 bars back. I was having a problem with using the [26], because it would reference the close 26 days ago, not the current close 26 bars back. I'm not sure if this makes sense, but any help is much appreciated.

Thanks a lot!

Reply With Quote
  #10 (permalink)
 
Hulk's Avatar
 Hulk 
Texas, USA
 
Experience: Advanced
Platform: TT, Custom
Trading: Futures, Spreads
Posts: 369 since May 2014
Thanks Given: 731
Thanks Received: 901



WPITrader View Post
For that print statement, do I have to make a new variable for the "Bardatetime", or should I put in the bar, date and time I want to check? and in what format? The only reason I ask is because when I copy in the code, I replace the "Variable1" and "Variable2" with the actual variable names, but it says that it doesn't recognize "Bardatetime", and is an unknown variable.

You must have an older version of tradestation. You should be able to use "Date" and "Time" keywords to print out Date and Time of the bar. Refer to the built in help for formatting syntax.


WPITrader View Post
for the offset line I'm trying to reference for my entries, I want to make a decision based off the current close if it was 26 bars back. I was having a problem with using the [26], because it would reference the close 26 days ago, not the current close 26 bars back. I'm not sure if this makes sense, but any help is much appreciated.

In general, variables in EasyLanguage are arrays. Using the [index] notation allows you to refer values calculated that many bars ago. Your best bet is to use the print function and debug this.

Visit my NexusFi Trade Journal Reply With Quote




Last Updated on April 1, 2015


© 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