Strategy for entering CCI TL break

Questions about MultiCharts and user contributed studies.
designer01
Posts: 80
Joined: 02 Feb 2010

Strategy for entering CCI TL break

Postby designer01 » 03 Sep 2011

I am trying the strategy (see code below) to enter long when the CCI crosses up thru the manually drawn Trendline. I am not sure why it is given me a delay entry. I've tried a few different times...It is entering 5 or 6 bars after breakout as shown in video playback below.
Please advice.
Thanks

Code: Select all

inputs:
TLPrice( CCI(14) );

variables:
TL_ID( 0 ),
TLVal( 0 ) ;


TL_ID = TL_GetFirst( 7 );

If TL_ID > 0 then
TLVal = TL_GetValue( TL_ID, Date, Time ) * PriceScale ;

if LastBarOnChart and
TL_ID > 0 and
TLPrice[1] < TLVal[1] and
TLPrice > TLVal then
Buy ( "TL LE" ) next bar at Market ;

if LastBarOnChart and
TL_ID > 0 and
TLPrice[1] < TLVal[1] and
TLPrice > TLVal then
Print (D, T, "Cross CCI", TLPrice, "LineVal", TLVal );
Attachments
CCI-TL-Bk.gif
(976.54 KiB) Downloaded 1410 times

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 03 Sep 2011

I am trying the strategy (see code below) to enter long when the CCI crosses up thru the manually drawn Trendline. I am not sure why it is given me a delay entry. I've tried a few different times...It is entering 5 or 6 bars after breakout as shown in video playback below.
Please advice.
Thanks

Code: Select all

inputs:
TLPrice( CCI(14) );

variables:
TL_ID( 0 ),
TLVal( 0 ) ;


TL_ID = TL_GetFirst( 7 );

If TL_ID > 0 then
TLVal = TL_GetValue( TL_ID, Date, Time ) * PriceScale ;

if LastBarOnChart and
TL_ID > 0 and
TLPrice[1] < TLVal[1] and
TLPrice > TLVal then
Buy ( "TL LE" ) next bar at Market ;

if LastBarOnChart and
TL_ID > 0 and
TLPrice[1] < TLVal[1] and
TLPrice > TLVal then
Print (D, T, "Cross CCI", TLPrice, "LineVal", TLVal );

what is your chart resolution?

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 04 Sep 2011

1 minute

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 04 Sep 2011

do you have the print out for

Code: Select all

Print (D, T, "Cross CCI", TLPrice, "LineVal", TLVal );
are the numbers correct?

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 04 Sep 2011

are the numbers correct?
the print numbers match the actual entry rather than at the location of the trendline break as shown in the video attached above.
TJ thanks for your help, can you try it on your machine to see if you get similar results?
Thanks again...

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 04 Sep 2011

are the numbers correct?
the print numbers match the actual entry rather than at the location of the trendline break as shown in the video attached above.
TJ thanks for your help, can you try it on your machine to see if you get similar results?
Thanks again...
Please try this modified code.

Code: Select all

inputs:
TLPrice( CCI(14) );

variables:
TLX(0),
TL_ID( 0 ),
TLVal( 0 ) ;


TL_ID = TL_GetFirst( 7 );

If TL_ID > 0 then
TLVal = TL_GetValue( TL_ID, Date, Time ) * PriceScale ;

if tlprice > tlval then
TLX = 1
else TLX = 0;

Print (D:0:0, T:0:0, ", TLPrice=", TLPrice, ", TLVal=", TLVal, ", ==", TLX:0:0 );


if LastBarOnChart and
TL_ID > 0 and
TLPrice[1] < TLVal[1] and
TLPrice > TLVal then
begin
Buy ( "TL LE" ) next bar at Market ;
Print (D:0:0, T:0:0, "<<== Cross CCI ==>>");
end;
You should go through the print out line by line to see if the break points are at the time and places you expected.
Please try it with a trendline at a fixed horizontal line. eg. at zero.


[edited: 20110904 1224]

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 04 Sep 2011

Thanks,
It misses a few entries but seems to have improved with the updated code.
I will try it tonight with Forex Real Time to see if that works better.
Thanks again

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 05 Sep 2011

Thanks,
It misses a few entries but seems to have improved with the updated code.
I will try it tonight with Forex Real Time to see if that works better.
Thanks again
I did not change your logic, so the result should not have changed (or improved).

I have merely moved the print statement (the audit trail),
which gives you a line-by-line read out of the variable values,
so that you can see exactly when and where the trigger was happening.

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 05 Sep 2011

I tried real time but still misses a few entries not sure why.
I also want to ad a condition... to enter when the trendilne is green, but it is not compiling for some reason, I'm sure I'm missing a statement. See code below.
Thanks again...

Code: Select all

inputs:
TLPrice( CCI(14) ),
TLColor( GREEN );

variables:
TL_ID( 0 ),
TLVal( 0 ) ;


TL_ID = TL_GetFirst( 7 );

If TL_ID > 0 then
TLVal = TL_GetValue( TL_ID, Date, Time ) * PriceScale ;

Print (D, T:0:0, (", TLPrice=" + symbol), TLPrice, ", TLVal=", TLVal ); //<--- add this line

if LastBarOnChart and TL_GetColor = TLColor and
TL_ID > 0 and
TLPrice[1] < TLVal[1] and
TLPrice > TLVal then
begin
Buy ( "TL LE" ) next bar at Market ;
Print (D, T, ( "Cross CCI thru-->" + symbol));
end

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 05 Sep 2011

I tried real time but still misses a few entries not sure why.
I also want to ad a condition... to enter when the trendilne is green, but it is not compiling for some reason, I'm sure I'm missing a statement. See code below.
Thanks again...
...
before we go any further,
you have to post the audit trail print out, a screen shot, and the execution log.
I will not be looking at your additional code until I have got the current problem pinpointed.

What are you testing this on?
Are you trading this live? on a papertrading account? or on a demo system?

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 05 Sep 2011

TJ,
Attached below is the screenshot of the entry and the output trail... As you can see the TL-LE Entry was triggered 3 bars before the CCI crossed the Trendline, this is constantly happening. Also constantly happening is the trigger a few bars after the trendline as in the video shot attached above.
I am not sure how to get the execution log, I gues you mean from the broker...I am not trading this on any real or paper account or broker yet. I only let the strategy run either on Playback mode on the charts over the weekend or realtime today and lastnight.
In both cases I had the same problem. Thanks
Attachments
TL-Error.jpg
(491.94 KiB) Downloaded 1395 times

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 05 Sep 2011

TJ,
Attached below is the screenshot of the entry and the output trail... As you can see the TL-LE Entry was triggered 3 bars before the CCI crossed the Trendline, this is constantly happening. Also constantly happening is the trigger a few bars after the trendline as in the video shot attached above.
I am not sure how to get the execution log, I gues you mean from the broker...I am not trading this on any real or paper account or broker yet. I only let the strategy run either on Playback mode on the charts over the weekend or realtime today and lastnight.
In both cases I had the same problem. Thanks
1. Please test this on a HORIZONTAL LINE at ZERO (double click on the line, set both ends to zero).

2. Please use the code I posted (note edited on 20110904 1224)

3. I do not need to see the whole chart. Please select one example and enlarge the order area of the chart, so that I can examine it bar-by-bar. Please highlight the corresponding audit trail trigger lines.

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 05 Sep 2011

1- Trndline is at 0.
2- Code used as posted (note edited on 20110904 1224)
3- Attached screenshot as requested
Attachments
TL-Error.jpg
(478.03 KiB) Downloaded 1393 times

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 05 Sep 2011

1- Trndline is at 0.
2- Code used as posted (note edited on 20110904 1224)
3- Attached screenshot as requested
I see impeccable timing.

Can you identify the error you see?
can you describe it bar-by-bar (with time stamp reference)?


Please see my notes on attached chart.
Attachments
cci trendline.jpg
(255.21 KiB) Downloaded 1403 times

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 05 Sep 2011

ps.

I see other audit trails in the list.
are you running multiple strategies in the chart?

For debugging purposes, you should remove all the other charts/indicators from your testing environment so that you can concentrate on finding the error.

pps. the code you use is not the 20110904 1224 edition. The logic is the same, I have changed the presentation so that it is easier to spot the cross over.

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 05 Sep 2011

TJ,
Thanks, Sorry about that, I am using this code this time...

Code: Select all

inputs:
TLPrice( CCI(14) );

variables:
TLX(0),
TL_ID( 0 ),
TLVal( 0 ) ;


TL_ID = TL_GetFirst( 7 );

If TL_ID > 0 then
TLVal = TL_GetValue( TL_ID, Date, Time ) * PriceScale ;

if tlprice > tlval then
TLX = 1
else TLX = 0;

Print (D:0:0, T:0:0, ", TLPrice=", TLPrice, ", TLVal=", TLVal, ", ==", TLX:0:0 );


if LastBarOnChart and
TL_ID > 0 and
TLPrice[1] < TLVal[1] and
TLPrice > TLVal then
begin
Buy ( "TL LE" ) next bar at Market ;
Print (D:0:0, T:0:0, "<<== Cross CCI ==>>");
end;
As you can see in the attachments, it works fine when the trendline is at zero but when the trendline is located somewhere else it does not work. See the TLVal numbers in the Output seem somewhat strenge.
Thanks again...
Attachments
TL-Error-Early-trigger.jpg
(671.61 KiB) Downloaded 1388 times

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 05 Sep 2011

PS Screenshot with line at zero...
Attachments
TL-Error-TL-at-Zero.jpg
(484.67 KiB) Downloaded 1392 times

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 05 Sep 2011

TJ,
Thanks, Sorry about that, I am using this code this time...
..
As you can see in the attachments, it works fine when the trendline is at zero but when the trendline is located somewhere else it does not work. See the TLVal numbers in the Output seem somewhat strenge.
Thanks again...
Please test it with another horizontal line,
say, at 10.

The idea is to make sure the horizontal line works,
the next step is to find out why a slanted line does not work.

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 05 Sep 2011

What instrument you are trading?
Please check your PriceScale.

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 06 Sep 2011

I am trading Forex EURUSD, AUDUSD, AUDJPY..
Attached find screenshot of the Scaling settings
Attachments
Scaling.jpg
(70.15 KiB) Downloaded 1383 times

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 06 Sep 2011

I am trading Forex EURUSD, AUDUSD, AUDJPY..
Attached find screenshot of the Scaling settings
The PriceScale is set in the QuoteManager:

1. right click on the symbol
2. select Edit Symbol
3. under Settings tab, select Price Scale.

Please check with your broker for the proper price scale setting for each symbol.

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 06 Sep 2011

It varies for AUDJPY is 1/1000
I am not using a broker as I said before it is only chart trading right now.
Data is from TS.
By the way I am using the same code on TS and works fine...
So there must be a Multicharts Chart or Platform Setting I need to change.
Is there a specialist from Multicharts that can connect remotelly to my machine to look at it so we do not keep going back and forth troubleshooting with no end in sight?
Thanks again TJ.

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 06 Sep 2011

It varies for AUDJPY is 1/1000
I am not using a broker as I said before it is only chart trading right now.
Data is from TS.
By the way I am using the same code on TS and works fine...
So there must be a Multicharts Chart or Platform Setting I need to change.
Is there a specialist from Multicharts that can connect remotelly to my machine to look at it so we do not keep going back and forth troubleshooting with no end in sight?
Thanks again TJ.
see post #18



ps. I know where the problem is, and I know the solution. I just want to take you through the debugging process, so that you can be independent in the future. If you had followed my suggestions, you would have found the solution in 3 posts.

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 06 Sep 2011

Sorry about that ... debugging has never really been my forte.. Do you have in the website instructions as to how to debug a strategy?
Attached find screenshot as requested. Looks like the trendline value "TLVal" is off for some reason, and obviously never crossed thru...Really don't know the solution though. Although I did mention earlier that the "TLVal" values were kind of strange if you read above.
Thanks again.
Attachments
TL-Error-TL-at-10.jpg
(359.76 KiB) Downloaded 1386 times

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 06 Sep 2011

Sorry about that ... debugging has never really been my forte.. Do you have in the website instructions as to how to debug a strategy?
Attached find screenshot as requested. Looks like the trendline value "TLVal" is off for some reason, and obviously never crossed thru...Really don't know the solution though. Although I did mention earlier that the "TLVal" values were kind of strange if you read above.
Thanks again.
You have drawn the trendline at 10, but the TVAL in the audit trail was 1000.

ie. something has modified your trendline.

if you go back to your code, you will see that TVAL was multiplied by the PRICESCALE.
TLVal = TL_GetValue( TL_ID, Date, Time ) * PriceScale;
if you remove the * PriceScale from the code, you should be good to go.

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 06 Sep 2011

Or I can change the pricescale to 1?
What does the PriceScale reffer to?
Do you have in the website instructions as to how to debug a strategy?

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 06 Sep 2011

Or I can change the pricescale to 1?
What does the PriceScale reffer to?
Do you have in the website instructions as to how to debug a strategy?
Do not change the PriceScale, it is a set value for each instrument. It is not broker specific, but they can provide the value for you.

Here's some reading material on debugging:
http://www.google.ca/search?rlz=1C1AVSX ... n+to+debug

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 06 Sep 2011

Thanks,
When I removed the * PriceScale from code I get this error...

------ Compiled with error(s): ------
Compile error
errLine 0, errColumn 0, errLineEnd 0, errColumnEnd 0
causal study: (Function)

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 06 Sep 2011

Thanks,
When I removed the * PriceScale from code I get this error...

------ Compiled with error(s): ------
Compile error
errLine 0, errColumn 0, errLineEnd 0, errColumnEnd 0
causal study: (Function)
Did you remove the semicolon at the end?

I would suggest that you start with this ebook:
Getting Started with EasyLanguage is the book you need if you're thinking about using EasyLanguage but don't know where to start.
https://www.multicharts.com/multicharts ... mentation/

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 06 Sep 2011

I did read the book you mention ...but there it says you are supposed to have the semicolon at the end...
I think there is a problem with the Multicharts Platform, The very same code works perfect in TS...

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 06 Sep 2011

I did read the book you mention ...but there it says you are supposed to have the semicolon at the end...
I think there is a problem with the Multicharts Platform, The very same code works perfect in TS...
I meant you are supposed to have the semicolon at the end.
There must be something else in your code that is altered (or you are using a different code for testing).

How did you use the code in TS? applied the same strategy/indicators and drawn trendline to the same subchart?

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 06 Sep 2011

TJ,
I used the same instrument, same indicator, same subgraph...
Have you tried this strategy on your Multicharts machine? if not please try it and tell me if it works as expected.

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 06 Sep 2011

TJ,
I used the same instrument, same indicator, same subgraph...
Have you tried this strategy on your Multicharts machine? if not please try it and tell me if it works as expected.
see attached.

note:
you do not see <<== Cross CCI ==>> in the audit trail because it was not Lastbaronchart.
Attachments
2011-09-06 14.1402.jpg
(202.32 KiB) Downloaded 1394 times

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 06 Sep 2011

Thanks,
When I removed the * PriceScale from code I get this error...

------ Compiled with error(s): ------
Compile error
errLine 0, errColumn 0, errLineEnd 0, errColumnEnd 0
causal study: (Function)
If you need help with coding,
Please post the code that caused this error.



ps. this is a coding error, not a MultiCharts error.

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 06 Sep 2011

1. We have established that the code works when the trendline is at zero.
ie. MultiCharts is capable of performing such kind of task.

2. Next, we have established that the calculation of TVAL is at error when the trendline is set to 10.
ie. this is a formula error.

3. there is only one thing left to do -- correct the formula.
ie. the performance (or the lack of) has nothing to do with MultiCharts.

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 06 Sep 2011

On your screenshot the strategy did not actually cause any entry long, that is one of the problems I am having with Multicharts. It misses it sometimes.
Can you do one where you actually enter long on your platform?

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 06 Sep 2011

On your screenshot the strategy did not actually cause any entry long, that is one of the problems I am having with Multicharts. It misses it sometimes.
Can you do one where you actually enter long on your platform?
see my note at the post above:
you do not see <<== Cross CCI ==>> in the audit trail because it was not Lastbaronchart.


the buy order did not execute because your code specified that BUY only if this is the Lastbaronchart.

I applied the strategy AFTER the cci has crossed the trendline. ie it was not lastbaronchart when the lines crossed, thus no buy order or print out in the audit trail.


ps. this has nothing to do with the compile error you are complaining about.


Anyway, I am satisfied that you do not have a problem, and that MultiCharts do not have a problem. If you have finished the first ebook, I would suggest that you attempt the next ebook in the support page.

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 06 Sep 2011

see my note at the post above:
you do not see <<== Cross CCI ==>> in the audit trail because it was not Lastbaronchart.
I realize it's Lastbaronchart ...you have to do it realtime or do it with the Multicharts Playback mode so you can see the order being triggered as it plays back. Please try it in Playback mode by jumping just a bit before where the trendline is...then play..

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Strategy for entering CCI TL break

Postby TJ » 06 Sep 2011

see my note at the post above:
you do not see <<== Cross CCI ==>> in the audit trail because it was not Lastbaronchart.
I realize it's Lastbaronchart ...you have to do it realtime or do it with the Multicharts Playback mode so you can see the order being triggered as it plays back. Please try it in Playback mode by jumping just a bit before where the trendline is...then play..
I am leaving for The Bahamas in a few minutes,
I will look at it when I return in a few days.

Enjoy.

designer01
Posts: 80
Joined: 02 Feb 2010

Re: Strategy for entering CCI TL break

Postby designer01 » 06 Sep 2011

TJ,
Thanks for your help.
Have a good trip.
Think about the LastBarOnChart while laying on the sun...


Return to “MultiCharts”