スポンサーサイト

上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。

MQL4言語のソースコードをMetaEditor風にシンタックスハイライトする方法

MQL4はC言語やPHP, JAVAなどに比べるとマイナーな言語です。

ソースコードの一部をブログなどで公開している人もいますが、海外のMQL4 Code Baseサイトのように
シンタックスハイライトさせて、MetaEditorのように色付けして表示しているサイトはまだ少ないですね。

なぜなら、シンタックスハイライトはオープンソースで便利なライブラリがいくつかあるのですが
マイナーなMQL4言語用の設定ファイルがないので、わざわざ作成する必要があるからです。

そこで今回は、MQL4言語用の設定ファイルを作成して
ソースコードをMetaEditor風にシンタックスハイライトする方法をご紹介します。


まずはじめに、ライブラリはシンタックスハイライトで有名なSyntaxHighlighterを使用しますので
サイトからダウンロード・展開してください。(執筆時点での最新版はSyntaxHighlighter 3.0.83)

次にMQL4言語用に使用するのは下記4ファイルです。☆はそのままで、★はこれから作成します。

[syntaxhighlighter_3.0.83]
├[script]
│├shBrushMql4.js ★
│└shCore.js ☆
└[styles]
 ├shCoreMetaEditor.css ★
 └shThemeDefault.css ☆

★の2ファイルは、下記をダブルクリック&コピーして作成してみてください。(説明は割愛します)

shBrushMql4.js
;(function()
{
// CommonJS
typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;

function Brush()
{
var keyword1 = 'AliceBlue AntiqueWhite Aqua Aquamarine Beige Bisque Black BlanchedAlmond Blue BlueViolet bool break Brown BurlyWood CadetBlue case Chartreuse Chocolate CLR_NONE color continue continue copyright Coral CornflowerBlue Cornsilk Crimson DarkBlue DarkGoldenrod DarkGray DarkGreen DarkKhaki DarkOliveGreen DarkOrange DarkOrchid DarkSalmon DarkSeaGreen DarkSlateBlue DarkSlateGray DarkTurquoise DarkViolet datetime DeepPink DeepSkyBlue default DimGray DodgerBlue double DRAW_ARROW DRAW_HISTOGRAM DRAW_LINE DRAW_NONE DRAW_SECTION DRAW_ZIGZAG else EMPTY EMPTY_VALUE ERR_ACCOUNT_DISABLED ERR_ARRAY_AS_PARAMETER_EXPECTED ERR_ARRAY_INDEX_OUT_OF_RANGE ERR_BROKER_BUSY ERR_CANNOT_CALL_FUNCTION ERR_CANNOT_LOAD_LIBRARY ERR_CANNOT_OPEN_FILE ERR_COMMON_ERROR ERR_CUSTOM_INDICATOR_ERROR ERR_DLL_CALLS_NOT_ALLOWED ERR_DOUBLE_PARAMETER_EXPECTED ERR_END_OF_FILE ERR_EXTERNAL_CALLS_NOT_ALLOWED ERR_FUNC_NOT_ALLOWED_IN_TESTING ERR_FUNCTION_NOT_CONFIRMED ERR_GLOBAL_VARIABLE_NOT_FOUND ERR_GLOBAL_VARIABLES_PROCESSING ERR_HISTORY_WILL_UPDATED ERR_INCOMPATIBLE_ARRAYS ERR_INCOMPATIBLE_FILEACCESS ERR_INCORRECT_SERIESARRAY_USING ERR_INTEGER_PARAMETER_EXPECTED ERR_INVALID_ACCOUNT ERR_INVALID_FUNCTION_PARAMSCNT ERR_INVALID_FUNCTION_PARAMVALUE ERR_INVALID_PRICE ERR_INVALID_PRICE_PARAM ERR_INVALID_STOPS ERR_INVALID_TICKET ERR_INVALID_TRADE_PARAMETERS ERR_INVALID_TRADE_VOLUME ERR_LONG_POSITIONS_ONLY_ALLOWED ERR_LONGS_NOT_ALLOWED ERR_MALFUNCTIONAL_TRADE ERR_MARKET_CLOSED ERR_NO_CONNECTION ERR_NO_ERROR ERR_NO_MEMORY_FOR_ARRAYSTRING ERR_NO_MEMORY_FOR_CALL_STACK ERR_NO_MEMORY_FOR_PARAM_STRING ERR_NO_MEMORY_FOR_RETURNED_STR ERR_NO_MEMORY_FOR_TEMP_STRING ERR_NO_MQLERROR ERR_NO_OBJECT_NAME ERR_NO_ORDER_SELECTED ERR_NO_RESULT ERR_NO_SPECIFIED_SUBWINDOW ERR_NOT_ENOUGH_MONEY ERR_NOT_ENOUGH_RIGHTS ERR_NOT_ENOUGH_STACK_FOR_PARAM ERR_NOT_INITIALIZED_ARRAY ERR_NOT_INITIALIZED_ARRAYSTRING ERR_NOT_INITIALIZED_STRING ERR_OBJECT_ALREADY_EXISTS ERR_OBJECT_COORDINATES_ERROR ERR_OBJECT_DOES_NOT_EXIST ERR_OFF_QUOTES ERR_OLD_VERSION ERR_ORDER_LOCKED ERR_PRICE_CHANGED ERR_RECURSIVE_STACK_OVERFLOW ERR_REMAINDER_FROM_ZERO_DIVIDE ERR_REQUOTE ERR_SEND_MAIL_ERROR ERR_SERVER_BUSY ERR_SHORTS_NOT_ALLOWED ERR_SOME_ARRAY_ERROR ERR_SOME_FILE_ERROR ERR_SOME_OBJECT_ERROR ERR_STRING_FUNCTION_INTERNAL ERR_STRING_PARAMETER_EXPECTED ERR_SYSTEM_BUSY ERR_TOO_FREQUENT_REQUESTS ERR_TOO_LONG_STRING ERR_TOO_MANY_OPENED_FILES ERR_TOO_MANY_REQUESTS ERR_TRADE_CONTEXT_BUSY ERR_TRADE_DISABLED ERR_TRADE_ERROR ERR_TRADE_EXPIRATION_DENIED ERR_TRADE_MODIFY_DENIED ERR_TRADE_NOT_ALLOWED ERR_TRADE_TIMEOUT ERR_TRADE_TOO_MANY_ORDERS ERR_UNKNOWN_COMMAND ERR_UNKNOWN_OBJECT_PROPERTY ERR_UNKNOWN_OBJECT_TYPE ERR_UNKNOWN_SYMBOL ERR_WRONG_FILE_NAME ERR_WRONG_FUNCTION_POINTER ERR_WRONG_JUMP ERR_ZERO_DIVIDE extern false FireBrick for ForestGreen Gainsboro Gold Goldenrod Gray Green GreenYellow Honeydew HotPink IDABORT IDCANCEL IDCONTINUE IDIGNORE IDNO IDOK IDRETRY IDTRYAGAIN IDYES if IndianRed indicator_buffers indicator_chart_window indicator_color1 indicator_color2 indicator_color3 indicator_color4 indicator_color5 indicator_color6 indicator_color7 indicator_color8 indicator_level1 indicator_level2 indicator_level3 indicator_level4 indicator_level5 indicator_level6 indicator_level7 indicator_level8 indicator_levelcolor indicator_levelstyle indicator_levelwidth indicator_maximum indicator_minimum indicator_separate_window indicator_style1 indicator_style2 indicator_style3 indicator_style4 indicator_style5 indicator_style6 indicator_style7 indicator_style8 indicator_width1 indicator_width2 indicator_width3 indicator_width4 indicator_width5 indicator_width6 indicator_width7 indicator_width8 Indigo int Ivory Khaki Lavender LavenderBlush LawnGreen LemonChiffon library LightBlue LightCoral LightCyan LightGoldenrod LightGray LightGreen LightPink LightSalmon LightSeaGreen LightSkyBlue LightSlateGray LightSteelBlue LightYellow Lime LimeGreen Linen link Magenta Maroon MB_ABORTRETRYIGNORE MB_CANCELTRYCONTINUE MB_DEFBUTTON1 MB_DEFBUTTON2 MB_DEFBUTTON3 MB_DEFBUTTON4 MB_ICONASTERISK MB_ICONERROR MB_ICONEXCLAMATION MB_ICONHAND MB_ICONINFORMATION MB_ICONQUESTION MB_ICONSTOP MB_ICONWARNING MB_OK MB_OKCANCEL MB_RETRYCANCEL MB_YESNO MB_YESNOCANCEL MediumAquamarine MediumBlue MediumOrchid MediumPurple MediumSeaGreen MediumSlateBlue MediumSpringGreen MediumTurquoise MediumVioletRed MidnightBlue MintCream MistyRose Moccasin MODE_ASK MODE_BID MODE_CHINKOUSPAN MODE_CLOSE MODE_DIGITS MODE_EMA MODE_EXPIRATION MODE_FREEZELEVEL MODE_HIGH MODE_HIGH MODE_KIJUNSEN MODE_LOTSIZE MODE_LOTSTEP MODE_LOW MODE_LOW MODE_LOWER MODE_LWMA MODE_MAIN MODE_MARGINCALCMODE MODE_MARGINHEDGED MODE_MARGININIT MODE_MARGINMAINTENANCE MODE_MARGINREQUIRED MODE_MAXLOT MODE_MINLOT MODE_MINUSDI MODE_OPEN MODE_PLUSDI MODE_POINT MODE_PROFITCALCMODE MODE_SENKOUSPANA MODE_SENKOUSPANB MODE_SIGNAL MODE_SMA MODE_SMMA MODE_SPREAD MODE_STARTING MODE_STOPLEVEL MODE_SWAPLONG MODE_SWAPSHORT MODE_SWAPTYPE MODE_TENKANSEN MODE_TICKSIZE MODE_TICKVALUE MODE_TIME MODE_TIME MODE_TRADEALLOWED MODE_UPPER MODE_VOLUME NavajoWhite Navy NULL OBJ_ALL_PERIODS OBJ_ARROW OBJ_CHANNEL OBJ_CYCLES OBJ_ELLIPSE OBJ_EXPANSION OBJ_FIBO OBJ_FIBOARC OBJ_FIBOCHANNEL OBJ_FIBOFAN OBJ_FIBOTIMES OBJ_GANNFAN OBJ_GANNGRID OBJ_GANNLINE OBJ_HLINE OBJ_LABEL OBJ_PERIOD_D1 OBJ_PERIOD_H1 OBJ_PERIOD_H4 OBJ_PERIOD_M1 OBJ_PERIOD_M15 OBJ_PERIOD_M30 OBJ_PERIOD_M5 OBJ_PERIOD_MN1 OBJ_PERIOD_W1 OBJ_PITCHFORK OBJ_RECTANGLE OBJ_REGRESSION OBJ_STDDEVCHANNEL OBJ_TEXT OBJ_TREND OBJ_TRENDBYANGLE OBJ_TRIANGLE OBJ_VLINE OBJPROP_ANGLE OBJPROP_ARROWCODE OBJPROP_BACK OBJPROP_COLOR OBJPROP_CORNER OBJPROP_DEVIATION OBJPROP_ELLIPSE OBJPROP_FIBOLEVELS OBJPROP_FIRSTLEVEL OBJPROP_FONTSIZE OBJPROP_LEVELCOLOR OBJPROP_LEVELSTYLE OBJPROP_LEVELWIDTH OBJPROP_PRICE1 OBJPROP_PRICE2 OBJPROP_PRICE3 OBJPROP_RAY OBJPROP_SCALE OBJPROP_STYLE OBJPROP_TIME1 OBJPROP_TIME2 OBJPROP_TIME3 OBJPROP_TIMEFRAMES OBJPROP_WIDTH OBJPROP_XDISTANCE OBJPROP_YDISTANCE OldLace Olive OliveDrab OP_BUY OP_BUYLIMIT OP_BUYSTOP OP_SELL OP_SELLLIMIT OP_SELLSTOP Orange OrangeRed Orchid PaleGoldenrod PaleGreen PaleTurquoise PaleVioletRed PapayaWhip PeachPuff PERIOD_D1 PERIOD_H1 PERIOD_H4 PERIOD_M1 PERIOD_M15 PERIOD_M30 PERIOD_M5 PERIOD_MN1 PERIOD_W1 Peru Pink Plum PowderBlue PRICE_CLOSE PRICE_HIGH PRICE_LOW PRICE_MEDIAN PRICE_OPEN PRICE_TYPICAL PRICE_WEIGHTED Purple REASON_ACCOUNT REASON_CHARTCHANGE REASON_CHARTCLOSE REASON_PARAMETERS REASON_RECOMPILE REASON_REMOVE Red return RosyBrown RoyalBlue SaddleBrown Salmon SandyBrown SeaGreen Seashell Sienna Silver SkyBlue SlateBlue SlateGray Snow SpringGreen static SteelBlue string STYLE_DASH STYLE_DASHDOT STYLE_DASHDOTDOT STYLE_DOT STYLE_SOLID switch SYMBOL_ARROWDOWN SYMBOL_ARROWUP SYMBOL_CHECKSIGN SYMBOL_LEFTPRICE SYMBOL_RIGHTPRICE SYMBOL_STOPSIGN SYMBOL_THUMBSDOWN SYMBOL_THUMBSUP Tan Teal Thistle Tomato true Turquoise Violet void Wheat while White WhiteSmoke WHOLE_ARRAY Yellow YellowGreen';

var keyword2 = 'AccountBalance AccountCompany AccountCredit AccountCurrency AccountEquity AccountFreeMargin AccountFreeMarginCheck AccountFreeMarginMode AccountLeverage AccountMargin AccountName AccountNumber AccountProfit AccountServer AccountStopoutLevel AccountStopoutMode Alert ArrayBsearch ArrayCopy ArrayCopyRates ArrayCopySeries ArrayDimension ArrayGetAsSeries ArrayInitialize ArrayIsSeries ArrayMaximum ArrayMinimum ArrayRange ArrayResize ArraySetAsSeries ArraySize ArraySort CharToStr Comment Day DayOfWeek DayOfYear DoubleToStr FileClose FileDelete FileFlush FileIsEnding FileIsLineEnding FileOpen FileOpenHistory FileReadArray FileReadDouble FileReadInteger FileReadNumber FileReadString FileSeek FileSize FileTell FileWrite FileWriteArray FileWriteDouble FileWriteInteger FileWriteString GetLastError GetTickCount GlobalVariableCheck GlobalVariableDel GlobalVariableGet GlobalVariableName GlobalVariablesDeleteAll GlobalVariableSet GlobalVariableSetOnCondition GlobalVariablesTotal HideTestIndicators Hour IndicatorBuffers IndicatorCounted IndicatorDigits IndicatorShortName IsConnected IsDemo IsDllsAllowed IsExpertEnabled IsLibrariesAllowed IsOptimization IsStopped MarketInfo MathAbs MathArccos MathArcsin MathArctan MathCeil MathCos MathExp MathFloor MathLog MathMax MathMin MathMod MathPow MathRand MathRound MathSin MathSqrt MathSrand MathTan MessageBox Minute Month NormalizeDouble ObjectCreate ObjectDelete ObjectDescription ObjectFind ObjectGet ObjectGetFiboDescription ObjectGetShiftByValue ObjectGetValueByShift ObjectMove ObjectName ObjectsDeleteAll ObjectSet ObjectSetFiboDescription ObjectSetText ObjectsTotal ObjectType OrderClose OrderCloseBy OrderClosePrice OrderCloseTime OrderComment OrderCommission OrderDelete OrderExpiration OrderLots OrderMagicNumber OrderModify OrderOpenPrice OrderOpenTime OrderPrint OrderProfit OrderSelect OrderSend OrdersHistoryTotal OrderStopLoss OrdersTotal OrderSwap OrderSymbol OrderTakeProfit OrderTicket OrderType Period PlaySound Print RefreshRates Seconds SendFTP SendMail SendNotification SetIndexArrow SetIndexBuffer SetIndexDrawBegin SetIndexEmptyValue SetIndexLabel SetIndexShift SetIndexStyle SetLevelStyle SetLevelValue Sleep StringConcatenate StringFind StringGetChar StringLen StringSetChar StringSubstr StringTrimLeft StringTrimRight StrToDouble StrToInteger StrToTime Symbol TerminalCompany TerminalName TerminalPath TimeCurrent TimeDay TimeDayOfWeek TimeDayOfYear TimeHour TimeLocal TimeMinute TimeMonth TimeSeconds TimeToStr TimeYear UninitializeReason WindowBarsPerChart WindowExpertName WindowFind WindowFirstVisibleBar WindowHandle WindowIsVisible WindowOnDropped WindowPriceMax WindowPriceMin WindowPriceOnDropped WindowRedraw WindowScreenShot WindowsTotal WindowTimeOnDropped WindowXOnDropped WindowYOnDropped Year';

var keyword3 = 'Ask Bars Bid Close Digits High Low Open Point Time Volume';

var keyword4 = 'iAC iAD iADX iAlligator iAO iATR iBands iBandsOnArray iBars iBarShift iBearsPower iBullsPower iBWMFI iCCI iCCIOnArray iClose iCustom iDeMarker iEnvelopes iEnvelopesOnArray iForce iFractals iGator iHigh iHighest iIchimoku iLow iLowest iMA iMACD iMAOnArray iMFI iMomentum iMomentumOnArray iOBV iOpen iOsMA iRSI iRSIOnArray iRVI iSAR iStdDev iStdDevOnArray iStochastic iTime iVolume iWPR';

this.regexList = [
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' },
{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' },
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' },
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' },
{ regex: /^ *#\w* /gm, css: 'keyword1' },
{ regex: new RegExp(this.getKeywords(keyword1), 'gm'), css: 'keyword1' },
{ regex: new RegExp(this.getKeywords(keyword2), 'gm'), css: 'keyword2' },
{ regex: new RegExp(this.getKeywords(keyword3), 'gm'), css: 'keyword3' },
{ regex: new RegExp(this.getKeywords(keyword4), 'gm'), css: 'keyword4' },
{ regex: /\d+\.*\d*/gm, css: 'keyword4' }
];
};

Brush.prototype = new SyntaxHighlighter.Highlighter();
Brush.aliases = ['mql4'];

SyntaxHighlighter.brushes.Mql4 = Brush;

typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
})();

shCoreMetaEditor.css
.syntaxhighlighter a,
.syntaxhighlighter div,
.syntaxhighlighter code,
.syntaxhighlighter table,
.syntaxhighlighter table td,
.syntaxhighlighter table tr,
.syntaxhighlighter table tbody,
.syntaxhighlighter table thead,
.syntaxhighlighter table caption,
.syntaxhighlighter textarea {
-moz-border-radius: 0 0 0 0 !important;
-webkit-border-radius: 0 0 0 0 !important;
background: none !important;
border: 0 !important;
bottom: auto !important;
float: none !important;
height: auto !important;
left: auto !important;
line-height: 1.1em !important;
margin: 0 !important;
outline: 0 !important;
overflow: visible !important;
padding: 0 !important;
position: static !important;
right: auto !important;
text-align: left !important;
top: auto !important;
vertical-align: baseline !important;
width: auto !important;
box-sizing: content-box !important;
font-family: "Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important;
font-weight: normal !important;
font-style: normal !important;
font-size: 1em !important;
min-height: inherit !important;
min-height: auto !important;
}

.syntaxhighlighter {
width: 100% !important;
margin: 1em 0 1em 0 !important;
position: relative !important;
overflow: auto !important;
overflow-y: hidden !important;
font-size: 1em !important;
}
.syntaxhighlighter.source {
overflow: hidden !important;
}
.syntaxhighlighter .bold {
font-weight: bold !important;
}
.syntaxhighlighter .italic {
font-style: italic !important;
}
.syntaxhighlighter .line {
white-space: pre !important;
}
.syntaxhighlighter table {
width: 100% !important;
}
.syntaxhighlighter table caption {
text-align: left !important;
padding: .5em 0 0.5em 1em !important;
}
.syntaxhighlighter table td.code {
width: 100% !important;
}
.syntaxhighlighter table td.code .container {
position: relative !important;
}
.syntaxhighlighter table td.code .container textarea {
box-sizing: border-box !important;
position: absolute !important;
left: 0 !important;
top: 0 !important;
width: 100% !important;
height: 100% !important;
border: none !important;
background: white !important;
padding-left: 1em !important;
overflow: hidden !important;
white-space: pre !important;
}
.syntaxhighlighter table td.gutter .line {
text-align: right !important;
padding: 0 0.5em 0 1em !important;
}
.syntaxhighlighter table td.code .line {
padding: 0 1em !important;
}
.syntaxhighlighter.nogutter td.code .container textarea, .syntaxhighlighter.nogutter td.code .line {
padding-left: 0em !important;
}
.syntaxhighlighter.show {
display: block !important;
}
.syntaxhighlighter.collapsed table {
display: none !important;
}
.syntaxhighlighter.collapsed .toolbar {
padding: 0.1em 0.8em 0em 0.8em !important;
font-size: 1em !important;
position: static !important;
width: auto !important;
height: auto !important;
}
.syntaxhighlighter.collapsed .toolbar span {
display: inline !important;
margin-right: 1em !important;
}
.syntaxhighlighter.collapsed .toolbar span a {
padding: 0 !important;
display: none !important;
}
.syntaxhighlighter.collapsed .toolbar span a.expandSource {
display: inline !important;
}
.syntaxhighlighter .toolbar {
position: absolute !important;
right: 1px !important;
top: 1px !important;
width: 11px !important;
height: 11px !important;
font-size: 10px !important;
z-index: 10 !important;
}
.syntaxhighlighter .toolbar span.title {
display: inline !important;
}
.syntaxhighlighter .toolbar a {
display: block !important;
text-align: center !important;
text-decoration: none !important;
padding-top: 1px !important;
}
.syntaxhighlighter .toolbar a.expandSource {
display: none !important;
}
.syntaxhighlighter.ie {
font-size: .9em !important;
padding: 1px 0 1px 0 !important;
}
.syntaxhighlighter.ie .toolbar {
line-height: 8px !important;
}
.syntaxhighlighter.ie .toolbar a {
padding-top: 0px !important;
}
.syntaxhighlighter.printing .line.alt1 .content,
.syntaxhighlighter.printing .line.alt2 .content,
.syntaxhighlighter.printing .line.highlighted .number,
.syntaxhighlighter.printing .line.highlighted.alt1 .content,
.syntaxhighlighter.printing .line.highlighted.alt2 .content {
background: none !important;
}
.syntaxhighlighter.printing .line .number {
color: #bbbbbb !important;
}
.syntaxhighlighter.printing .line .content {
color: black !important;
}
.syntaxhighlighter.printing .toolbar {
display: none !important;
}
.syntaxhighlighter.printing a {
text-decoration: none !important;
}
.syntaxhighlighter.printing .plain, .syntaxhighlighter.printing .plain a {
color: black !important;
}
.syntaxhighlighter.printing .comments, .syntaxhighlighter.printing .comments a {
color: gray !important;
}
.syntaxhighlighter.printing .string, .syntaxhighlighter.printing .string a {
color: teal !important;
}
.syntaxhighlighter.printing .keyword {
color: #006699 !important;
font-weight: bold !important;
}
.syntaxhighlighter.printing .preprocessor {
color: gray !important;
}
.syntaxhighlighter.printing .variable {
color: #aa7700 !important;
}
.syntaxhighlighter.printing .value {
color: #009900 !important;
}
.syntaxhighlighter.printing .functions {
color: #ff1493 !important;
}
.syntaxhighlighter.printing .constants {
color: #0066cc !important;
}
.syntaxhighlighter.printing .script {
font-weight: bold !important;
}
.syntaxhighlighter.printing .color1, .syntaxhighlighter.printing .color1 a {
color: gray !important;
}
.syntaxhighlighter.printing .color2, .syntaxhighlighter.printing .color2 a {
color: #ff1493 !important;
}
.syntaxhighlighter.printing .color3, .syntaxhighlighter.printing .color3 a {
color: red !important;
}
.syntaxhighlighter.printing .break, .syntaxhighlighter.printing .break a {
color: black !important;
}

.syntaxhighlighter {
background-color: white !important;
}
.syntaxhighlighter .line.alt1 {
background-color: white !important;
}
.syntaxhighlighter .line.alt2 {
background-color: white !important;
}
.syntaxhighlighter .line.highlighted.alt1, .syntaxhighlighter .line.highlighted.alt2 {
background-color: #e0e0e0 !important;
}
.syntaxhighlighter .line.highlighted.number {
color: black !important;
}
.syntaxhighlighter table caption {
color: black !important;
}
.syntaxhighlighter .gutter {
color: #afafaf !important;
}
.syntaxhighlighter .gutter .line {
border-right: 3px solid #6ce26c !important;
}
.syntaxhighlighter .gutter .line.highlighted {
background-color: #6ce26c !important;
color: white !important;
}
.syntaxhighlighter.printing .line .content {
border: none !important;
}
.syntaxhighlighter.collapsed {
overflow: visible !important;
}
.syntaxhighlighter.collapsed .toolbar {
color: blue !important;
background: white !important;
border: 1px solid #6ce26c !important;
}
.syntaxhighlighter.collapsed .toolbar a {
color: blue !important;
}
.syntaxhighlighter.collapsed .toolbar a:hover {
color: red !important;
}
.syntaxhighlighter .toolbar {
color: white !important;
background: #6ce26c !important;
border: none !important;
}
.syntaxhighlighter .toolbar a {
color: white !important;
}
.syntaxhighlighter .toolbar a:hover {
color: black !important;
}
.syntaxhighlighter .plain, .syntaxhighlighter .plain a {
color: black !important;
}
.syntaxhighlighter .comments, .syntaxhighlighter .comments a {
color: gray !important;
}
.syntaxhighlighter .string, .syntaxhighlighter .string a {
color: teal !important;
}
.syntaxhighlighter .keyword {
color: #006699 !important;
}
.syntaxhighlighter .preprocessor {
color: gray !important;
}
.syntaxhighlighter .variable {
color: #aa7700 !important;
}
.syntaxhighlighter .value {
color: #009900 !important;
}
.syntaxhighlighter .functions {
color: #ff1493 !important;
}
.syntaxhighlighter .constants {
color: #0066cc !important;
}
.syntaxhighlighter .script {
font-weight: bold !important;
color: #006699 !important;
background-color: none !important;
}
.syntaxhighlighter .color1, .syntaxhighlighter .color1 a {
color: gray !important;
}
.syntaxhighlighter .color2, .syntaxhighlighter .color2 a {
color: #ff1493 !important;
}
.syntaxhighlighter .color3, .syntaxhighlighter .color3 a {
color: red !important;
}

.syntaxhighlighter .keyword {
font-weight: bold !important;
}

.syntaxhighlighter .keyword1 {
font-weight: bold !important;
color: blue !important;
}

.syntaxhighlighter .keyword2 {
font-weight: bold !important;
color: BlueViolet !important;
}

.syntaxhighlighter .keyword3 {
font-weight: bold !important;
color: magenta !important;
}

.syntaxhighlighter .keyword4 {
font-weight: bold !important;
color: green !important;
}

作成したら、上記4ファイルを各自Webサーバにアップロードします。
そして、htmlのhead内に下記設定をします。(それぞれのパスは適宜変更してください)






そして、各記事のpreタグに class="brush: mql4;" を指定すると。。。
下記のように表示されます。

Bands.mq4
//+------------------------------------------------------------------+
//| Bands.mq4 |
//| Copyright ゥ 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ゥ 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 LightSeaGreen
#property indicator_color2 LightSeaGreen
#property indicator_color3 LightSeaGreen
//---- indicator parameters
extern int BandsPeriod=20;
extern int BandsShift=0;
extern double BandsDeviations=2.0;
//---- buffers
double MovingBuffer[];
double UpperBuffer[];
double LowerBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,MovingBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,UpperBuffer);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,LowerBuffer);
//----
SetIndexDrawBegin(0,BandsPeriod+BandsShift);
SetIndexDrawBegin(1,BandsPeriod+BandsShift);
SetIndexDrawBegin(2,BandsPeriod+BandsShift);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Bollinger Bands |
//+------------------------------------------------------------------+
int start()
{
int i,k,counted_bars=IndicatorCounted();
double deviation;
double sum,oldval,newres;
//----
if(Bars <= BandsPeriod) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i <= BandsPeriod;i++)
{
MovingBuffer[Bars-i]=EMPTY_VALUE;
UpperBuffer[Bars-i]=EMPTY_VALUE;
LowerBuffer[Bars-i]=EMPTY_VALUE;
}
//----
int limit=Bars-counted_bars;
if(counted_bars > 0) limit++;
for(i=0; i < limit; i++)
MovingBuffer[i]=iMA(NULL,0,BandsPeriod,BandsShift,MODE_SMA,PRICE_CLOSE,i);
//----
i=Bars-BandsPeriod+1;
if(counted_bars > BandsPeriod-1) i=Bars-counted_bars-1;
while(i >= 0)
{
sum=0.0;
k=i+BandsPeriod-1;
oldval=MovingBuffer[i];
while(k >= i)
{
newres=Close[k]-oldval;
sum+=newres*newres;
k--;
}
deviation=BandsDeviations*MathSqrt(sum/BandsPeriod);
UpperBuffer[i]=oldval+deviation;
LowerBuffer[i]=oldval-deviation;
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+

MetaEditor風になりましたね!

< や > のHTMLタグ(開始・終了)が入力されている場合は、前後に空白がないと表示が崩れます。。。
空白があればそのままで問題なく表示できていますので、みなさんも色を変更したりしてお試しください。

MT4 EA開発・運用ブログ:関連記事ピックアップ

EAつくーる
自動売買システム作成ソフト「EAつくーる
MT4 EA開発ブログの人気記事「RSI」「ボリンジャーバンド
を使用したEAが、数値入力とクリックで簡単に作成できます。
mq4プログラムが出力されるため、MQL4言語を効率よく
習得したいEA開発初心者にもオススメのEA開発ツールです。
お試しで利用したい方は「EAつくーる【1ヶ月版】」をどうぞ。

MT4 EA開発・運用ブログ:関連記事ピックアップ

EAつくーる
自動売買システム作成ソフト「EAつくーる
MT4 EA開発ブログの人気記事「RSI」「ボリンジャーバンド
を使用したEAが、数値入力とクリックで簡単に作成できます。
mq4プログラムが出力されるため、MQL4言語を効率よく
習得したいEA開発初心者にもオススメのEA開発ツールです。
お試しで利用したい方は「EAつくーる【1ヶ月版】」をどうぞ。

MT4 EA開発・運用ブログ:カテゴリー

MT4 EA開発・運用ブログ:人気記事ランキング(直近1ヶ月)

MT4 EA開発・運用ブログ:最新記事一覧

もっと見る...
上記広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書くことで広告を消せます。