- Joined
- 12 January 2008
- Posts
- 7,371
- Reactions
- 18,418
@Skate mentioned that some might find this feature easier to use in their codes, so I have a simplified version as an introduction to what can be done.Backtesting is made simpler & chart swapping is even easier
@Trav. may elect to do a post - how to code using the (switch) feature - as the possibilities with Amibroker is limitless.
ChartType = ParamList( "Chart Type", "Price Chart|ADX & STOCH|ADX & MACD" ); // Enables the user to select which type of chart is displayed.
Show_MA10 = ParamToggle( "Show MA10", "Off|On", 1 ); // Turn on/off moving average plot
Show_MA20 = ParamToggle( "Show MA20", "Off|On", 1 );
Show_MA50 = ParamToggle( "Show MA50", "Off|On", 1 );
Show_MA100 = ParamToggle( "Show MA100", "Off|On", 1 );
Show_MA200 = ParamToggle( "Show MA200", "Off|On", 1 );
AllOff = ParamToggle( "Turn Off All Inidcators", "Off|On", 1 ); // Turns all moving averages off in Price chart
///////////////////////////////////////////
// CHARTING //
///////////////////////////////////////////
SetChartBkColor(colorBlack);
SetChartBkGradientFill( colorBlack, colorBlack);
if( ChartType == "Price Chart" )
{
Plot( C, "Price", colorDefault, styleCandle );
if( Show_MA10 AND AllOff )
{
Plot( EMA( C, 10), "EMA 10 ", colorGold, styleLine, 0, 0, 0, 0, 1 );
}
if( Show_MA20 AND AllOff )
{
Plot( EMA( C, 20), "EMA 20 ", colorGreen, styleLine, 0, 0, 0, 0, 1 );
}
if( Show_MA50 AND AllOff )
{
Plot( EMA( C, 50), "EMA 50 ", colorAqua, styleLine, 0, 0, 0, 0, 1 );
}
if( Show_MA100 AND AllOff )
{
Plot( EMA( C, 100), "EMA 100 ", colorBlue, styleLine, 0, 0, 0, 0, 1 );
}
if( Show_MA200 AND AllOff )
{
Plot( EMA( C, 200), "EMA 200 ", colorBrown, styleLine, 0, 0, 0, 0, 1 );
}
}
if( ChartType == "ADX & STOCH" )
{
_SECTION_BEGIN("Stochastic %D");
periods = Param( "Periods", 12, 1, 200, 1 );
Ksmooth = Param( "%K avg", 1, 1, 200, 1 );
Dsmooth = Param( "%D avg", 1, 1, 200, 1 );
Plot( StochD( periods , Ksmooth, DSmooth ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
SetChartBkColor( colorBlack );
r4 = Param("Periods", 12, 2, 200, 1 );
ADXColor = IIf( ADX(r4) > 30, colorBrightGreen, colorDarkGreen);
Plot( ADX(12), StrFormat("ADX"+"(%g)", r4), ADXColor, ParamStyle("ADX style", styleThick | styleOwnScale ) );
_SECTION_END();
}
if( ChartType == "ADX & MACD" )
{
_SECTION_BEGIN("ADX & MACD");
SetChartBkColor( colorBlack );
ADXColor = IIf( ADX(14) > 30, colorBrightGreen, colorDarkGreen);
Plot( ADX(14), StrFormat("ADX"+"(%g)", 14), ADXColor, ParamStyle("ADX style", styleThick | styleOwnScale ) );
FastMACD = 12;
SlowtMACD = 26;
SignaMACD = 9;
Plot( ml = MACD(FastMACD, SlowtMACD), StrFormat("MACD"+"(%g,%g)", FastMACD, SlowtMACD), ParamColor("MACD color", colorRed ), ParamStyle("MACD style", styleLine | styleOwnScale) );
Plot( sl = Signal(FastMACD,SlowtMACD,SignaMACD), StrFormat("Signal" + "(%g,%g,%g)", FastMACD, SlowtMACD, SignaMACD), ParamColor("Signal color", colorLightBlue ), ParamStyle("Signal style", styleLine | styleOwnScale) );
Plot( ml-sl, "MACD Histogram", ParamColor("Histogram color", colorDefault ), styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel | styleOwnScale, maskHistogram ) );
_SECTION_END();
_SECTION_END();
}
SystemSelect = ParamList( "System Select", "Channel Break Up|EMA Crossover|MA Crossover" ); // Enables the user to select which type of system is traded.
ShowArrows = ParamToggle( "Show Buy/Sell Arrows", "Off|On", 1 );
AllOff = ParamToggle( "Turn Off All Inidcators", "Off|On", 1 ); // Turns all moving averages off in Price chart
ChannelBreakUpPeriod = Param("Channel Break Up Period", 10, 5, 100, 1); // 10 bars
StopLevel = 1 - Param("Channel Break Up TS %", 20, 5, 30, 1)/100;
EMAperiod = Param("EMA Crossover", 20, 5, 100, 1); // number of averaging periods
MAperiod = Param("MA Crossover", 20, 5, 100, 1); // number of averaging periods
SetTradeDelays(1, 1, 1, 1);
///////////////////////////////////////////
// CHARTING //
///////////////////////////////////////////
// Title
_N(Title = StrFormat("{{NAME}}" + " - {{FULLNAME}} " + " - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%), Vol " +
WriteVal(V, 1.0), O, H, L, C, (ROC(C, 1))));
SetChartBkColor(colorBlack);
SetChartBkGradientFill( colorBlack, colorBlack);
SetChartOptions(1, chartShowDates, chartGridMiddle, 0, 0, 0);
Plot( Close,"Price",colorBlack,styleBar);
if( SystemSelect == "Channel Break Up" )
{
ChannelBreakUp = Close > Ref( HHV( High, ChannelBreakUpPeriod ), -1 );
Buy = ChannelBreakUp;
Sell = 0;
trailARRAY = Null;
trailstop = 0;
for( i = 1; i < BarCount; i++ )
{
if( trailstop == 0 AND Buy[ i ] )
{
trailstop = High[ i ] * stoplevel;
}
else Buy[ i ] = 0; // remove excess buy signals
if( trailstop > 0 AND Low[ i ] < trailstop )
{
Sell[ i ] = 1;
SellPrice[ i ] = trailstop;
trailstop = 0;
}
if( trailstop > 0 )
{
trailstop = Max( High[ i ] * stoplevel, trailstop );
trailARRAY[ i ] = trailstop;
}
}
Plot( trailARRAY,"trailing stop level", colorRed );
if( showArrows AND AllOff )
{
/* Plot Buy and Sell Signal Arrows */
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeupArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, L, Offset=-60);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,L, Offset=-70);
PlotShapes(IIf(Sell, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-65);
}
}
if( SystemSelect == "EMA Crossover" )
{
emaCross = EMA( Close, EMAperiod ); // exponential moving average
Buy = Cross( Close, emaCross ); // buy when close crosses ABOVE moving average
Sell = Cross( emaCross, Close ); // sell when closes crosses BELOW moving average
if( AllOff )
{
Plot( emaCross, "EMA ", colorGreen, styleLine, 0, 0, 0, 0, 1 );
}
if( showArrows AND AllOff )
{
/* Plot Buy and Sell Signal Arrows */
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeupArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, L, Offset=-60);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,L, Offset=-70);
PlotShapes(IIf(Sell, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-65);
}
}
if( SystemSelect == "MA Crossover" )
{
maCross = MA( Close, MAperiod ); // simple moving average
Buy = Cross( Close, maCross ); // buy when close crosses ABOVE moving average
Sell = Cross( maCross, Close ); // sell when closes crosses BELOW moving average
if( AllOff )
{
Plot( maCross, "MA ", colorYellow, styleLine, 0, 0, 0, 0, 1 );
}
if( showArrows AND AllOff )
{
/* Plot Buy and Sell Signal Arrows */
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeupArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, L, Offset=-60);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,L, Offset=-70);
PlotShapes(IIf(Sell, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-65);
}
}
@greasy_pancakes try right click on chart tabs and set to Floating, then arrange on screen as per below. I only have end of day data so unable to show you 4hr and 5min
View attachment 117609
View attachment 117610
Not that I am aware of mate, but others might have seen this elsewhere.Now, quick question: is there a way to sync the cursor so that when it's pointing at one price on one timeframe, it'll highlight the same price on all other timeframes?
Now, quick question: is there a way to sync the cursor so that when it's pointing at one price on one timeframe, it'll highlight the same price on all other timeframes?
Thanks for dropping by @captain black and that worked well. Now I know nearly 5% of the capabilities of AmiBroker.It's certainly possible, I use it for discretionary trading with multiple time frame charts in Amibroker. The thread below on the AB forum might give you some helpful pointers.
Thanks for dropping by @captain black and that worked well.
Now I know nearly 5% of the capabilities of AmiBroker.
I was adding some new watchlists today and it took me a minute to remember how to organise them, so I thought that I would share this really simple but important tip
From the toolbar select Symbol / Categories.
View attachment 116803
Select the Watch list tab, and then move up / down your watchlists into the order that you would like.
View attachment 116804
Simple as that, but a handy reminder.
Another good way to add/subtract/edit your Watchlists is to find the "index" file in C:\Program Files\AmiBroker\Data\WatchLists. Exit AmiBroker and edit it with Notepad and save. Delete all the other Watchlists in that Folder. It will update to new one next time you start AmiBroker.
Probably a good idea to make sure you've got a backup in case you mess up.
Whenever I run a Filter that I only want to save the result temporarily, I made a Watchlist called "0 Watch" or just "0". It appears at the top of the list so it's easy to access, and when finished, I overwrite it with the next Filter. HIghlight, then right click and "replace watch list list with selected results". This way you can scroll up and down without clicking.
As I am in a sharing mood this morning I thought that I would put up some watchlist that are good starting point for you to run your scans against a particular sector.I was adding some new watchlists today and it took me a minute to remember how to organise them, so I thought that I would share this really simple but important tip
As I am in a sharing mood this morning I thought that I would put up some watchlist that are good starting point for you to run your scans against a particular sector.
You could do this by selecting a sector as per below but you have 780 stocks currently in the Basic Materials Sector
View attachment 119632
Now if you wanted to focus on some Lithium stocks then I would select my watchlist as per below which has 19 stocks and therefore narrowed down your search a lot.
View attachment 119633
I have attached some watchlist that I created in the zip file and you can add / remove stocks in each section
View attachment 119637
Just extract to your watchlist folder and my path is below but you will find yours will have the standard Norgate watchlists already there
View attachment 119638
If the newly imported watchlists don't show immediately then restart AmiBroker and they should show up in the Watch Lists folder. Then you can reorganize as detailed in my previous post.
Now back to creating that Cobalt watchlist.
Goodluck !!!
// System name for the chart watermark
SystemName = StrExtract(StrExtract(GetFormulaPath(), -1, '\\'), -2, '.' ); // uses filename as SystemName
Ver = "1.01"; // This needs to be incremented for every committed change
SystemNameVer = SystemName + "_" + Ver;
// Add watermark so we know we have the correct chart with the correct analysis
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", 24, weight=300, italic=true, underline=false, orientation=0);
GfxSetTextAlign(6); // 6 = center, 0 = left, 2 = right
GfxSetTextColor(colorGrey40);
GfxSetBkMode(1); // transparent
GfxTextOut(SystemNameVer, Status("pxwidth")/2.2, Status("pxheight")/2.5);
Was doing something similar but more manual: thanks for the code,will adopt .I've been adding this code to my AFL:
Near the top of the file:
Code:// System name for the chart watermark SystemName = StrExtract(StrExtract(GetFormulaPath(), -1, '\\'), -2, '.' ); // uses filename as SystemName Ver = "1.01"; // This needs to be incremented for every committed change SystemNameVer = SystemName + "_" + Ver;
Then at the top of the charting section:
Code:// Add watermark so we know we have the correct chart with the correct analysis GfxSetOverlayMode(1); GfxSelectFont("Tahoma", 24, weight=300, italic=true, underline=false, orientation=0); GfxSetTextAlign(6); // 6 = center, 0 = left, 2 = right GfxSetTextColor(colorGrey40); GfxSetBkMode(1); // transparent GfxTextOut(SystemNameVer, Status("pxwidth")/2.2, Status("pxheight")/2.5);
This adds a watermark to my chart so I know it's in sync with my AFL.
Before this, I often was looking at a chart that didn't match my AFL, wondering why my buy and sell arrows were off!
View attachment 122732
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?