Source Code Mql4 Gabungan Beberapa Indikator

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

#property copyright ""

#property link ""

#property version ""

#property strict

#property indicator_chart_window

//--- input parameters

extern string ___________ = "____________________________";

extern string Set1 = "**** Show AskBidLine Setting****";

input bool InpShowAsk=true; //Show Ask line

input color InpAskColor=clrRed; //Ask Line Color

input color InpBidColor=clrGray; //Bid Line Color

extern string ____________ = "____________________________";

extern string Set2 = "**** SpreadMonitor setting ****";

extern bool UseSpreadMonitor = true;

extern color LabelColor = DeepPink;

extern int YPos = 15 ;

extern int XPos = 330 ;

extern int Corner = 1;

extern string _____________ = "____________________________";

extern string Set3 = "**** Profit Loss Info setting ****";

extern bool UseProfitLossInfo = true;

extern color Color_Text = Silver;

extern color Color_Order_Sell = Red;

extern color Color_Order_Buy = Lime;

extern color Color_Loss = Red;

extern color Color_Profit = Lime;

extern string Text_Font = "Verdana Bold";


extern int Size_Font = 8;

extern double posX = 730;

extern double posY = 50;

extern string ______________ = "____________________________";

extern string Set4 = "**** Thick setting ****";

extern bool ShowTick = true;

extern int XDst = 10;

extern int YDst = 0;

extern bool DisplayInfo=true; // display 15m, 1h, 4h and daily trend, spread and bar time
left

extern bool ShowSteepness=true; // display steepness for 10EMA

extern bool UseBackground = false;

extern color BackgroundColor = LightGray;

extern string _______________ = "____________________________";

extern string Set5 = "**** CSM setting ****";

extern bool ShowCSM = true;

bool AccountIsIBFXmini = false;

bool LoopOnInit = false;

extern color Paircolor = DimGray;

extern color Lowcolor = 3937500;

extern color Mediumcolor = 16777215;

extern color Highcolor = 65280;

extern color Linecolor = White;

#define OBJ_NAME "SpreadIndikatorObj"

#include <ChartObjects\ChartObjectsLines.mqh>
int x = NULL;

CChartObjectHLine bid,ask;

//thick

int tickpos=0; // pointer for the tickbar

int trend5mall, trend15mall, trend30mall, trend1hall, trend4hall; // trends for the EMA 35/50

color trendcolorall[3] = { Lime, Red, DarkOrange }; // colors for trend arrows

string trendarrowall[3] = { "5", "6", "q"};

int trendXcorrectionall[3] = { 0, 1, 1};

int GMTlocaloffset=0; // holds the GMT offset in hours

int GMTbrokeroffset=0;

datetime localtime; // local computer time

datetime gmttime; // GMT Time

datetime brokertime; // broker time

#define TICKS "////////"

#define CLOCKS "·¸¹º»¼½¾¿ÀÁ·¸¹º»¼½¾¿ÀÁ" // clock icons

#define UP 0 // Trend UP

#define DOWN 1 // Trend DOWN

#define RANGING 2 // Trend RANGING

#define TIME_URL "http://tycho.usno.navy.mil/cgi-bin/timer.pl" // from here we get the UTC


time

// CSM

string gsa_100[] = {"USD","EUR" , "GBP", "JPY", "CHF", "CAD", "NZD", "AUD"};

//string gsa_104[] = {"EURUSD", "GBPUSD", "AUDUSD", "USDJPY", "USDCHF", "USDCAD", "EURAUD",


"EURCAD", "EURCHF", "EURGBP", "EURJPY", "GBPJPY", "GBPCHF", "NZDUSD", "AUDCAD", "AUDJPY",
"CHFJPY", "AUDNZD", "NZDJPY", "NZDCAD", "NZDCHF", "GBPNZD", "EURNZD", "GBPCAD",
"GBPAUD", "AUDCHF", "CADCHF", "CADJPY"};
string gsa_104[] = {

"AUDCAD", "AUDCHF", "AUDJPY", "AUDNZD", "AUDUSD", "BGNRON", "CADCHF",


"CADJPY", "CHFBGN", "CHFJPY",

"CHFRON", "CHFTRY", "EURAUD", "EURCAD", "EURCHF", "EURCZK", "EURDKK",


"EURGBP", "EURHKD", "EURHUF",

"EURILS", "EURJPY", "EURMXN", "EURNOK", "EURNZD", "EURPLN", "EURRON",


"EURRUB", "EURSEK", "EURSGD",

"EURTRY", "EURUSD", "EURZAR", "GBPAUD", "GBPBGN", "GBPCAD", "GBPCHF",


"GBPCZK", "GBPDKK", "GBPHKD",

"GBPHUF", "GBPJPY", "GBPNOK", "GBPNZD", "GBPPLN", "GBPRON", "GBPSEK",


"GBPSGD", "GBPTRY", "GBPUSD",

"GBPZAR", "HKDJPY", "MXNJPY", "NZDCAD", "NZDCHF", "NZDJPY", "NZDUSD",


"SGDHKD", "SGDJPY", "TRYBGN",

"TRYJPY", "TRYRON", "USDBGN", "USDCAD", "USDCHF", "USDCZK", "USDDKK",


"USDHKD", "USDHUF", "USDILS",

"USDJPY", "USDMXN", "USDNOK", "USDPLN", "USDRON", "USDRUB", "USDSEK",


"USDSGD", "USDTRY", "USDZAR",

"XAUUSD","XAGUSD"

};

string gsa_108[] = {"GBPJPY", "AUDJPY", "EURJPY", "USDJPY", "NZDJPY", "CHFJPY", "GBPUSD",


"AUDUSD", "EURUSD", "NZDUSD", "USDCAD", "USDCHF"};

double gd_112;

double gd_120;

double gd_128;

double gd_136;

double gd_144;

double gd_152;

double gd_160;
//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int OnInit()

//--- indicator buffers mapping

ChartSetInteger(0,CHART_SHOW_BID_LINE,false);

ChartSetInteger(0,CHART_SHOW_ASK_LINE,false);

bid.Create(0,"__bid__",0,0.0);

bid.Color(InpBidColor);

bid.Tooltip("Bid");

if(InpShowAsk)

ask.Create(0,"__ask__",0,0.0);

ask.Color(InpAskColor);

ask.Tooltip("Ask");

//---

return(INIT_SUCCEEDED);

int deinit()

ObjectDelete(OBJ_NAME);

CleanUp();

return(0);
}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int OnCalculate(const int rates_total,

const int prev_calculated,

const datetime &time[],

const double &open[],

const double &high[],

const double &low[],

const double &close[],

const long &tick_volume[],

const long &volume[],

const int &spread[])

//-----------------------------------------

// -- spread

//-----------------------------------------

if (UseSpreadMonitor == true)

ShowSpread();

//-----------------------------------------

// -- csm

//-----------------------------------------

if (ShowCSM) displayMeter();

//-----------------------------------------

// -- thick
//-----------------------------------------

if (ShowTick == true)

int limit;

int counted_bars=IndicatorCounted();

//---- last counted bar will be recounted

if(counted_bars<0) return (-1);

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

if (limit > 10000) limit = 10000;

for (int i=0; i<limit; i++) { // process all bars in the chart

if (DisplayInfo) ShowInfo();

//-----------------------------------------

// -- Profit Loss

//-----------------------------------------

if (UseProfitLossInfo == true)

int j;

int idx;

string text;

double PL;

double total;
//----

if(x != NULL) {

for(idx = 0; idx<x; idx++) {

ObjectDelete("O"+idx);

ObjectDelete("PL"+idx);

ObjectDelete("Total1");

ObjectDelete("Total2");

text = "";

j=0;

total = 0;

//DisplayText("h", "Profit/Loss Info ", Size_Font, Color_Text, 0, posX, posY , Text_Font);

for (int ih = OrdersTotal()-1 ; ih >= 0; ih--)

if(OrderSelect(ih, SELECT_BY_POS, MODE_TRADES) == true)

if(OrderType() == OP_BUY) {

//DisplayText("O"+j, OrderSymbol() + " (" + OrderTicket() + ")" + " ", Font,


Color_Order_Buy, 0, 5, 25 + j * 18, "Arial Bold");

DisplayText("O"+j, OrderSymbol() + " ", Size_Font, Color_Order_Buy, 0, posX, posY+20 + j *


18, Text_Font);
PL = (OrderClosePrice()-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT);

total = total + PL;

if(PL<0) DisplayText("PL"+j, "= "+DoubleToStr(PL, 0)+ " point ", Size_Font, Color_Loss, 0,
posX+129, posY+20 + j * 18, Text_Font);

else if(PL>0) DisplayText("PL"+j, "= +"+DoubleToStr(PL, 0)+ " point ", Size_Font,
Color_Profit, 0, posX+129, posY+20 + j * 18, Text_Font);

else DisplayText("PL"+j, "= "+DoubleToStr(PL, 0)+ " point ", Size_Font, Color_Text, 0,
posX+129, posY+20 + j * 18, Text_Font);

else if(OrderType() == OP_SELL) {

//DisplayText("O"+j, OrderSymbol() + " (" + OrderTicket() + ")" + " ", Font,


Color_Order_Sell, 0, posX, 25 + j * 18, Text_Font);

DisplayText("O"+j, OrderSymbol() + " ", Size_Font, Color_Order_Sell, 0, posX, posY+20 + j *


18, Text_Font);

PL = (OrderOpenPrice()-OrderClosePrice())/MarketInfo(OrderSymbol(),MODE_POINT);

total = total + PL;

if(PL<0) DisplayText("PL"+j, "= "+DoubleToStr(PL, 0)+ " point " , Size_Font, Color_Loss, 0,
posX+129, posY+20 + j * 18, Text_Font);

else if(PL>0) DisplayText("PL"+j,"= +"+DoubleToStr(PL, 0)+ " point " , Size_Font,


Color_Profit, 0, posX+129, posY+20 + j * 18, Text_Font);

else DisplayText("PL"+j,"= "+DoubleToStr(PL, 0) + " point ", Size_Font, Color_Text, 0,


posX+129, posY+20 + j * 18, Text_Font);

j=j+1;

// menghitung total LABA / RUGI

double LR = AccountEquity() - AccountBalance();

string sLR = DoubleToStr(LR,2);


DisplayText("Total1","Total Profit/Loss = ", Size_Font, Color_Text, 0, posX, posY+20 + j * 18,
Text_Font);

if(total<0) DisplayText("Total2", DoubleToStr(total, 0) + " point ", Size_Font, Color_Loss, 0,


posX+143, posY+20 + j * 18, Text_Font);

else if (total>0) DisplayText("Total2","+" + DoubleToStr(total, 0) + " point ", Size_Font,


Color_Profit, 0, posX+143, posY+20 + j * 18, Text_Font);

else DisplayText("Total2", DoubleToStr(total, 0) + " point ", Size_Font, Color_Text, 0, posX+143,


posY+20 + j * 18, Text_Font);

x=j;

//---

MqlTick tick;

SymbolInfoTick(_Symbol,tick);

bid.Price(0,tick.bid);

if(InpShowAsk)

ask.Price(0,tick.ask);

//--- return value of prev_calculated for next call

return(rates_total);

//+------------------------------------------------------------------+

void ShowSpread()

static double spread;

spread = MarketInfo(Symbol(), MODE_SPREAD);


DrawSpreadOnChart(spread);

void DrawSpreadOnChart(double spread)

string s = "Spread: "+DoubleToStr(spread, 0)+" points";

if(ObjectFind(OBJ_NAME) < 0)

ObjectCreate(OBJ_NAME, OBJ_LABEL, 0, 0, 0);

ObjectSet(OBJ_NAME, OBJPROP_CORNER, Corner);

ObjectSet(OBJ_NAME, OBJPROP_YDISTANCE, YPos);

ObjectSet(OBJ_NAME, OBJPROP_XDISTANCE, XPos);

ObjectSetText(OBJ_NAME, s, 10, "FixedSys", LabelColor);

ObjectSetText(OBJ_NAME, s);

WindowRedraw();

//-----------------------------------

void DisplayText(string objname, string text, int fontsize, color clr, double C, double X, double Y,
string font)

ObjectDelete(objname);

ObjectCreate(objname, OBJ_LABEL, 0, 0, 0);

ObjectSetText(objname, text, fontsize, font, clr);

ObjectSet(objname, OBJPROP_CORNER, 2);


ObjectSet(objname, OBJPROP_XDISTANCE, X);

ObjectSet(objname, OBJPROP_YDISTANCE, Y);

//-----------------------------------

void CleanUp() {

ObjectsDeleteAll(0);

void ShowInfo() {

double spread;

datetime bartimeleft;

int Y=0;

int Ya=0;

int Yb=0;

int Yc=0;

int Yd=0;

int Yall=0;

color trendcol=DimGray;

color trendcola=DimGray;

color trendcolb=DimGray;

color trendcolc=DimGray;

color trendcold=DimGray;

color trendcolall=DimGray;

string time;

UpdateTimes(); // sync clocks


Write("Div01", 10, 12, "----------------------------------------------------------------------------------------------------
-", 10, DimGray, "Arial");

for (int i=0;i<6;i++)

if (UseBackground == true)

Write("Info01", 0, 0, "ggggggggggggg", 16, BackgroundColor, "Webdings");

//Write("Info20", 9, 5, "SaminForexLab" , 11, Silver, "Arial");

//Write("Info21", 8, 4, "SaminForexLab" , 11, Navy, "Arial");

Write("Info1"+i, 0, 25+21*i, "ggggggggggggg", 16, BackgroundColor, "Webdings");

//Write("Div02", 10, 115,"-------------------------------------------------------------------------------------------------


----", 10, DimGray, "Arial");

Write("Ticker", 180,3, StringSubstr(TICKS, 0, tickpos), 9, Gold, "Webdings");

tickpos++; if (tickpos>StringLen(TICKS)-1) tickpos=1;

// show time and GMT informations

Write("Time01", 30,20, StringSubstr(CLOCKS, TimeHour(localtime), 1), 30, DimGray, "Wingdings");

Write("Time02", 118,20,StringSubstr(CLOCKS, TimeHour(gmttime), 1), 30, DimGray, "Wingdings");

Write("Time03", 206,20,StringSubstr(CLOCKS, TimeHour(brokertime),1), 30, DimGray,


"Wingdings");

Write("Time11", 33,56, TimeToStr(localtime, TIME_MINUTES), 8, DimGray, "Arial");

Write("Time12",120,56, TimeToStr(gmttime, TIME_MINUTES), 8, DimGray, "Arial");

Write("Time13",209,56, TimeToStr(brokertime, TIME_MINUTES), 8, DimGray, "Arial");

if (localtime>gmttime) time="+"; else time="-";

Write("Time21",12, 70, "Local (GMT"+time+GMTlocaloffset+")", 8, SlateGray, "Arial");

Write("Time22",123,70, "GMT", 8, SlateGray, "Arial");

if (brokertime>gmttime) time="+"; else time="-";

Write("Time23",186,70, "Broker (GMT"+time+GMTbrokeroffset+")", 8, SlateGray, "Arial");


Write("Time24", 10, 76,"--------------------------------------------------------------------------------------------------
---", 10, DimGray, "Arial");

/*

// jam

int li_8 = Time[0] + 60 * Period() - TimeCurrent();

double ld_0 = li_8 / 60.0;

int li_12 = li_8 % 60;

li_8 = (li_8 - li_8 % 60) / 60;

Write("Time25", 20,100, gs_112 + " Bar end: " + li_8 + " m " + li_12 + " s ", 10, PowderBlue, "Arial
Bold");

int li_20 = TimeHour(Time[0]);

if (li_20 > 11) li_20 -= 12;

*/

void UpdateTimes() {

localtime = TimeLocal();

if (GMTlocaloffset>0) gmttime= localtime-(GMTlocaloffset*3600);

else gmttime = localtime+(GMTlocaloffset*3600);

brokertime = TimeCurrent();

}
void Write(string name, int x, int y, string text, int size, color col, string font="Lucida Console") {

if (ObjectFind(name)==-1) ObjectCreate(name, OBJ_LABEL, 0, 0, 0);

ObjectSetText(name, text, size, font, col);

ObjectSet(name, OBJPROP_CORNER, 1);

ObjectSet(name, OBJPROP_BACK, false);

ObjectSet(name, OBJPROP_XDISTANCE, x + XDst);

ObjectSet(name, OBJPROP_YDISTANCE, y + YDst);

//+------------------------------------------------------------------+

// expert CSM |

//+------------------------------------------------------------------+

double currency_strength(string as_0) {

int Li_16;

string Ls_28;

double Ld_36;

double Ld_44;

double Ld_ret_8 = 0;

int L_count_20 = 0;

for (int L_index_24 = 0; L_index_24 < ArraySize(gsa_104); L_index_24++) {

Li_16 = 0;

Ls_28 = gsa_104[L_index_24];

if (as_0 == StringSubstr(Ls_28, 0, 3) || as_0 == StringSubstr(Ls_28, 3, 3)) {

Ld_36 = (MarketInfo(Ls_28, MODE_HIGH) - MarketInfo(Ls_28, MODE_LOW)) *


MarketInfo(Ls_28, MODE_POINT);

if (Ld_36 != 0.0) {

Ld_44 = 100.0 * ((MarketInfo(Ls_28, MODE_BID) - MarketInfo(Ls_28, MODE_LOW)) / Ld_36 *


MarketInfo(Ls_28, MODE_POINT));
if (Ld_44 > 3.0) Li_16 = 1;

if (Ld_44 > 10.0) Li_16 = 2;

if (Ld_44 > 25.0) Li_16 = 3;

if (Ld_44 > 40.0) Li_16 = 4;

if (Ld_44 > 50.0) Li_16 = 5;

if (Ld_44 > 60.0) Li_16 = 6;

if (Ld_44 > 75.0) Li_16 = 7;

if (Ld_44 > 90.0) Li_16 = 8;

if (Ld_44 > 97.0) Li_16 = 9;

L_count_20++;

if (as_0 == StringSubstr(Ls_28, 3, 3)) Li_16 = 9 - Li_16;

Ld_ret_8 += Li_16;

Ld_ret_8 /= L_count_20;

return (Ld_ret_8);

void displayMeter() {

color L_color_0;

string L_name_12;

string Ls_20 = "Meter";

double Ld_4 = 0;

int L_x_28 = 220;

int L_index_32 ;

for (int L_index_32 = 0; L_index_32 < ArraySize(gsa_100); L_index_32++) {


Ld_4++;

L_name_12 = Ls_20 + DoubleToStr(Ld_4, 0);

ObjectCreate(L_name_12, OBJ_LABEL, 0, 0, 0);

ObjectSetText(L_name_12, gsa_100[L_index_32], 9, "Arial Bold", Paircolor);

ObjectSet(L_name_12, OBJPROP_CORNER, 3);

ObjectSet(L_name_12, OBJPROP_XDISTANCE, L_x_28);

ObjectSet(L_name_12, OBJPROP_YDISTANCE, 30);

L_x_28 -= 30;

L_x_28 = 221;

for (L_index_32 = 0; L_index_32 < ArraySize(gsa_100); L_index_32++) {

Ld_4++;

L_name_12 = Ls_20 + DoubleToStr(Ld_4, 0);

L_color_0 = symcolor(currency_strength(gsa_100[L_index_32]));

ObjectCreate(L_name_12, OBJ_LABEL, 0, 0, 0);

ObjectSetText(L_name_12, DoubleToStr(currency_strength(gsa_100[L_index_32]), 2), 9, "Arial


Bold", L_color_0);

ObjectSet(L_name_12, OBJPROP_CORNER, 3);

ObjectSet(L_name_12, OBJPROP_XDISTANCE, L_x_28);

ObjectSet(L_name_12, OBJPROP_YDISTANCE, 17);

L_x_28 -= 30;

ObjectCreate("Sym Line1", OBJ_LABEL, 0, 0, 0);

ObjectSetText("Sym Line1", "__________________________________", 10, "Arial Bold",


Linecolor);

ObjectSet("Sym Line1", OBJPROP_CORNER, 3);

ObjectSet("Sym Line1", OBJPROP_XDISTANCE, 10);

ObjectSet("Sym Line1", OBJPROP_YDISTANCE, 45);


ObjectCreate("Sym Line2", OBJ_LABEL, 0, 0, 0);

ObjectSetText("Sym Line2", "__________________________________", 10, "Arial Bold",


Linecolor);

ObjectSet("Sym Line2", OBJPROP_CORNER, 3);

ObjectSet("Sym Line2", OBJPROP_XDISTANCE, 10);

ObjectSet("Sym Line2", OBJPROP_YDISTANCE, 16);

ObjectSet("HiLo Info", OBJPROP_CORNER, 3);

ObjectSet("HiLo Info", OBJPROP_XDISTANCE, 13);

ObjectSet("HiLo Info", OBJPROP_YDISTANCE, 5);

int symcolor(double ad_0) {

int li_ret_8;

//if (ad_0 <= 2.0) li_ret_8 = 3937500;

//if (ad_0 > 2.0) li_ret_8 = 16777215;

//if (ad_0 >= 7.0) li_ret_8 = 65280;

if (ad_0 <= 2.0) li_ret_8 = Lowcolor;

if (ad_0 > 2.0) li_ret_8 = Mediumcolor;

if (ad_0 >= 7.0) li_ret_8 = Highcolor;

return (li_ret_8);

//+------------------------------------------------------------------+

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy