| Coding Forum Collaborate, receive help, or discuss coding related issues. |
![]() | | Tweet | |
| | #1 | ||
![]() | AB = Plot StyleCloud on MA Ribbon 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 ); The problem is where 2 put Displacement ? PlotOHLC(Span1,Span1,Span 2,Span2,"Cloud",colorWhit e ,styleCloud ); Last edited by aaa; 01-09-2010 at 06:10 AM. | ||
| |
|
| The Following User Says Thank You to aaa For This Useful Post: | ||
Tams (01-09-2010) | ||
| | #2 | ||
![]() | Re: AB = Plot StyleCloud on MA Ribbon
__________________ Only an idiot would reply to a stupid post | ||
| |
|
| The Following User Says Thank You to Tams For This Useful Post: | ||
aaa (01-10-2010) | ||
| | #3 | ||
![]() | Re: AB = Plot StyleCloud on MA Ribbon 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.... | ||
| |
|
| | #4 | ||
![]() | Re: AB = Plot StyleCloud on MA Ribbon 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:
| ||
| |
|
| The Following User Says Thank You to Head2k For This Useful Post: | ||
aaa (01-10-2010) | ||
| | #5 | ||
![]() | Re: AB = Plot StyleCloud on MA Ribbon Quote:
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. | ||
| |
|
| The Following User Says Thank You to Head2k For This Useful Post: | ||
aaa (01-10-2010) | ||
| | #6 | ||
![]() | Re: AB = Plot StyleCloud on MA Ribbon 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:
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 | ||
| |
|
| | #7 | ||
![]() | Re: AB = Plot StyleCloud on MA Ribbon 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. | ||
| |
|
| | #8 | ||
![]() | Re: AB = Plot StyleCloud on MA Ribbon 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:
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. | ||
| |
|
| The Following User Says Thank You to Head2k For This Useful Post: | ||
aaa (01-10-2010) | ||
![]() |
| Thread Tools | |
| Display Modes | 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 |