Australian (ASX) Stock Market Forum

Amibroker FAQ

Hi

Feel like this is a dumb question but, here goes

How to I change the background colour in the chart screen...

Regards
Shaker
 
On a formula level you can have a background colour gradient and/or different colours in the inner and outer panels. Here's some example code:

Code:
_SECTION_BEGIN("Background Color");
BKswitch = ParamToggle("Background Color","On,Off");

OUTcolor = ParamColor("Outer Panel Color",colorLightBlue);
INUPcolor = ParamColor("Inner Panel Upper",colorLightYellow);
INDNcolor = ParamColor("Inner Panel Lower",colorSeaGreen);
TitleColor = ParamColor("Title Color ",ColorRGB(245,245,245));

if (NOT BKswitch)
{
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
_SECTION_END();
 
No such thing as a dumb question, only dumb if you don't ask :)



Easiest way is "Tools --> Preferences --> Colors tab --> Background. Click on the "Background" box and change to whatever colour you prefer.

Also possible to change background colour in formula code as well:

http://www.amibroker.com/guide/afl/afl_view.php?id=308

Hi when I changed via above instruction it did this
Screen Colour.jpg

I would like the whole panel to be white. What am I missing here?

Shaker
PS thanks for the help so far
 
Hi when I changed via above instruction it did this
View attachment 54541

I would like the whole panel to be white. What am I missing here?

Shaker
PS thanks for the help so far

That looks like a pre-defined chart theme. In the Preferences box click on the "Axes/Grid" tab and see if you have one of the pre-defined chart themes selected. I keep the pre-defined themes blank and set my own grid colours etc. Untick the "alternate background fill" boxes if they're ticked and see if that affects the background chart colour.
 
Hi

There was no theme selected. so for now have selected basic which is white.
Will now need to find bar colour selections as they are all black now.

Thanks to all
Shaker
 
Q: I would like to experiment with a Donchian style Equity Curve Filter, any help is much appreciated.


Howard Bandy has provided a template for an EquityCurveFeedback system based on a Moving Average (msg# 25815).

But I'm having difficulty translating the one-dimensional MA Filter to a two-dimensional Donchian Filter,
specifically, switching the system back "ON" after it has been triggered "OFF". So far I have:


/////////////////////////////
// Basic System

Buy = BuyCondition;
Sell = SellCondition;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

e = Equity();

// Equity Filter -- incomplete

x = Optimize("x",40,10,50,2); // UpperDonchianLength
y = Optimize("y",20,10,50,2); // LowerDonchianLength

UpperDonchian = Ref(HHV(e,x),-1);
LowerDonchain = Ref(LLV(e,y),-1);

Pass = IIf(e < LowerDonchian,0,1);

Buy = Buy AND Pass;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

e1 = Equity();

/////////////////////////////

^ So far this remains a one-dimensional variant to Howard's MA based filter.

There are four basic relations equity 'e' can have relative to Upper/Lower Donchian:

1 = System ON: e > UpperDonchian AND e > LowerDonchian
2 = System ON: e < UpperDonchian AND e > LowerDonchian (following Breakout)
3 = System OFF: e < UpperDonchian AND e > LowerDonchian (following Breakdown)
4 = System OFF: e < UpperDonchian AND e < LowerDonchian

I'm guessing a loop of some sort is required to distinguish between '2' and '3', but I'm having
difficulty making the conceptual step to qualify this extra condition.

Again, any help would be much appreciated.
 
There are four basic relations equity 'e' can have relative to Upper/Lower Donchian:

1 = System ON: e > UpperDonchian AND e > LowerDonchian
2 = System ON: e < UpperDonchian AND e > LowerDonchian (following Breakout)
3 = System OFF: e < UpperDonchian AND e > LowerDonchian (following Breakdown)
4 = System OFF: e < UpperDonchian AND e < LowerDonchian

Hi Cology --

What are the rules that indicate the system is in state 3? How is "breakdown" defined?

Regards,
Howard
 
Hi Cology --

What are the rules that indicate the system is in state 3? How is "breakdown" defined?

Regards,
Howard

Thanks for getting back to me!

Perhaps 'Chandelier Filter' would be a more accurate description, in any case, it is meant to be a very basic Turtle type trend following filter on the equity curve.

The system is in state 3 when:

a) following a "breakdown", i.e., 'e' equity having recently crossed below the LowerDonchian (it was True that 'e < Ref(LLV(e,period),-1)' )

and,

b) the equity curve is currently above the LowerDonchian, but also below the UpperDonchian ... in other words, waiting for a "breakout" to switch the system back "ON".

So,

1 = System ON: e > UpperDonchian AND e > LowerDonchian = Breakout
2 = System ON: e < UpperDonchian AND e > LowerDonchian (following Breakout)
3 = System OFF: e < UpperDonchian AND e > LowerDonchian (following Breakdown)
4 = System OFF: e < UpperDonchian AND e < LowerDonchian = Breakdown

'1' would correspond to the "breakout" and '4' would correspond to the "breakdown".

The problem I'm having is that the code for the equity curve filter is "second order". A simple "first order" code for this system would look like this:

// Begin

Upper_Length = Optimize("Upper Length",40,10,50,2);
Lower_Length = Optimize("Lower Length",20,10,50,2);

Buy = C > Ref(HHV(H,Upper_Length),-1);
Sell = C < Ref(LLV(L,Lower_Length),-1);

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

// End

With this first order system there is no ambiguity whether the system is in '2' or '3' (i.e., when the price is below the upper band, but above the lower band).

I hope that makes sense?

Any insight is much appreciated!
 
It is meant to be a very basic Turtle type trend following filter on the equity curve.

The system is in state 3 when:

a) following a "breakdown", i.e., 'e' equity having recently crossed below the LowerDonchian (it was True that 'e < Ref(LLV(e,period),-1)' )

and,

b) the equity curve is currently above the LowerDonchian, but also below the UpperDonchian ... in other words, waiting for a "breakout" to switch the system back "ON".

. . .

I hope that makes sense?

Here's an illustration (assume the blue line represents 'e', the unfiltered equity curve):

EquityCurveFeedbackFilter.PNG
 
Hi Cology --

Does it help to think about a "shadow equity curve" being formed from "shadow trades" that come from the system's rules, analyze the shadow equity using whatever indicator you want (such as Donchian channel breakout) to use creating "pass" and "dont pass" filter, then combine the shadow trades with the pass/dontpass filter. Something like this (which is for concept only):

// system buy and sell rules
Buy = xxx;
Sell = yyy;

// shadow equity
se = shadowequity = equity();

// analyze shadow equity, treating it as if it is a price series
pass = breakup = se>=HHV(se,20);
dontpass = breakdown = se<=LLV(se,10);

// overwrite the original buy and sell with the filtered buy and sell
buy = buy and pass;
sell = sell or dontpass;

/////////////// end

Or am I missing something?

Best regards,
Howard
 
Hi Cology --

Does it help to think about a "shadow equity curve" being formed from "shadow trades" that come from the system's rules, analyze the shadow equity using whatever indicator you want (such as Donchian channel breakout) to use creating "pass" and "dont pass" filter, then combine the shadow trades with the pass/dontpass filter. Something like this (which is for concept only):

// system buy and sell rules
Buy = xxx;
Sell = yyy;

// shadow equity
se = shadowequity = equity();

// analyze shadow equity, treating it as if it is a price series
pass = breakup = se>=HHV(se,20);
dontpass = breakdown = se<=LLV(se,10);

// overwrite the original buy and sell with the filtered buy and sell
buy = buy and pass;
sell = sell or dontpass;

/////////////// end

Or am I missing something?

Best regards,
Howard

Thanks! First off, I should say I'm relatively new to AFL and don't have a programming background, so I appreciate your time in helping me out.

Something like what you have written above was my initial thought, but my concern was that buy signals would only pass the filter if it coincided with the equity curve being 'in a state of breakout' (rather than: 'in a state of breakout OR the period following breakout, prior to breakdown').

Anyway (at least at first glance) my concern seems to be confirmed when I apply your suggestion to a simple strategy. What seems to happen is that buy signals are only generated when we have both a basic buy signal AND the equity curve is in a state of breakout (i.e., 'e' > yesterday's Upper Donchian).

My intention with applying a Donchian filter to the equity curve was that it would operate like a switch. I.e., following a "breakout" the system would be ON, and all buy/sell signals pass the filter. As soon as we get a "breakdown" in the equity curve, the system goes OFFLINE until the equity curve again reaches a "breakout". It is similar to a simple MA filter, with the important difference that the ON and OFF conditions do not form an exclusive disjunction.

Anyway, I will look into this more, but I have included a basic strategy applied to the SPY (for illustrative purposes) to help explain my conundrum.

1. Basic MA cross over system

// Basic MA Crossover System

MA1 = MA(C,11); //Optimize("MA1",11,10,50,1));
MA2 = MA(C,13); //Optimize("MA2",13,10,50,1));

Buy = Cross(MA1,MA2);
Sell = Cross(MA2,MA1);

e = Equity();

Plot(C,"C",colorBlack,styleCandle);
Plot(e,"Equity",colorGreen,styleLine|styleThick|styleLeftAxisScale);

PlotShapes(Buy*shapeUpArrow,colorBrightGreen);
PlotShapes(Sell*shapeDownArrow,colorRed);

Equity_1.PNG

2. Plot Donchian Channel/Filter

// Donchian Channel

Plot(Ref(HHV(e,100),-1),"Upper",colorGreen,styleDashed|styleLeftAxisScale);
Plot(Ref(LLV(e,50),-1),"Lower",colorGreen,styleDashed|styleLeftAxisScale);

Equity_2.PNG

3. Apply Donchian Channel/Filter to Equity Curve

// Donchian Filter

On = e > Ref(HHV(e,100),-1);
Off = e < Ref(LLV(e,50),-1);

Buy = Buy AND On;
Sell = Sell OR Off;

PlotShapes(Buy*shapeUpArrow,colorBrightGreen); //Filtered "Buy" - commenting out original "Buy" signal
PlotShapes(Sell*shapeDownArrow,colorRed); //Filtered "Sell" - commenting out original "Sell" signal

e1 = Equity();

Plot(e1,"Filtered Equity",colorBlue,styleLine|styleLeftAxisScale);

Equity_3.PNG

For some reason, the final step removes all "Buy" signals. I am still familiarising myself with AFL, so it may well be that I have overlooked something very obvious. Unfortunately, for the time being I remain stuck.

If you have any further thoughts that would be much appreciated!

Regards,

Andres
 
Hi Cology --

As written, the On condition is true for those bars where the equity is greater than the highest equity over the previous 100 bars. As soon as the equity drops by any amount, On is no longer True. See if using the Flip function to latch On to True until it is turned to Off helps.

To see the effect, run this as it is, then again with the two lines that call Flip commented out.

// Donchian Filter

On = e > Ref(HHV(e,100),-1);
Off = e < Ref(LLV(e,50),-1);

On = Flip(On,Off);
Off = Flip(Off,On);

Plot(On,"On",colorGreen,styleLine|styleOwnScale);

Buy = Buy AND On;
Sell = Sell OR Off;

Regards,
Howard
 
Hi Cology --

As written, the On condition is true for those bars where the equity is greater than the highest equity over the previous 100 bars. As soon as the equity drops by any amount, On is no longer True. See if using the Flip function to latch On to True until it is turned to Off helps.

To see the effect, run this as it is, then again with the two lines that call Flip commented out.

// Donchian Filter

On = e > Ref(HHV(e,100),-1);
Off = e < Ref(LLV(e,50),-1);

On = Flip(On,Off);
Off = Flip(Off,On);

Plot(On,"On",colorGreen,styleLine|styleOwnScale);

Buy = Buy AND On;
Sell = Sell OR Off;

Regards,
Howard

Excellent! That does the trick.

Many thanks!

- - - - - - - - - -

before/after :
Equity_4.PNG
 
Top