Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 01-09-2010, 05:55 AM   #1
aaa

aaa's Avatar

Join Date: Jun 2008
Location: Switzerland
Posts: 443
Ignore this user

Thanks: 240
Thanked 283 Times in 136 Posts

AB = Plot StyleCloud on MA Ribbon

I've adapted MA Ribbon from EL 2 AB

http://www.traderslaboratory.com/for...html#post78174

How 2 plot a cloud between the 2 avgs and change color area when avg crosses ??

Here is my preliminary code

Code:
Plot(C,"Price",colorBlack,styleCandle);
	
Periods      = Param("Periods",      30, 2, 200, 1, 0 );
Displacement = Param("Displacement", 30, -150, 150 );

Plot( EMA( c, Periods ), "", 
	ParamColor( "ColorMM", colorBlue ), 
	ParamStyle( "StyleMM") | styleThick | styleNoRescale ); 

Plot( EMA( c, Periods ), "" , 
	ParamColor( "Color Delay", colorWhite ), 
	ParamStyle( "Style Delay") | styleNoRescale | styleNoLabel, Null, Null, Displacement  );
I've found this from ICHIMOKU

The problem is where 2 put Displacement ?

PlotOHLC(Span1,Span1,Span 2,Span2,"Cloud",colorWhit e ,styleCloud );

Attached Thumbnails
AB = Plot StyleCloud on MA Ribbon-snap1.jpg  

Last edited by aaa; 01-09-2010 at 06:10 AM.
aaa is offline  
Reply With Quote
The Following User Says Thank You to aaa For This Useful Post:
Tams (01-09-2010)
Old 01-09-2010, 08:51 AM   #2

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: AB = Plot StyleCloud on MA Ribbon

that's a nice looking chart...
__________________



Only an idiot would reply to a stupid post
Tams is offline  
Reply With Quote
The Following User Says Thank You to Tams For This Useful Post:
aaa (01-10-2010)
Old 01-09-2010, 09:46 AM   #3
aaa

aaa's Avatar

Join Date: Jun 2008
Location: Switzerland
Posts: 443
Ignore this user

Thanks: 240
Thanked 283 Times in 136 Posts

Re: AB = Plot StyleCloud on MA Ribbon

Hi Tams

I shouls have precised that it's a snapshot from the Xcellent help...

It was 2 illustrate the ICHIMOKU stylecloud which is similar than your MA Ribbon

PlotOHLC(Span1,Span1,Span 2,Span2,"Cloud",colorWhit e ,styleCloud );

Oups....
aaa is offline  
Reply With Quote
Old 01-09-2010, 10:23 AM   #4

Head2k's Avatar

Join Date: Jul 2008
Location: N/A
Posts: 313
Ignore this user

Thanks: 140
Thanked 290 Times in 129 Posts

Re: AB = Plot StyleCloud on MA Ribbon

Use Ref function for displacement.

Plot( Ref( EMA( c, Periods ), Displacement), ...

Negative displacement moves the average in the past, positive displacement in the future.

Anyway, the whole code would be as follows:

Code:
Plot(C,"Price",colorBlack,styleCandle);
	
Periods      = Param("Periods",      30, 2, 200, 1 );
Displacement = Param("Displacement", 15, 0, 150, 1 );

EMAactual = EMA( c, Periods );
EMAdisp = Ref( EMA( c, Periods ), -Displacement);

Color = IIf( EMAactual > EMAdisp, colorGreen, colorRed);

PlotOHLC( EMAdisp , EMAactual, EMAdisp, EMAactual, "Cloud", Color, styleCloud);
Quote:
Originally Posted by Tams »
that's a nice looking chart...
I admire people who can trade off flying carpets.
Head2k is offline  
Reply With Quote
The Following User Says Thank You to Head2k For This Useful Post:
aaa (01-10-2010)
Old 01-09-2010, 10:43 AM   #5

Head2k's Avatar

Join Date: Jul 2008
Location: N/A
Posts: 313
Ignore this user

Thanks: 140
Thanked 290 Times in 129 Posts

Re: AB = Plot StyleCloud on MA Ribbon

Quote:
Originally Posted by Head2k »
Negative displacement moves the average in the past, positive displacement in the future.
Sorry, actually it is the other way around. Negative displacement moves the past data into the future and positive displacement moves the future data into the past.
So with positive displacement you refer to future data which are not known in the actual moment, and that won't work in real time usage and it can screw up your back test.

That's why I allowed only for negative displacement in the code.
Head2k is offline  
Reply With Quote
The Following User Says Thank You to Head2k For This Useful Post:
aaa (01-10-2010)
Old 01-09-2010, 03:59 PM   #6
aaa

aaa's Avatar

Join Date: Jun 2008
Location: Switzerland
Posts: 443
Ignore this user

Thanks: 240
Thanked 283 Times in 136 Posts

Re: AB = Plot StyleCloud on MA Ribbon

Hi Head2K

ThanX again 4 your help

Ref( formula ); is the key of the magic carpet 2 make it flying

Now 3 questions for a champion
------------------------------------------------

about else

ColorBuble =
IIf( Condition1, Color1,
IIf( Condition2, Color2,
IIf( Condition3, Color3,
IIf( Condition4, Color4,
ElseColor )))) ;

For each condition we must add a ) at the end
In this case I don't need the elseColor

But it works fine

Is there an other smartest way ?

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


Quote:
Negative displacement moves the average in the past, positive displacement in the future.
I've seen that the colors is 1 bar late than normally

How 2 avoid that ?

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

I don't arrive to change the color of an avg when it changes trend

EL

if avg > avg[1] then
SetPlotColor[1](1, Line.upcolor);
else
SetPlotColor[1](1, Line.dncolor);

AFL

IIf( EMAactual < EMAactual[1] , colorYellow, colorBlue);

The problem is the [1] I think
aaa is offline  
Reply With Quote
Old 01-09-2010, 04:09 PM   #7
aaa

aaa's Avatar

Join Date: Jun 2008
Location: Switzerland
Posts: 443
Ignore this user

Thanks: 240
Thanked 283 Times in 136 Posts

Re: AB = Plot StyleCloud on MA Ribbon

I'm surprised to arrive to transpose "easily" code from EasyLanguage 2 AFL

I thought C is complicate but, for easy indicators I use, it is OK

May B AFL is the "EasyCLanguage" ?

Last edited by aaa; 01-09-2010 at 04:25 PM.
aaa is offline  
Reply With Quote
Old 01-09-2010, 05:21 PM   #8

Head2k's Avatar

Join Date: Jul 2008
Location: N/A
Posts: 313
Ignore this user

Thanks: 140
Thanked 290 Times in 129 Posts

Re: AB = Plot StyleCloud on MA Ribbon

To the 1st question:
If you want the color to change in a discrete manner you can list the conditions just like you did.
If you want the color change continuously over the color spectrum, or if you can join your descrete conditions into a mathematical function, then you can use this function to define the color.
Then you can use ColorRGB function (find it in AFL help) to change the color. So you need to convert your conditions into mathematical functions which output values between 0 and 255 for red, green and blue.

To the 2nd question:
The color change doesn't happen late. If you zoom in you can see that the two averages cross usually somewhere in between of two bars. The color is defined by relation of the two averages at the last bar. Then the averages cross, but before the next bar is reached the color remains the same. Once the next bar is reached, the relation between the averages is re-examined and the color changes at that bar.
AmiBroker can't change color somewhere between bars, only at a bar.

To the 3rd question
IIf( EMAactual < EMAactual[1] , colorYellow, colorBlue);
This will always return colorBlue, because you compare EMAactual to EMAactual, that is two same numbers. So the expression in the condition is always false.

Quote:
Originally Posted by aaa »
I'm surprised to arrive to transpose "easily" code from EasyLanguage 2 AFL

I thought C is complicate but, for easy indicators I use, it is OK

May B AFL is the "EasyCLanguage" ?
I can't judge this. I am not a programmer and I never learned C. I've learned just AFL from AmiBroker help.
When I was a 10 years old child I used to learn TurboPascal which was kind of an educational programing language, so I had an idea about what a loop is and so on. So the only thing I can say is that AFL is probably easy, because if one has some elementary knowledge of programing languages principles, then he/she can learn it very well only from the help included in AB.
Head2k is offline  
Reply With Quote
The Following User Says Thank You to Head2k For This Useful Post:
aaa (01-10-2010)

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
MA Ribbon Tams Trading Indicators 7 04-23-2012 06:41 AM
Horizontal Line Plot For Day nab999 Coding Forum 3 09-16-2009 09:03 AM
Plot Text Vertical jojojo Trading Indicators 3 08-31-2009 08:55 AM
Constant Plot Level PeterBrazel Coding Forum 12 08-05-2009 12:04 PM
Plot Statement Issue PeterBrazel Coding Forum 15 08-03-2009 06:23 AM

All times are GMT -4. The time now is 02:23 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.