Created
March 22, 2016 14:07
-
-
Save APPEA/3141b8d6442b0732a563 to your computer and use it in GitHub Desktop.
拆彈指標
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
#property indicator_buffers 4 | |
#property indicator_color1 LawnGreen | |
#property indicator_color2 LawnGreen | |
#property indicator_color3 OrangeRed | |
#property indicator_color4 RoyalBlue | |
extern color color1 = Red; | |
extern color color2 = SkyBlue; | |
extern color color3 = Red; | |
extern color color4 = SkyBlue; | |
double gda_92[]; | |
double gda_96[]; | |
double gda_100[]; | |
double gda_104[]; | |
int gi_108 = 0; | |
int init() { | |
SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 1, color1); | |
SetIndexBuffer(0, gda_92); | |
SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 1, color2); | |
SetIndexBuffer(1, gda_96); | |
SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 3, color3); | |
SetIndexBuffer(2, gda_100); | |
SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, 3, color4); | |
SetIndexBuffer(3, gda_104); | |
SetIndexDrawBegin(0, 10); | |
SetIndexDrawBegin(1, 10); | |
SetIndexDrawBegin(2, 10); | |
SetIndexDrawBegin(3, 10); | |
SetIndexBuffer(0, gda_92); | |
SetIndexBuffer(1, gda_96); | |
SetIndexBuffer(2, gda_100); | |
SetIndexBuffer(3, gda_104); | |
return (0); | |
} | |
int deinit() { | |
return (0); | |
} | |
int start() { | |
double ld_0; | |
double ld_8; | |
double ld_16; | |
double ld_24; | |
if (Bars <= 10) return (0); | |
gi_108 = IndicatorCounted(); | |
if (gi_108 < 0) return (-1); | |
if (gi_108 > 0) gi_108--; | |
for (int li_32 = Bars - gi_108 - 1; li_32 >= 0; li_32--) { | |
ld_0 = (gda_100[li_32 + 1] + (gda_104[li_32 + 1])) / 2.0; | |
ld_24 = (Open[li_32] + High[li_32] + Low[li_32] + Close[li_32]) / 4.0; | |
ld_8 = MathMax(High[li_32], MathMax(ld_0, ld_24)); | |
ld_16 = MathMin(Low[li_32], MathMin(ld_0, ld_24)); | |
if (ld_0 < ld_24) { | |
gda_92[li_32] = ld_16; | |
gda_96[li_32] = ld_8; | |
} else { | |
gda_92[li_32] = ld_8; | |
gda_96[li_32] = ld_16; | |
} | |
gda_100[li_32] = ld_0; | |
gda_104[li_32] = ld_24; | |
} | |
return (0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
#property indicator_buffers 1 | |
#property indicator_color1 DarkTurquoise | |
int TimeShift = 0; | |
double gda_80[]; | |
double gd_84; | |
double gd_92; | |
int deinit() { | |
return (0); | |
} | |
int init() { | |
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 3, DarkTurquoise); | |
SetIndexBuffer(0, gda_80); | |
IndicatorShortName("Daily- Pivot"); | |
SetIndexLabel(0, "Daily- Pivot"); | |
SetIndexDrawBegin(0, 1); | |
return (0); | |
} | |
int start() { | |
int li_0 = IndicatorCounted(); | |
if (li_0 == 0) { | |
gd_92 = Period(); | |
if (gd_92 > 240.0) return (-1); | |
} | |
if (li_0 < 0) return (-1); | |
int li_4 = Bars - li_0 - 1; | |
for (int li_8 = li_4; li_8 >= 0; li_8--) { | |
if (TimeDay(Time[li_8]) != TimeDay(Time[li_8 + 1])) gd_84 = Open[li_8 - TimeShift]; | |
gda_80[li_8 - TimeShift] = gd_84; | |
} | |
return (0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
bool Bid_Ask_Colors = TRUE; | |
color FontColor = Black; | |
string FontType = "Tahoma"; | |
int FontSize = 36; | |
int Corner = 3; | |
double gd_100; | |
int init() { | |
return (0); | |
} | |
int deinit() { | |
ObjectDelete("MarketPrice"); | |
ObjectDelete("Symbol"); | |
return (0); | |
} | |
int start() { | |
if (Bid_Ask_Colors == TRUE) { | |
if (Bid > gd_100) FontColor = SkyBlue; | |
if (Bid < gd_100) FontColor = Red; | |
gd_100 = Bid; | |
} | |
string ls_0 = DoubleToStr(Bid, Digits); | |
ObjectCreate("MarketPrice", OBJ_LABEL, 0, 0, 0); | |
ObjectSetText("MarketPrice", ls_0, FontSize, FontType, FontColor); | |
ObjectSet("MarketPrice", OBJPROP_CORNER, Corner); | |
ObjectSet("MarketPrice", OBJPROP_XDISTANCE, 1); | |
ObjectSet("MarketPrice", OBJPROP_YDISTANCE, 1); | |
string time; | |
if (Period()<60) time="-M"+Period(); | |
if (Period()>=60) time="-H"+Period()/60; | |
if (Period()>=1440) time="-D"+Period()/1440; | |
string msg=Symbol()+time; | |
ObjectCreate("Symbol", OBJ_LABEL, 0, 0, 0); | |
ObjectSetText("Symbol", msg, 24, FontType, FontColor); | |
ObjectSet("Symbol", OBJPROP_CORNER, Corner); | |
ObjectSet("Symbol", OBJPROP_XDISTANCE, 1); | |
ObjectSet("Symbol", OBJPROP_YDISTANCE, 1+50); | |
return (0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
#property indicator_buffers 2 | |
#property indicator_color1 SkyBlue | |
#property indicator_color2 Red | |
double gda_76[]; | |
double gda_80[]; | |
int Fastsignal = 4; | |
int Slowsignal = 8; | |
bool SoundON = TRUE; | |
double gd_96; | |
double gd_104 = EMPTY_VALUE; | |
int init() { | |
SetIndexStyle(0, DRAW_ARROW, EMPTY, 3); | |
SetIndexArrow(0, 233); | |
SetIndexBuffer(0, gda_76); | |
SetIndexStyle(1, DRAW_ARROW, EMPTY, 3); | |
SetIndexArrow(1, 234); | |
SetIndexBuffer(1, gda_80); | |
return (0); | |
} | |
int deinit() { | |
return (0); | |
} | |
int start() { | |
int li_8; | |
double ld_12; | |
double ld_20; | |
double ld_28; | |
double ld_36; | |
double ld_44; | |
double ld_52; | |
double ld_60; | |
double ld_68; | |
int li_76 = IndicatorCounted(); | |
if (li_76 < 0) return (-1); | |
if (li_76 > 0) li_76--; | |
int li_0 = Bars - li_76; | |
for (int li_4 = 0; li_4 <= li_0; li_4++) { | |
li_8 = li_4; | |
ld_60 = 0; | |
ld_68 = 0; | |
for (li_8 = li_4; li_8 <= li_4 + 9; li_8++) ld_68 += MathAbs(High[li_8] - Low[li_8]); | |
ld_60 = ld_68 / 10.0; | |
ld_12 = iMA(NULL, 0, Fastsignal, 0, MODE_EMA, PRICE_CLOSE, li_4); | |
ld_28 = iMA(NULL, 0, Fastsignal, 0, MODE_EMA, PRICE_CLOSE, li_4 + 1); | |
ld_44 = iMA(NULL, 0, Fastsignal, 0, MODE_EMA, PRICE_CLOSE, li_4 - 1); | |
ld_20 = iMA(NULL, 0, Slowsignal, 0, MODE_EMA, PRICE_CLOSE, li_4); | |
ld_36 = iMA(NULL, 0, Slowsignal, 0, MODE_EMA, PRICE_CLOSE, li_4 + 1); | |
ld_52 = iMA(NULL, 0, Slowsignal, 0, MODE_EMA, PRICE_CLOSE, li_4 - 1); | |
if (ld_12 > ld_20 && ld_28 < ld_36 && ld_44 > ld_52) gda_76[li_4] = Low[li_4] - ld_60 / 2.0; | |
else | |
if (ld_12 < ld_20 && ld_28 > ld_36 && ld_44 < ld_52) gda_80[li_4] = High[li_4] + ld_60 / 2.0; | |
if (SoundON == TRUE && li_4 == 1 && gda_76[li_4] > gda_80[li_4] && gd_96 != Time[0]) { | |
Alert("Sell Signal ", Symbol(), " ", Period()); | |
gd_96 = Time[0]; | |
} | |
if (SoundON == TRUE && li_4 == 1 && gda_76[li_4] < gda_80[li_4] && gd_96 != Time[0]) { | |
Alert("Buy Signal ", Symbol(), " ", Period()); | |
gd_96 = Time[0]; | |
} | |
} | |
return (0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
#property indicator_buffers 6 | |
#property indicator_color1 Yellow | |
#property indicator_color2 Yellow | |
#property indicator_color3 Fuchsia | |
#property indicator_color4 Fuchsia | |
#property indicator_color5 Lime | |
#property indicator_color6 Red | |
bool Sound_Alert = FALSE; | |
double Period1 = 5.0; | |
double Period2 = 13.0; | |
double Period3 = 34.0; | |
string Dev_Step_1 = "1,3"; | |
string Dev_Step_2 = "8,5"; | |
string Dev_Step_3 = "13,8"; | |
int Symbol_1_Kod = 170; | |
int Symbol_2_Kod = 174; | |
int Symbol_3_Kod = 175; | |
double gda_140[]; | |
double gda_144[]; | |
double gda_148[]; | |
double gda_152[]; | |
double gda_156[]; | |
double gda_160[]; | |
int gi_164; | |
int gi_168; | |
int gi_172; | |
int gi_176; | |
int gi_180; | |
int gi_184; | |
int gi_188; | |
int gi_192; | |
int gi_196; | |
string gs_200; | |
string gs_208; | |
string gs_216; | |
int gi_224; | |
int gi_228; | |
bool gi_232; | |
bool gi_236; | |
bool gi_240; | |
int gi_244 = -1; | |
int gi_248 = 65535; | |
int init() { | |
int lia_0[]; | |
gi_228 = Period(); | |
gs_208 = TimeFrameToString(gi_228); | |
gs_200 = Symbol(); | |
gi_224 = Digits; | |
gs_216 = "tbb" + gs_200 + gs_208; | |
if (Period1 > 0.0) gi_164 = MathCeil(Period1 * Period()); | |
else gi_164 = 0; | |
if (Period2 > 0.0) gi_168 = MathCeil(Period2 * Period()); | |
else gi_168 = 0; | |
if (Period3 > 0.0) gi_172 = MathCeil(Period3 * Period()); | |
else gi_172 = 0; | |
if (Period1 > 0.0) { | |
SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, 1); | |
SetIndexArrow(0, Symbol_1_Kod); | |
SetIndexBuffer(0, gda_140); | |
SetIndexEmptyValue(0, 0.0); | |
SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, 1); | |
SetIndexArrow(1, Symbol_1_Kod); | |
SetIndexBuffer(1, gda_144); | |
SetIndexEmptyValue(1, 0.0); | |
} | |
if (Period2 > 0.0) { | |
SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID, 2); | |
SetIndexArrow(2, Symbol_2_Kod); | |
SetIndexBuffer(2, gda_148); | |
SetIndexEmptyValue(2, 0.0); | |
SetIndexStyle(3, DRAW_ARROW, STYLE_SOLID, 2); | |
SetIndexArrow(3, Symbol_2_Kod); | |
SetIndexBuffer(3, gda_152); | |
SetIndexEmptyValue(3, 0.0); | |
} | |
if (Period3 > 0.0) { | |
SetIndexStyle(4, DRAW_ARROW, STYLE_SOLID, 4); | |
SetIndexArrow(4, Symbol_3_Kod); | |
SetIndexBuffer(4, gda_156); | |
SetIndexEmptyValue(4, 0.0); | |
SetIndexStyle(5, DRAW_ARROW, STYLE_SOLID, 4); | |
SetIndexArrow(5, Symbol_3_Kod); | |
SetIndexBuffer(5, gda_160); | |
SetIndexEmptyValue(5, 0.0); | |
} | |
int li_4 = 0; | |
int li_8 = 0; | |
int li_12 = 0; | |
if (IntFromStr(Dev_Step_1, li_12, lia_0) == 1) { | |
gi_180 = lia_0[1]; | |
gi_176 = lia_0[0]; | |
} | |
if (IntFromStr(Dev_Step_2, li_12, lia_0) == 1) { | |
gi_188 = lia_0[1]; | |
gi_184 = lia_0[0]; | |
} | |
if (IntFromStr(Dev_Step_3, li_12, lia_0) == 1) { | |
gi_196 = lia_0[1]; | |
gi_192 = lia_0[0]; | |
} | |
return (0); | |
} | |
int deinit() { | |
return (0); | |
} | |
int start() { | |
if (Bars != gi_244) { | |
gi_232 = TRUE; | |
gi_236 = TRUE; | |
gi_240 = TRUE; | |
} | |
if (Period1 > 0.0) CountZZ(gda_140, gda_144, Period1, gi_176, gi_180); | |
if (Period2 > 0.0) CountZZ(gda_148, gda_152, Period2, gi_184, gi_188); | |
if (Period3 > 0.0) CountZZ(gda_156, gda_160, Period3, gi_192, gi_196); | |
if (gi_232 && Sound_Alert) { | |
if (gda_140[0] != 0.0) { | |
gi_232 = FALSE; | |
Alert(gs_200, " ", gs_208, " Level 1 Lower " + DoubleToStr(Close[0], gi_224)); | |
} | |
if (gda_144[0] != 0.0) { | |
gi_232 = FALSE; | |
Alert(gs_200, " ", gs_208, " Level 1 Upper " + DoubleToStr(Close[0], gi_224)); | |
} | |
} | |
if (gi_236 && Sound_Alert) { | |
if (gda_148[0] != 0.0) { | |
gi_236 = FALSE; | |
Alert(gs_200, " ", gs_208, " Level 2 Lower " + DoubleToStr(Close[0], gi_224)); | |
} | |
if (gda_152[0] != 0.0) { | |
gi_236 = FALSE; | |
Alert(gs_200, " ", gs_208, " Level 2 Upper " + DoubleToStr(Close[0], gi_224)); | |
} | |
} | |
if (gi_240 && Sound_Alert) { | |
if (gda_156[0] != 0.0) { | |
gi_240 = FALSE; | |
Alert(gs_200, " ", gs_208, " Level 3 Lower " + DoubleToStr(Close[0], gi_224)); | |
} | |
if (gda_160[0] != 0.0) { | |
gi_240 = FALSE; | |
Alert(gs_200, " ", gs_208, " Level 3 Upper " + DoubleToStr(Close[0], gi_224)); | |
} | |
} | |
gi_244 = Bars; | |
return (0); | |
} | |
string TimeFrameToString(int ai_0) { | |
string ls_4; | |
switch (ai_0) { | |
case 1: | |
ls_4 = "M1"; | |
break; | |
case 5: | |
ls_4 = "M5"; | |
break; | |
case 15: | |
ls_4 = "M15"; | |
break; | |
case 30: | |
ls_4 = "M30"; | |
break; | |
case 60: | |
ls_4 = "H1"; | |
break; | |
case 240: | |
ls_4 = "H4"; | |
break; | |
case 1440: | |
ls_4 = "D1"; | |
break; | |
case 10080: | |
ls_4 = "W1"; | |
break; | |
case 43200: | |
ls_4 = "MN"; | |
} | |
return (ls_4); | |
} | |
int CountZZ(double &ada_0[], double &ada_4[], int ai_8, int ai_12, int ai_16) { | |
double ld_20; | |
double ld_28; | |
double ld_36; | |
double ld_44; | |
double ld_52; | |
double ld_60; | |
for (int li_68 = Bars - ai_8; li_68 >= 0; li_68--) { | |
ld_20 = Low[iLowest(NULL, 0, MODE_LOW, ai_8, li_68)]; | |
if (ld_20 == ld_60) ld_20 = 0.0; | |
else { | |
ld_60 = ld_20; | |
if (Low[li_68] - ld_20 > ai_12 * Point) ld_20 = 0.0; | |
else { | |
for (int li_72 = 1; li_72 <= ai_16; li_72++) { | |
ld_28 = ada_0[li_68 + li_72]; | |
if (ld_28 != 0.0 && ld_28 > ld_20) ada_0[li_68 + li_72] = 0.0; | |
} | |
} | |
} | |
ada_0[li_68] = ld_20; | |
ld_20 = High[iHighest(NULL, 0, MODE_HIGH, ai_8, li_68)]; | |
if (ld_20 == ld_52) ld_20 = 0.0; | |
else { | |
ld_52 = ld_20; | |
if (ld_20 - High[li_68] > ai_12 * Point) ld_20 = 0.0; | |
else { | |
for (li_72 = 1; li_72 <= ai_16; li_72++) { | |
ld_28 = ada_4[li_68 + li_72]; | |
if (ld_28 != 0.0 && ld_28 < ld_20) ada_4[li_68 + li_72] = 0.0; | |
} | |
} | |
} | |
ada_4[li_68] = ld_20; | |
} | |
ld_52 = -1; | |
int li_76 = -1; | |
ld_60 = -1; | |
int li_80 = -1; | |
for (li_68 = Bars - ai_8; li_68 >= 0; li_68--) { | |
ld_36 = ada_0[li_68]; | |
ld_44 = ada_4[li_68]; | |
if (ld_36 == 0.0 && ld_44 == 0.0) continue; | |
if (ld_44 != 0.0) { | |
if (ld_52 > 0.0) { | |
if (ld_52 < ld_44) ada_4[li_76] = 0; | |
else ada_4[li_68] = 0; | |
} | |
if (ld_52 < ld_44 || ld_52 < 0.0) { | |
ld_52 = ld_44; | |
li_76 = li_68; | |
} | |
ld_60 = -1; | |
} | |
if (ld_36 != 0.0) { | |
if (ld_60 > 0.0) { | |
if (ld_60 > ld_36) ada_0[li_80] = 0; | |
else ada_0[li_68] = 0; | |
} | |
if (ld_36 < ld_60 || ld_60 < 0.0) { | |
ld_60 = ld_36; | |
li_80 = li_68; | |
} | |
ld_52 = -1; | |
} | |
} | |
for (li_68 = Bars - 1; li_68 >= 0; li_68--) { | |
if (li_68 >= Bars - ai_8) ada_0[li_68] = 0.0; | |
else { | |
ld_28 = ada_4[li_68]; | |
if (ld_28 != 0.0) ada_4[li_68] = ld_28; | |
} | |
} | |
return (0); | |
} | |
int Str2Massive(string as_0, int &ai_8, int &aia_12[]) { | |
int li_16; | |
int li_20 = StrToInteger(as_0); | |
if (li_20 > 0) { | |
ai_8++; | |
li_16 = ArrayResize(aia_12, ai_8); | |
if (li_16 == 0) return (-1); | |
aia_12[ai_8 - 1] = li_20; | |
return (1); | |
} | |
return (0); | |
} | |
int IntFromStr(string as_0, int &ai_8, int& aia_12[]) { | |
string ls_16; | |
if (StringLen(as_0) == 0) return (-1); | |
string ls_24 = as_0; | |
int li_32 = 0; | |
ai_8 = 0; | |
ArrayResize(aia_12, ai_8); | |
while (StringLen(ls_24) > 0) { | |
li_32 = StringFind(ls_24, ","); | |
if (li_32 > 0) { | |
ls_16 = StringSubstr(ls_24, 0, li_32); | |
ls_24 = StringSubstr(ls_24, li_32 + 1, StringLen(ls_24)); | |
} else { | |
if (StringLen(ls_24) > 0) { | |
ls_16 = ls_24; | |
ls_24 = ""; | |
} | |
} | |
if (Str2Massive(ls_16, ai_8, aia_12) == 0) return (-2); | |
} | |
return (1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//+------------------------------------------------------------------+ | |
//| AutoTrendChannel.mq4 | | |
//| Copyright ?2006, MetaQuotes Software Corp. | | |
//| http://www.metaquotes.net | | |
//+------------------------------------------------------------------+ | |
/********************************************************************* | |
* Author: | |
* Original Author: | |
* Date: December 14, 2006 | |
* Custom Indicator: .mq4 | |
* Version: 1.0.1 | |
* Description: Trend Detector | |
* | |
* Change Logs | |
* Version 1.0.1 | |
* - Rewriting Code. Multi Color. | |
* Other function will add next release :) | |
* | |
* Version ang_AutoCh_HL-v1 | |
* - Release by | |
**********************************************************************/ | |
#property indicator_chart_window | |
int Hours = 24; | |
color col_bull = Blue; | |
color col_mid = SkyBlue; | |
color col_bear = Red; | |
//------------------ | |
double lr,lr0,lrp; | |
double sx,sy,sxy,sx2,aa,bb; | |
int p,fs; | |
int f,f0,f1; | |
double dh,dl,dh_1,dl_1,dh_2,dl_2; | |
int ai_1,ai_2,bi_1,bi_2; | |
double hai,lai,dhi,dli,dhm,dlm,ha0,hap,la0,lap; | |
double price_p1,price_p0,price_p2,price_01,price_00,price_02; | |
int p1,p0,p2,fp; | |
string sName = "BombRemovable7"; | |
int init() { | |
p = Hours*60/Period(); | |
if (fs==0) { | |
fs = 1; | |
} | |
return(0); | |
} | |
//******************************* | |
int deinit() { | |
ObjectDelete("1"+sName); | |
ObjectDelete("0"+sName); | |
ObjectDelete("2"+sName); | |
return(0); | |
} | |
//******************************* | |
int start() { | |
int i,n; | |
//------------------------------------------------------------------------------ | |
if (f==1) { | |
p1=iBarShift(Symbol(),Period(),ObjectGet("1"+sName,OBJPROP_TIME1)); | |
p0=iBarShift(Symbol(),Period(),ObjectGet("0"+sName,OBJPROP_TIME1)); | |
p2=iBarShift(Symbol(),Period(),ObjectGet("2"+sName,OBJPROP_TIME1)); | |
//if (fp==0 && p!=p1) {p=p1; fp=1;} | |
//if (fp==0 && p!=p0) {p=p0; fp=1;} | |
//if (fp==0 && p!=p2) {p=p2; fp=1;} | |
} | |
//==================================================== | |
sx=0; sy=0; sxy=0; sx2=0; | |
for (n=0; n<=p; n++) { | |
sx+=n; sy+=Close[n]; | |
sxy+=n*Close[n]; | |
sx2+=MathPow(n,2); | |
} | |
aa=(sx*sy-(p+1)*sxy)/(MathPow(sx,2)-(p+1)*sx2); | |
bb=(sy-aa*sx)/(p+1); | |
//---------------------------------------------------- | |
for (i=0; i<=p; i++) { | |
lr=bb+aa*i; | |
dh=High[i]-lr; | |
dl=Low[i]-lr; | |
//---------------------------------------------------- | |
if (i<p/2) { | |
if (i==0) { | |
dh_1=0.0; | |
dl_1=0.0; | |
ai_1=i; | |
bi_1=i; | |
} | |
if (dh>=dh_1) { | |
dh_1=dh; | |
ai_1=i; | |
} | |
if (dl<=dl_1) { | |
dl_1=dl; | |
bi_1=i; | |
} | |
} | |
//---------------------------------------------------- | |
if (i>=p/2) { | |
if (i==p/2) { | |
dh_2=0.0; | |
dl_2=0.0; | |
ai_2=i; | |
bi_2=i; | |
} | |
if (dh>=dh_2) { | |
dh_2=dh; | |
ai_2=i; | |
} | |
if (dl<=dl_2) { | |
dl_2=dl; | |
bi_2=i; | |
} | |
} | |
} | |
//------------------------------------- | |
lr0=bb; | |
lrp=bb+aa*(i+p); | |
//=================================================== | |
if (MathAbs(ai_1-ai_2)>MathAbs(bi_1-bi_2)) f=1; | |
if (MathAbs(ai_1-ai_2)<MathAbs(bi_1-bi_2)) f=2; | |
if (MathAbs(ai_1-ai_2)==MathAbs(bi_1-bi_2)) { | |
if (MathAbs(dh_1-dh_2)<MathAbs(dl_1-dl_2)) f=1; | |
if (MathAbs(dh_1-dh_2)>=MathAbs(dl_1-dl_2)) f=2; | |
} | |
//================================================= | |
if (f==1) { | |
for (n=0; n<=20; n++) { | |
f1=0; | |
for (i=0; i<=p; i++) { | |
hai=High[ai_1]*(i-ai_2)/(ai_1-ai_2)+High[ai_2]*(i-ai_1)/(ai_2-ai_1); | |
if (i==0 || i==p/2) dhm=0.0; | |
if (High[i]-hai>dhm && i<p/2) { | |
ai_1=i; | |
f1=1; | |
} | |
if (High[i]-hai>dhm && i>=p/2) { | |
ai_2=i; | |
f1=1; | |
} | |
} | |
if (f==0) break; | |
} | |
//---------------------------- | |
for (i=0; i<=p; i++) { | |
hai=High[ai_1]*(i-ai_2)/(ai_1-ai_2)+High[ai_2]*(i-ai_1)/(ai_2-ai_1); | |
dli=Low[i]-hai; | |
if (i==0) dlm=0.0; | |
if (dli<dlm) dlm=dli; | |
} | |
ha0=High[ai_1]*(0-ai_2)/(ai_1-ai_2)+High[ai_2]*(0-ai_1)/(ai_2-ai_1); | |
hap=High[ai_1]*(p-ai_2)/(ai_1-ai_2)+High[ai_2]*(p-ai_1)/(ai_2-ai_1); | |
//---------------------------- | |
price_p1=hap; | |
price_p0=hap+dlm/2; | |
price_p2=hap+dlm; | |
price_01=ha0; | |
price_00=ha0+dlm/2; | |
price_02=ha0+dlm; | |
} | |
//================================================= | |
if (f==2) { | |
for (n=0; n<=20; n++) { | |
f1=0; | |
for (i=0; i<=p; i++) { | |
lai=Low[bi_1]*(i-bi_2)/(bi_1-bi_2)+Low[bi_2]*(i-bi_1)/(bi_2-bi_1); | |
if (i==0 || i==p/2) dlm=0.0; | |
if (Low[i]-lai<dlm && i<p/2) { | |
bi_1=i; | |
f1=1; | |
} | |
if (Low[i]-lai<dlm && i>=p/2) { | |
bi_2=i; | |
f1=1; | |
} | |
} | |
if (f==0) break; | |
} | |
//---------------------------- | |
for (i=0; i<=p; i++) { | |
lai=Low[bi_1]*(i-bi_2)/(bi_1-bi_2)+Low[bi_2]*(i-bi_1)/(bi_2-bi_1); | |
dhi=High[i]-lai; | |
if (i==0) dhm=0.0; | |
if (dhi>dhm) dhm=dhi; | |
} | |
la0=Low[bi_1]*(0-bi_2)/(bi_1-bi_2)+Low[bi_2]*(0-bi_1)/(bi_2-bi_1); | |
lap=Low[bi_1]*(p-bi_2)/(bi_1-bi_2)+Low[bi_2]*(p-bi_1)/(bi_2-bi_1); | |
//---------------------------------------------------------------- | |
price_p1=lap; | |
price_p0=lap+dhm/2; | |
price_p2=lap+dhm; | |
price_01=la0; | |
price_00=la0+dhm/2; | |
price_02=la0+dhm; | |
} | |
//=================================================================================== | |
ObjectCreate("1"+sName,2, 0,Time[p],price_p1,Time[0],price_01); | |
ObjectCreate("0"+sName,2, 0,Time[p],price_p0,Time[0],price_00); | |
ObjectCreate("2"+sName,2, 0,Time[p],price_p2,Time[0],price_02); | |
//----------------------------------------------------------------- | |
ObjectSet("1"+sName,OBJPROP_COLOR,col_bear); | |
ObjectSet("0"+sName,OBJPROP_COLOR,col_mid); | |
ObjectSet("0"+sName,OBJPROP_STYLE,STYLE_DOT); | |
ObjectSet("2"+sName,OBJPROP_COLOR,col_bull); | |
//--------------------------------------------- | |
ObjectSet("1"+sName,OBJPROP_TIME1,Time[p]); | |
ObjectSet("1"+sName,OBJPROP_PRICE1,price_p1); | |
ObjectSet("1"+sName,OBJPROP_TIME2,Time[0]); | |
ObjectSet("1"+sName,OBJPROP_PRICE2,price_01); | |
ObjectSet("0"+sName,OBJPROP_TIME1,Time[p]); | |
ObjectSet("0"+sName,OBJPROP_PRICE1,price_p0); | |
ObjectSet("0"+sName,OBJPROP_TIME2,Time[0]); | |
ObjectSet("0"+sName,OBJPROP_PRICE2,price_00); | |
ObjectSet("2"+sName,OBJPROP_TIME1,Time[p]); | |
ObjectSet("2"+sName,OBJPROP_PRICE1,price_p2); | |
ObjectSet("2"+sName,OBJPROP_TIME2,Time[0]); | |
ObjectSet("2"+sName,OBJPROP_PRICE2,price_02); | |
//================================================================== | |
f=1; | |
p1=p; | |
p0=p; | |
p2=p; | |
fp=0; | |
//************************************************************************************* | |
ObjectsRedraw(); | |
return(0); | |
} | |
//===================================================================================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
#property indicator_buffers 2 | |
#property indicator_color1 White | |
#property indicator_color2 White | |
bool gi_76 = TRUE; | |
int gi_80 = 0; | |
bool AlertsOn = FALSE; | |
bool Comments = FALSE; | |
bool TrendLine = TRUE; | |
int TrendLineStyle = 0; | |
int TrendLineWidth = 3; | |
color UpperTrendLineColour = Red; | |
color LowerTrendLineColour = SkyBlue; | |
bool ProjectionLines = FALSE; | |
int ProjectionLinesStyle = 2; | |
int ProjectionLinesWidth = 3; | |
color UpperProjectionLineColour = Blue; | |
color LowerProjectionLineColour = Red; | |
bool HorizontLine = FALSE; | |
bool gi_144 = FALSE; | |
int gi_148 = 0; | |
int gi_152 = 1; | |
bool gi_156 = FALSE; | |
double gd_160 = -1.0; | |
bool gi_168 = FALSE; | |
double gd_172 = -1.0; | |
bool gi_180 = FALSE; | |
double gda_184[]; | |
double gda_188[]; | |
int init() { | |
SetIndexStyle(0, DRAW_ARROW); | |
SetIndexArrow(0, 217); | |
SetIndexBuffer(0, gda_184); | |
SetIndexEmptyValue(0, 0.0); | |
SetIndexStyle(1, DRAW_ARROW); | |
SetIndexArrow(1, 218); | |
SetIndexBuffer(1, gda_188); | |
SetIndexEmptyValue(1, 0.0); | |
for (int li_0 = 1; li_0 <= 10; li_0++) { | |
ObjectDelete("HHL_" + li_0); | |
ObjectDelete("HL_" + li_0); | |
ObjectDelete("HLL_" + li_0); | |
ObjectDelete("LL_" + li_0); | |
ObjectDelete("HC1_" + li_0); | |
ObjectDelete("HC2_" + li_0); | |
ObjectDelete("HC3_" + li_0); | |
ObjectDelete("LC1_" + li_0); | |
ObjectDelete("LC2_" + li_0); | |
ObjectDelete("LC3_" + li_0); | |
} | |
Comment(""); | |
return (0); | |
} | |
int deinit() { | |
for (int li_0 = 1; li_0 <= 10; li_0++) { | |
ObjectDelete("HHL_" + li_0); | |
ObjectDelete("HL_" + li_0); | |
ObjectDelete("HLL_" + li_0); | |
ObjectDelete("LL_" + li_0); | |
ObjectDelete("HC1_" + li_0); | |
ObjectDelete("HC2_" + li_0); | |
ObjectDelete("HC3_" + li_0); | |
ObjectDelete("LC1_" + li_0); | |
ObjectDelete("LC2_" + li_0); | |
ObjectDelete("LC3_" + li_0); | |
} | |
Comment(""); | |
return (0); | |
} | |
int SetTDPoint(int ai_0) { | |
if (gi_156 == FALSE) { | |
for (int li_4 = ai_0; li_4 > 1; li_4--) { | |
if (High[li_4 + 2] < High[li_4] && High[li_4 + 1] < High[li_4] && High[li_4 - 1] < High[li_4] && High[li_4 - 2] < High[li_4]) gda_184[li_4] = High[li_4]; | |
if (Low[li_4 + 2] > Low[li_4] && Low[li_4 + 1] > Low[li_4] && Low[li_4 - 1] > Low[li_4] && Low[li_4 - 2] > Low[li_4]) gda_188[li_4] = Low[li_4]; | |
} | |
gda_184[0] = 0; | |
gda_188[0] = 0; | |
gda_184[1] = 0; | |
gda_188[1] = 0; | |
} else { | |
for (li_4 = ai_0; li_4 > 3; li_4--) { | |
if (High[li_4 + 1] <= High[li_4] && High[li_4 - 1] < High[li_4] && High[li_4 + 2] <= High[li_4] && High[li_4 - 2] < High[li_4]) gda_184[li_4] = High[li_4]; | |
else gda_184[li_4] = 0; | |
if (Low[li_4 + 1] >= Low[li_4] && Low[li_4 - 1] > Low[li_4] && Low[li_4 + 2] >= Low[li_4] && Low[li_4 - 2] > Low[li_4]) gda_188[li_4] = Low[li_4]; | |
else gda_188[li_4] = 0; | |
} | |
gda_184[0] = 0; | |
gda_188[0] = 0; | |
gda_184[1] = 0; | |
gda_188[1] = 0; | |
gda_184[2] = 0; | |
gda_188[2] = 0; | |
} | |
return (0); | |
} | |
int GetHighTD(int ai_0) { | |
int li_4 = 0; | |
for (int li_8 = 0; li_8 < ai_0; li_8++) { | |
li_4++; | |
while (gda_184[li_4] == 0.0) { | |
li_4++; | |
if (li_4 > Bars - 2) return (-1); | |
} | |
} | |
return (li_4); | |
} | |
int GetNextHighTD(int ai_0) { | |
int li_4 = ai_0 + 1; | |
while (gda_184[li_4] <= High[ai_0]) { | |
li_4++; | |
if (li_4 > Bars - 2) return (-1); | |
} | |
return (li_4); | |
} | |
int GetLowTD(int ai_0) { | |
int li_4 = 0; | |
for (int li_8 = 0; li_8 < ai_0; li_8++) { | |
li_4++; | |
while (gda_188[li_4] == 0.0) { | |
li_4++; | |
if (li_4 > Bars - 2) return (-1); | |
} | |
} | |
return (li_4); | |
} | |
int GetNextLowTD(int ai_0) { | |
int li_4 = ai_0 + 1; | |
while (gda_188[li_4] >= Low[ai_0] || gda_188[li_4] == 0.0) { | |
li_4++; | |
if (li_4 > Bars - 2) return (-1); | |
} | |
return (li_4); | |
} | |
int TrendLineHighTD(int ai_0, int ai_4, int ai_8, int ai_12) { | |
ObjectSet("HL_" + ai_8, OBJPROP_TIME1, Time[ai_4]); | |
ObjectSet("HL_" + ai_8, OBJPROP_TIME2, Time[ai_0]); | |
ObjectSet("HL_" + ai_8, OBJPROP_PRICE1, High[ai_4]); | |
ObjectSet("HL_" + ai_8, OBJPROP_PRICE2, High[ai_0]); | |
ObjectSet("HL_" + ai_8, OBJPROP_COLOR, UpperTrendLineColour); | |
if (ai_8 == 1) ObjectSet("HL_" + ai_8, OBJPROP_WIDTH, TrendLineWidth); | |
else ObjectSet("HL_" + ai_8, OBJPROP_WIDTH, 2); | |
return (0); | |
} | |
int TrendLineLowTD(int ai_0, int ai_4, int ai_8, int ai_12) { | |
ObjectSet("LL_" + ai_8, OBJPROP_TIME1, Time[ai_4]); | |
ObjectSet("LL_" + ai_8, OBJPROP_TIME2, Time[ai_0]); | |
ObjectSet("LL_" + ai_8, OBJPROP_PRICE1, Low[ai_4]); | |
ObjectSet("LL_" + ai_8, OBJPROP_PRICE2, Low[ai_0]); | |
ObjectSet("LL_" + ai_8, OBJPROP_COLOR, LowerTrendLineColour); | |
if (ai_8 == 1) ObjectSet("LL_" + ai_8, OBJPROP_WIDTH, TrendLineWidth); | |
else ObjectSet("LL_" + ai_8, OBJPROP_WIDTH, 2); | |
return (0); | |
} | |
int HorizontLineHighTD(int ai_0, int ai_4, int ai_8, double ad_12, color ai_20) { | |
ObjectSet("HHL_" + ai_8, OBJPROP_PRICE1, High[ai_4] - (High[ai_4] - High[ai_0]) / (ai_4 - ai_0) * ai_4); | |
ObjectSet("HHL_" + ai_8, OBJPROP_STYLE, ad_12); | |
ObjectSet("HHL_" + ai_8, OBJPROP_COLOR, ai_20); | |
ObjectSet("HHL_" + ai_8, OBJPROP_BACK, TRUE); | |
return (0); | |
} | |
int HorizontLineLowTD(int ai_0, int ai_4, int ai_8, double ad_12, color ai_20) { | |
ObjectSet("HLL_" + ai_8, OBJPROP_PRICE1, Low[ai_4] + (Low[ai_0] - Low[ai_4]) / (ai_4 - ai_0) * ai_4); | |
ObjectSet("HLL_" + ai_8, OBJPROP_STYLE, ad_12); | |
ObjectSet("HLL_" + ai_8, OBJPROP_COLOR, ai_20); | |
ObjectSet("HLL_" + ai_8, OBJPROP_BACK, TRUE); | |
return (0); | |
} | |
string TakeProfitHighTD(int ai_0, int ai_4, int ai_8, color ai_12) { | |
int li_16; | |
double ld_20; | |
double ld_28; | |
double ld_36; | |
double ld_44; | |
int li_52 = 0; | |
string ls_56 = ""; | |
double ld_64 = (High[ai_4] - High[ai_0]) / (ai_4 - ai_0); | |
while (NormalizeDouble(Point, li_52) == 0.0) li_52++; | |
double ld_72 = 0; | |
for (int li_80 = ai_0; li_80 > 0; li_80--) { | |
if (Close[li_80] > High[ai_4] - ld_64 * (ai_4 - li_80)) { | |
ld_72 = High[ai_4] - ld_64 * (ai_4 - li_80); | |
break; | |
} | |
} | |
if (ld_72 > 0.0) { | |
ls_56 = ls_56 + "UTD_Line (" + DoubleToStr(High[ai_4] - ld_64 * ai_4, li_52) + ") broken at " + DoubleToStr(ld_72, li_52) + ", uptargets:\n"; | |
li_16 = iLowest(NULL, 0, MODE_LOW, ai_4 - li_80, li_80); | |
ld_20 = High[ai_4] - ld_64 * (ai_4 - li_16) - Low[li_16]; | |
ld_28 = High[ai_4] - ld_64 * (ai_4 - li_16) - Close[li_16]; | |
li_16 = iLowest(NULL, 0, MODE_CLOSE, ai_4 - li_80, li_80); | |
ld_36 = High[ai_4] - ld_64 * (ai_4 - li_16) - Close[li_16]; | |
ld_44 = TrendLineStyle; | |
} else { | |
ld_72 = High[ai_4] - ld_64 * ai_4; | |
ls_56 = ls_56 + "UTD_Line (" + DoubleToStr(ld_72, li_52) + "), Possible break-up. \n"; | |
li_16 = iLowest(NULL, 0, MODE_LOW, ai_4, 0); | |
ld_20 = High[ai_4] - ld_64 * (ai_4 - li_16) - Low[li_16]; | |
ld_28 = High[ai_4] - ld_64 * (ai_4 - li_16) - Close[li_16]; | |
li_16 = iLowest(NULL, 0, MODE_CLOSE, ai_4, 0); | |
ld_36 = High[ai_4] - ld_64 * (ai_4 - li_16) - Close[li_16]; | |
ld_44 = TrendLineStyle; | |
} | |
ObjectSet("HL_" + ai_8, OBJPROP_STYLE, ld_44); | |
ls_56 = ls_56 + "TP1=" + DoubleToStr(ld_20 + ld_72, li_52) + " (" + DoubleToStr(ld_20 / Point, 0) + "pts.)\n"; | |
ObjectSet("HC1_" + ai_8, OBJPROP_TIME1, Time[ai_0]); | |
ObjectSet("HC1_" + ai_8, OBJPROP_TIME2, Time[0]); | |
ObjectSet("HC1_" + ai_8, OBJPROP_PRICE1, ld_20 + ld_72); | |
ObjectSet("HC1_" + ai_8, OBJPROP_PRICE2, ld_20 + ld_72); | |
ObjectSet("HC1_" + ai_8, OBJPROP_COLOR, ai_12); | |
ObjectSet("HC1_" + ai_8, OBJPROP_STYLE, ld_44); | |
if (ai_8 == 1) { | |
ObjectSet("HC1_" + ai_8, OBJPROP_WIDTH, ProjectionLinesWidth); | |
ObjectSet("HC1_" + ai_8, OBJPROP_STYLE, ProjectionLinesStyle); | |
} else ObjectSet("HC1_" + ai_8, OBJPROP_WIDTH, 2); | |
return (ls_56); | |
} | |
string TakeProfitLowTD(int ai_0, int ai_4, int ai_8, color ai_12) { | |
int li_16; | |
double ld_20; | |
double ld_28; | |
double ld_36; | |
double ld_44; | |
int li_52 = 0; | |
string ls_56 = ""; | |
double ld_64 = (Low[ai_0] - Low[ai_4]) / (ai_4 - ai_0); | |
while (NormalizeDouble(Point, li_52) == 0.0) li_52++; | |
double ld_72 = 0; | |
for (int li_80 = ai_0; li_80 > 0; li_80--) { | |
if (Close[li_80] < Low[ai_4] + ld_64 * (ai_4 - li_80)) { | |
ld_72 = Low[ai_4] + ld_64 * (ai_4 - li_80); | |
break; | |
} | |
} | |
if (ld_72 > 0.0) { | |
ls_56 = ls_56 + "LTD_Line (" + DoubleToStr(Low[ai_4] + ld_64 * ai_4, li_52) + ") broken at " + DoubleToStr(ld_72, li_52) + ", downtargets:\n"; | |
li_16 = iHighest(NULL, 0, MODE_HIGH, ai_4 - li_80, li_80); | |
ld_20 = High[li_16] - (Low[ai_4] + ld_64 * (ai_4 - li_16)); | |
ld_28 = Close[li_16] - (Low[ai_4] + ld_64 * (ai_4 - li_16)); | |
li_80 = iHighest(NULL, 0, MODE_CLOSE, ai_4 - li_80, li_80); | |
ld_36 = Close[li_16] - (Low[ai_4] + ld_64 * (ai_4 - li_16)); | |
ld_44 = TrendLineStyle; | |
} else { | |
ld_72 = Low[ai_4] + ld_64 * ai_4; | |
ls_56 = ls_56 + "LTD_Line (" + DoubleToStr(ld_72, li_52) + "), Possible downbreak.\n"; | |
li_16 = iHighest(NULL, 0, MODE_HIGH, ai_4, 0); | |
ld_20 = High[li_16] - (Low[ai_4] + ld_64 * (ai_4 - li_16)); | |
ld_28 = Close[li_16] - (Low[ai_4] + ld_64 * (ai_4 - li_16)); | |
li_16 = iHighest(NULL, 0, MODE_CLOSE, ai_4, 0); | |
ld_36 = Close[li_16] - (Low[ai_4] + ld_64 * (ai_4 - li_16)); | |
ld_44 = TrendLineStyle; | |
} | |
ObjectSet("LL_" + ai_8, OBJPROP_STYLE, ld_44); | |
ls_56 = ls_56 + "TP1=" + DoubleToStr(ld_72 - ld_20, li_52) + " (" + DoubleToStr(ld_20 / Point, 0) + "pts.)\n"; | |
ObjectSet("LC1_" + ai_8, OBJPROP_TIME1, Time[ai_0]); | |
ObjectSet("LC1_" + ai_8, OBJPROP_TIME2, Time[0]); | |
ObjectSet("LC1_" + ai_8, OBJPROP_PRICE1, ld_72 - ld_20); | |
ObjectSet("LC1_" + ai_8, OBJPROP_PRICE2, ld_72 - ld_20); | |
ObjectSet("LC1_" + ai_8, OBJPROP_COLOR, ai_12); | |
ObjectSet("LC1_" + ai_8, OBJPROP_STYLE, ld_44); | |
if (ai_8 == 1) { | |
ObjectSet("LC1_" + ai_8, OBJPROP_WIDTH, ProjectionLinesWidth); | |
ObjectSet("LC1_" + ai_8, OBJPROP_STYLE, ProjectionLinesStyle); | |
} else ObjectSet("LC1_" + ai_8, OBJPROP_WIDTH, 2); | |
return (ls_56); | |
} | |
string TDMain(int ai_0) { | |
int li_4; | |
double ld_8; | |
double lda_16[20]; | |
string ls_20 = "--- step " + ai_0 + " --------------------\n"; | |
while (NormalizeDouble(Point, li_4) == 0.0) li_4++; | |
lda_16[0] = UpperProjectionLineColour; | |
lda_16[2] = 16711935; | |
lda_16[4] = 1993170; | |
lda_16[6] = 2139610; | |
lda_16[8] = 13458026; | |
lda_16[1] = LowerProjectionLineColour; | |
lda_16[3] = 2237106; | |
lda_16[5] = 32768; | |
lda_16[7] = 13850042; | |
lda_16[9] = 15570276; | |
lda_16[10] = 255; | |
lda_16[12] = 16711935; | |
lda_16[14] = 1993170; | |
lda_16[16] = 2139610; | |
lda_16[18] = 13458026; | |
lda_16[11] = 16711680; | |
lda_16[13] = 2237106; | |
lda_16[15] = 32768; | |
lda_16[17] = 13850042; | |
lda_16[19] = 15570276; | |
ai_0 += gi_148; | |
int li_28 = GetHighTD(ai_0); | |
int li_32 = GetNextHighTD(li_28); | |
int li_36 = GetLowTD(ai_0); | |
int li_40 = GetNextLowTD(li_36); | |
gd_160 = High[li_32] - (High[li_32] - High[li_28]) / (li_32 - li_28) * li_32; | |
gd_172 = Low[li_40] + (Low[li_36] - Low[li_40]) / (li_40 - li_36) * li_40; | |
if (li_28 < 0) ls_20 = ls_20 + "UTD no TD up-point \n"; | |
else { | |
if (li_32 < 0) ls_20 = ls_20 + "UTD no TD point-upper then last one (" + DoubleToStr(High[li_28], li_4) + ")\n"; | |
else { | |
ls_20 = ls_20 + "UTD " + DoubleToStr(High[li_32], li_4) + " " + DoubleToStr(High[li_28], li_4) | |
+ "\n"; | |
} | |
} | |
if (li_36 < 0) ls_20 = ls_20 + "LTD no TD down-point \n"; | |
else { | |
if (li_40 < 0) ls_20 = ls_20 + "LTD no TD point-lower then last one (" + DoubleToStr(Low[li_36], li_4) + ")\n"; | |
else { | |
ls_20 = ls_20 + "LTD " + DoubleToStr(Low[li_40], li_4) + " " + DoubleToStr(Low[li_36], li_4) | |
+ "\n"; | |
} | |
} | |
if (ai_0 == 1) ld_8 = 0; | |
else ld_8 = 2; | |
if (li_28 > 0 && li_32 > 0) { | |
if (TrendLine == TRUE) { | |
ObjectCreate("HL_" + ai_0, OBJ_TREND, 0, 0, 0, 0, 0); | |
TrendLineHighTD(li_28, li_32, ai_0, lda_16[ai_0 * 2 - 2]); | |
} else ObjectDelete("HL_" + ai_0); | |
if (HorizontLine == TRUE && ai_0 == 1) { | |
ObjectCreate("HHL_" + ai_0, OBJ_HLINE, 0, 0, 0, 0, 0); | |
ObjectSet("HHL_" + ai_0, OBJPROP_BACK, TRUE); | |
HorizontLineHighTD(li_28, li_32, ai_0, ld_8, lda_16[ai_0 * 2 - 2]); | |
} else ObjectDelete("HHL_" + ai_0); | |
if (ProjectionLines == TRUE) { | |
ObjectCreate("HC1_" + ai_0, OBJ_TREND, 0, 0, 0, 0, 0); | |
ObjectCreate("HC2_" + ai_0, OBJ_TREND, 0, 0, 0, 0, 0); | |
ObjectCreate("HC3_" + ai_0, OBJ_TREND, 0, 0, 0, 0, 0); | |
ls_20 = ls_20 + TakeProfitHighTD(li_28, li_32, ai_0, lda_16[ai_0 * 2 - 2]); | |
} else { | |
ObjectDelete("HC1_" + ai_0); | |
ObjectDelete("HC2_" + ai_0); | |
ObjectDelete("HC3_" + ai_0); | |
} | |
} | |
if (li_36 > 0 && li_40 > 0) { | |
if (TrendLine == TRUE) { | |
ObjectCreate("LL_" + ai_0, OBJ_TREND, 0, 0, 0, 0, 0); | |
TrendLineLowTD(li_36, li_40, ai_0, lda_16[ai_0 * 2 - 1]); | |
} else ObjectDelete("LL_" + ai_0); | |
if (HorizontLine == TRUE && ai_0 == 1) { | |
ObjectCreate("HLL_" + ai_0, OBJ_HLINE, 0, 0, 0, 0, 0); | |
ObjectSet("HLL_" + ai_0, OBJPROP_BACK, TRUE); | |
HorizontLineLowTD(li_36, li_40, ai_0, ld_8, lda_16[ai_0 * 2 - 1]); | |
} else ObjectDelete("HLL_" + ai_0); | |
if (ProjectionLines == TRUE) { | |
ObjectCreate("LC1_" + ai_0, OBJ_TREND, 0, 0, 0, 0, 0); | |
ObjectCreate("LC2_" + ai_0, OBJ_TREND, 0, 0, 0, 0, 0); | |
ObjectCreate("LC3_" + ai_0, OBJ_TREND, 0, 0, 0, 0, 0); | |
ls_20 = ls_20 + TakeProfitLowTD(li_36, li_40, ai_0, lda_16[ai_0 * 2 - 1]); | |
} else { | |
ObjectDelete("LC1_" + ai_0); | |
ObjectDelete("LC2_" + ai_0); | |
ObjectDelete("LC3_" + ai_0); | |
} | |
} | |
if (AlertsOn) { | |
if (Close[0] > gd_160 && gi_168 == FALSE) { | |
Alert("UTL Break>", gd_160, " on ", Symbol(), " ", Period(), " @ ", Bid); | |
gi_168 = TRUE; | |
} | |
if (Close[0] < gd_172 && gi_180 == FALSE) { | |
Alert("LTL Break<", gd_172, " on ", Symbol(), " ", Period(), " @ ", Bid); | |
gi_180 = TRUE; | |
} | |
} | |
return (ls_20); | |
} | |
int start() { | |
string ls_0 = ""; | |
SetTDPoint(Bars - 1); | |
if (gi_144 == TRUE) { | |
SetIndexArrow(0, 217); | |
SetIndexArrow(1, 218); | |
} else { | |
SetIndexArrow(0, 160); | |
SetIndexArrow(1, 160); | |
} | |
if (gi_152 > 10) { | |
Comment("ShowingSteps readings 0 - 10"); | |
return (0); | |
} | |
for (int li_8 = 1; li_8 <= gi_152; li_8++) ls_0 = ls_0 + TDMain(li_8); | |
ls_0 = ls_0 + "------------------------------------\nShowingSteps=" + gi_152 | |
+ "\nBackSteps=" + gi_148; | |
if (gi_156 == TRUE) { | |
ls_0 = ls_0 | |
+ "\nFractals"; | |
} else { | |
ls_0 = ls_0 | |
+ "\nTD point"; | |
} | |
if (Comments == TRUE) Comment(ls_0); | |
else Comment(""); | |
return (0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
#property indicator_buffers 7 | |
#property indicator_color1 Blue | |
#property indicator_color2 DimGray | |
#property indicator_color3 Red | |
#property indicator_color4 Red | |
#property indicator_color5 DimGray | |
#property indicator_color6 LimeGreen | |
#property indicator_color7 LimeGreen | |
int Nmbr_Bars = 120; | |
int Order = 3; | |
double Ecart = 1.61803399; | |
double gda_92[]; | |
double gda_96[]; | |
double gda_100[]; | |
double gda_104[]; | |
double gda_108[]; | |
double gda_112[]; | |
double gda_116[]; | |
double gda_120[20][20]; | |
double gda_124[20]; | |
double gda_128[20]; | |
double gda_132[20]; | |
int gi_136; | |
int gi_140; | |
int gi_144; | |
int gi_148; | |
int gi_152; | |
int gi_156; | |
int gi_160; | |
double gd_164; | |
double gd_172; | |
double gd_180; | |
double gd_188; | |
double gd_196; | |
int init() { | |
//Comment("Floting+"); | |
SetIndexStyle(0, DRAW_LINE); | |
SetIndexBuffer(0, gda_92); | |
SetIndexBuffer(1, gda_96); | |
SetIndexBuffer(2, gda_100); | |
SetIndexBuffer(3, gda_104); | |
SetIndexBuffer(4, gda_108); | |
SetIndexBuffer(5, gda_112); | |
SetIndexBuffer(6, gda_116); | |
return (0); | |
} | |
int deinit() { | |
Comment(""); | |
ObjectDelete("REG"); | |
ObjectDelete("X1"); | |
ObjectDelete("X2"); | |
ObjectDelete("X3"); | |
ObjectDelete("Z1"); | |
ObjectDelete("Z2"); | |
ObjectDelete("Z3"); | |
return (0); | |
} | |
int start() { | |
if (Year() >= 2020) return (0); | |
datetime lt_0 = 0; | |
SetIndexDrawBegin(0, Bars - Nmbr_Bars - 1); | |
SetIndexDrawBegin(1, Bars - Nmbr_Bars - 1); | |
SetIndexDrawBegin(2, Bars - Nmbr_Bars - 1); | |
SetIndexDrawBegin(3, Bars - Nmbr_Bars - 1); | |
SetIndexDrawBegin(4, Bars - Nmbr_Bars - 1); | |
SetIndexDrawBegin(5, Bars - Nmbr_Bars - 1); | |
SetIndexDrawBegin(6, Bars - Nmbr_Bars - 1); | |
if (lt_0 != Time[0]) { | |
ObjectDelete("REG"); | |
ObjectDelete("X1"); | |
ObjectDelete("X2"); | |
ObjectDelete("X3"); | |
ObjectDelete("Z1"); | |
ObjectDelete("Z2"); | |
ObjectDelete("Z3"); | |
lt_0 = Time[0]; | |
} | |
gi_152 = Order + 1; | |
gda_124[1] = Nmbr_Bars + 1; | |
for (gi_160 = 1; gi_160 <= gi_152 * 2 - 2; gi_160++) { | |
gd_164 = 0; | |
for (gi_156 = 0; gi_156 <= Nmbr_Bars; gi_156++) gd_164 += MathPow(gi_156, gi_160); | |
gda_124[gi_160 + 1] = gd_164; | |
} | |
for (gi_160 = 1; gi_160 <= gi_152; gi_160++) { | |
gd_164 = 0; | |
for (gi_156 = 0; gi_156 <= Nmbr_Bars; gi_156++) { | |
if (gi_160 == 1) gd_164 += (High[gi_156] + Low[gi_156]) / 2.0; | |
else gd_164 += (High[gi_156] + Low[gi_156]) / 2.0 * MathPow(gi_156, gi_160 - 1); | |
} | |
gda_128[gi_160] = gd_164; | |
} | |
for (gi_140 = 1; gi_140 <= gi_152; gi_140++) { | |
for (gi_136 = 1; gi_136 <= gi_152; gi_136++) { | |
gi_144 = gi_136 + gi_140 - 1; | |
gda_120[gi_136][gi_140] = gda_124[gi_144]; | |
} | |
} | |
for (gi_144 = 1; gi_144 <= gi_152 - 1; gi_144++) { | |
gi_148 = 0; | |
gd_188 = 0; | |
for (gi_136 = gi_144; gi_136 <= gi_152; gi_136++) { | |
if (MathAbs(gda_120[gi_136][gi_144]) > gd_188) { | |
gd_188 = MathAbs(gda_120[gi_136][gi_144]); | |
gi_148 = gi_136; | |
} | |
} | |
if (gi_148 == 0) return (0); | |
if (gi_148 != gi_144) { | |
for (gi_140 = 1; gi_140 <= gi_152; gi_140++) { | |
gd_196 = gda_120[gi_144][gi_140]; | |
gda_120[gi_144][gi_140] = gda_120[gi_148][gi_140]; | |
gda_120[gi_148][gi_140] = gd_196; | |
} | |
gd_196 = gda_128[gi_144]; | |
gda_128[gi_144] = gda_128[gi_148]; | |
gda_128[gi_148] = gd_196; | |
} | |
for (gi_136 = gi_144 + 1; gi_136 <= gi_152; gi_136++) { | |
gd_180 = gda_120[gi_136][gi_144] / gda_120[gi_144][gi_144]; | |
for (gi_140 = 1; gi_140 <= gi_152; gi_140++) { | |
if (gi_140 == gi_144) gda_120[gi_136][gi_140] = 0; | |
else gda_120[gi_136][gi_140] = gda_120[gi_136][gi_140] - gd_180 * gda_120[gi_144][gi_140]; | |
} | |
gda_128[gi_136] = gda_128[gi_136] - gd_180 * gda_128[gi_144]; | |
} | |
} | |
gda_132[gi_152] = gda_128[gi_152] / gda_120[gi_152][gi_152]; | |
for (gi_136 = gi_152 - 1; gi_136 >= 1; gi_136--) { | |
gd_196 = 0; | |
for (gi_140 = 1; gi_140 <= gi_152 - gi_136; gi_140++) { | |
gd_196 += (gda_120[gi_136][gi_136 + gi_140]) * (gda_132[gi_136 + gi_140]); | |
gda_132[gi_136] = 1 / gda_120[gi_136][gi_136] * (gda_128[gi_136] - gd_196); | |
} | |
} | |
for (gi_156 = 0; gi_156 <= Nmbr_Bars; gi_156++) { | |
gd_164 = 0; | |
for (gi_144 = 1; gi_144 <= Order; gi_144++) gd_164 += (gda_132[gi_144 + 1]) * MathPow(gi_156, gi_144); | |
gda_92[gi_156] = gda_132[1] + gd_164; | |
} | |
gd_172 = iStdDev(NULL, 0, Nmbr_Bars, 0, MODE_SMA, PRICE_HIGH, 0) * Ecart; | |
for (gi_156 = 0; gi_156 <= Nmbr_Bars; gi_156++) { | |
gda_104[gi_156] = gda_92[gi_156] + gd_172; | |
gda_100[gi_156] = gda_92[gi_156] + (gda_104[gi_156] - gda_92[gi_156]) / 1.382; | |
gda_96[gi_156] = gda_92[gi_156] + (gda_100[gi_156] - gda_92[gi_156]) / 1.618; | |
gda_116[gi_156] = gda_92[gi_156] - gd_172; | |
gda_112[gi_156] = gda_92[gi_156] - (gda_92[gi_156] - gda_116[gi_156]) / 1.382; | |
gda_108[gi_156] = gda_92[gi_156] - (gda_92[gi_156] - gda_112[gi_156]) / 1.618; | |
} | |
ObjectCreate("REG", OBJ_ARROW, 0, Time[0], gda_92[0]); | |
ObjectSet("REG", OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE); | |
ObjectSet("REG", OBJPROP_COLOR, Blue); | |
ObjectCreate("X1", OBJ_ARROW, 0, Time[0], gda_96[0]); | |
ObjectSet("X1", OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE); | |
ObjectSet("X1", OBJPROP_COLOR, DimGray); | |
ObjectCreate("X2", OBJ_ARROW, 0, Time[0], gda_100[0]); | |
ObjectSet("X2", OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE); | |
ObjectSet("X2", OBJPROP_COLOR, Red); | |
ObjectCreate("X3", OBJ_ARROW, 0, Time[0], gda_104[0]); | |
ObjectSet("X3", OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE); | |
ObjectSet("X3", OBJPROP_COLOR, Red); | |
ObjectCreate("Z1", OBJ_ARROW, 0, Time[0], gda_108[0]); | |
ObjectSet("Z1", OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE); | |
ObjectSet("Z1", OBJPROP_COLOR, DimGray); | |
ObjectCreate("Z2", OBJ_ARROW, 0, Time[0], gda_112[0]); | |
ObjectSet("Z2", OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE); | |
ObjectSet("Z2", OBJPROP_COLOR, LimeGreen); | |
ObjectCreate("Z3", OBJ_ARROW, 0, Time[0], gda_116[0]); | |
ObjectSet("Z3", OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE); | |
ObjectSet("Z3", OBJPROP_COLOR, LimeGreen); | |
return (0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
#property indicator_buffers 3 | |
#property indicator_color1 Red | |
#property indicator_color2 SkyBlue | |
#property indicator_color3 CLR_NONE | |
int MALength = 80; | |
double Separation = 5.0; | |
int BuyArrowCharacter = 217; | |
int SellArrowCharacter = 218; | |
bool EnableBuyAlertSound = TRUE; | |
bool EnableSellAlertSound = TRUE; | |
string BuyWAV = "alert.wav"; | |
string SellWAV = "alert.wav"; | |
bool EnableBuyAlertPopup = FALSE; | |
bool EnableSellAlertPopup = FALSE; | |
string sPlotOnOpenOfBar = "true = Plot on the bar after the signal bar, false = on the signal bar itself"; | |
bool PlotOnOpenOfBar = TRUE; | |
double gda_140[]; | |
double gda_144[]; | |
double gda_148[]; | |
int gi_152 = -1; | |
int gi_156; | |
int gi_272; | |
int init() { | |
IndicatorBuffers(3); | |
if ((!SetIndexBuffer(0, gda_140)) && !SetIndexBuffer(1, gda_144) && (!SetIndexBuffer(2, gda_148))) Print("cannot set indicator buffers!"); | |
SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, 3); | |
SetIndexArrow(0, SellArrowCharacter); | |
SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, 3); | |
SetIndexArrow(1, BuyArrowCharacter); | |
SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2); | |
gi_156 = MALength; | |
SetIndexDrawBegin(0, gi_156); | |
SetIndexDrawBegin(1, gi_156); | |
IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS) + 1.0); | |
IndicatorShortName("Pegasus(" + MALength + ")"); | |
SetIndexLabel(0, "Pegasus Sell"); | |
SetIndexLabel(1, "Pegasus Buy"); | |
SetIndexLabel(2, "Pegasus MA("); | |
return (0); | |
} | |
int start() { | |
bool li_20; | |
double ld_24; | |
bool li_32; | |
int li_8 = IndicatorCounted(); | |
bool li_12 = li_8 == 0; | |
int li_4 = 0; | |
if (li_8 < 1) { | |
Comment(""); | |
for (li_4 = 0; li_4 < Bars; li_4++) { | |
gda_140[li_4] = EMPTY_VALUE; | |
gda_144[li_4] = EMPTY_VALUE; | |
gda_148[li_4] = EMPTY_VALUE; | |
} | |
} | |
if (li_8 > 0) li_8--; | |
int li_0 = Bars - li_8; | |
int li_16 = 0; | |
gda_140[Bars - 1] = EMPTY_VALUE; | |
gda_144[Bars - 1] = EMPTY_VALUE; | |
gda_148[0] = iMA(NULL, 0, MALength, 0, MODE_SMA, PRICE_CLOSE, 0); | |
for (li_4 = 1; li_4 <= li_0; li_4++) { | |
if (gda_148[li_4] == EMPTY_VALUE) gda_148[li_4] = iMA(NULL, 0, MALength, 0, MODE_SMA, PRICE_CLOSE, li_4); | |
li_20 = Close[li_4 + li_16] < Open[li_4 + li_16]; | |
li_20 = li_20 && Close[li_4 + 1 - li_16] > Open[li_4 + 1 + li_16]; | |
li_20 = li_20 && Close[li_4 + li_16] > gda_148[li_4 + li_16]; | |
if (li_20) { | |
ld_24 = iATR(NULL, 0, 15, li_4) * Separation / 10.0; | |
if (!PlotOnOpenOfBar) gda_144[li_4 + li_16] = Low[li_4 + li_16] - ld_24; | |
else gda_144[li_4 - 1] = Low[li_4 + li_16] - ld_24; | |
} | |
li_32 = Close[li_4 + li_16] > Open[li_4 + li_16]; | |
li_32 = li_32 && Close[li_4 + 1 + li_16] < Open[li_4 + 1 + li_16]; | |
li_32 = li_32 && Close[li_4 + li_16] < gda_148[li_4 + li_16]; | |
if (li_32) { | |
ld_24 = iATR(NULL, 0, 15, li_4) * Separation / 10.0; | |
if (!PlotOnOpenOfBar) { | |
gda_140[li_4 + li_16] = High[li_4 + li_16] + ld_24; | |
continue; | |
} | |
gda_140[li_4 - 1] = High[li_4 + li_16] + ld_24; | |
} | |
} | |
if (!li_12 && gi_152 != Bars) { | |
if (gda_144[1] != EMPTY_VALUE) { | |
if (EnableBuyAlertPopup) Alert("Pegasus BUY on " + Symbol() + " " + Period() + "-min"); | |
else | |
if (EnableBuyAlertSound && BuyWAV != "") PlaySound(BuyWAV); | |
} | |
if (gda_140[1] != EMPTY_VALUE) { | |
if (EnableSellAlertPopup) Alert("Pegasus SELL on " + Symbol() + " " + Period() + "-min"); | |
else | |
if (EnableSellAlertSound && SellWAV != "") PlaySound(SellWAV); | |
} | |
} | |
gi_152 = Bars; | |
return (0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
#property indicator_buffers 2 | |
int forced_tf = 0; | |
bool use_narrow_bands = false; | |
bool kill_retouch = true; | |
color TopColor = Gold; | |
color BotColor = CornflowerBlue; | |
int Price_Width = 1; | |
double BuferUp[]; | |
double BuferDn[]; | |
double iPeriod=13; | |
int Dev=8; | |
int Step=5; | |
datetime t1,t2; | |
double p1,p2; | |
string pair; | |
double point; | |
int digits; | |
int tf; | |
string TAG; | |
double up_cur,dn_cur; | |
int init() | |
{ | |
SetIndexBuffer(1,BuferUp); | |
SetIndexEmptyValue(1,0.0); | |
SetIndexStyle(1,DRAW_NONE); | |
SetIndexBuffer(0,BuferDn); | |
SetIndexEmptyValue(0,0.0); | |
SetIndexStyle(0,DRAW_NONE); | |
if(forced_tf != 0) tf = forced_tf; | |
else tf = Period(); | |
point = Point; | |
digits = Digits; | |
if(digits == 3 || digits == 5) point*=10; | |
TAG = "II_SupDem"+tf; | |
return(0); | |
} | |
int deinit() | |
{ | |
ObDeleteObjectsByPrefix(TAG); | |
Comment(""); | |
return(0); | |
} | |
int start() { | |
if(NewBar()==true) | |
{ | |
CountZZ(BuferUp,BuferDn,iPeriod,Dev,Step); | |
GetValid(); | |
Draw(); | |
} | |
return(0); | |
} | |
void Draw() | |
{ | |
int i; | |
string s; | |
ObDeleteObjectsByPrefix(TAG); | |
for(i=0;i<iBars(pair,tf);i++) | |
{ | |
if(BuferDn[i] > 0.0) | |
{ | |
t1 = iTime(pair,tf,i); | |
t2 = Time[0]; | |
if(use_narrow_bands) p2 = MathMax(iClose(pair,tf,i),iOpen(pair,tf,i)); | |
else p2 = MathMin(iClose(pair,tf,i),iOpen(pair,tf,i)); | |
p2 = MathMax(p2,MathMax(iLow(pair,tf,i-1),iLow(pair,tf,i+1))); | |
s = TAG+"UPAR"+tf+i; | |
ObjectCreate(s,OBJ_ARROW,0,0,0); | |
ObjectSet(s,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE); | |
ObjectSet(s, OBJPROP_TIME1, t2); | |
ObjectSet(s, OBJPROP_PRICE1, p2); | |
ObjectSet(s,OBJPROP_COLOR,TopColor); | |
ObjectSet(s,OBJPROP_WIDTH,Price_Width); | |
s = TAG+"UPFILL"+tf+i; | |
ObjectCreate(s,OBJ_RECTANGLE,0,0,0,0,0); | |
ObjectSet(s,OBJPROP_TIME1,t1); | |
ObjectSet(s,OBJPROP_PRICE1,BuferDn[i]); | |
ObjectSet(s,OBJPROP_TIME2,t2); | |
ObjectSet(s,OBJPROP_PRICE2,p2); | |
ObjectSet(s,OBJPROP_COLOR,TopColor); | |
} | |
if(BuferUp[i] > 0.0) | |
{ | |
t1 = iTime(pair,tf,i); | |
t2 = Time[0]; | |
if(use_narrow_bands) p2 = MathMin(iClose(pair,tf,i),iOpen(pair,tf,i)); | |
else p2 = MathMax(iClose(pair,tf,i),iOpen(pair,tf,i)); | |
if(i>0) p2 = MathMin(p2,MathMin(iHigh(pair,tf,i+1),iHigh(pair,tf,i-1))); | |
s = TAG+"DNAR"+tf+i; | |
ObjectCreate(s,OBJ_ARROW,0,0,0); | |
ObjectSet(s,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE); | |
ObjectSet(s, OBJPROP_TIME1, t2); | |
ObjectSet(s, OBJPROP_PRICE1, p2); | |
ObjectSet(s,OBJPROP_COLOR,BotColor); | |
ObjectSet(s,OBJPROP_WIDTH,Price_Width); | |
s = TAG+"DNFILL"+tf+i; | |
ObjectCreate(s,OBJ_RECTANGLE,0,0,0,0,0); | |
ObjectSet(s,OBJPROP_TIME1,t1); | |
ObjectSet(s,OBJPROP_PRICE1,p2); | |
ObjectSet(s,OBJPROP_TIME2,t2); | |
ObjectSet(s,OBJPROP_PRICE2,BuferUp[i]); | |
ObjectSet(s,OBJPROP_COLOR,BotColor); | |
} | |
} | |
} | |
bool NewBar() { | |
static datetime LastTime = 0; | |
if (iTime(pair,tf,0) != LastTime) { | |
LastTime = iTime(pair,tf,0); | |
return (true); | |
} else | |
return (false); | |
} | |
void ObDeleteObjectsByPrefix(string Prefix) | |
{ | |
int L = StringLen(Prefix); | |
int i = 0; | |
while(i < ObjectsTotal()) | |
{ | |
string ObjName = ObjectName(i); | |
if(StringSubstr(ObjName, 0, L) != Prefix) | |
{ | |
i++; | |
continue; | |
} | |
ObjectDelete(ObjName); | |
} | |
} | |
int CountZZ( double& ExtMapBuffer[], double& ExtMapBuffer2[], int ExtDepth, int ExtDeviation, int ExtBackstep ) | |
{ | |
int shift, back,lasthighpos,lastlowpos; | |
double val,res; | |
double curlow,curhigh,lasthigh,lastlow; | |
int count = iBars(pair,tf)-ExtDepth; | |
for(shift=count; shift>=0; shift--) | |
{ | |
val = iLow(pair,tf,iLowest(pair,tf,MODE_LOW,ExtDepth,shift)); | |
if(val==lastlow) val=0.0; | |
else | |
{ | |
lastlow=val; | |
if((iLow(pair,tf,shift)-val)>(ExtDeviation*Point)) val=0.0; | |
else | |
{ | |
for(back=1; back<=ExtBackstep; back++) | |
{ | |
res=ExtMapBuffer[shift+back]; | |
if((res!=0)&&(res>val)) ExtMapBuffer[shift+back]=0.0; | |
} | |
} | |
} | |
ExtMapBuffer[shift]=val; | |
//--- high | |
val=iHigh(pair,tf,iHighest(pair,tf,MODE_HIGH,ExtDepth,shift)); | |
if(val==lasthigh) val=0.0; | |
else | |
{ | |
lasthigh=val; | |
if((val-iHigh(pair,tf,shift))>(ExtDeviation*Point)) val=0.0; | |
else | |
{ | |
for(back=1; back<=ExtBackstep; back++) | |
{ | |
res=ExtMapBuffer2[shift+back]; | |
if((res!=0)&&(res<val)) ExtMapBuffer2[shift+back]=0.0; | |
} | |
} | |
} | |
ExtMapBuffer2[shift]=val; | |
} | |
// final cutting | |
lasthigh=-1; lasthighpos=-1; | |
lastlow=-1; lastlowpos=-1; | |
for(shift=count; shift>=0; shift--) | |
{ | |
curlow=ExtMapBuffer[shift]; | |
curhigh=ExtMapBuffer2[shift]; | |
if((curlow==0)&&(curhigh==0)) continue; | |
//--- | |
if(curhigh!=0) | |
{ | |
if(lasthigh>0) | |
{ | |
if(lasthigh<curhigh) ExtMapBuffer2[lasthighpos]=0; | |
else ExtMapBuffer2[shift]=0; | |
} | |
//--- | |
if(lasthigh<curhigh || lasthigh<0) | |
{ | |
lasthigh=curhigh; | |
lasthighpos=shift; | |
} | |
lastlow=-1; | |
} | |
//---- | |
if(curlow!=0) | |
{ | |
if(lastlow>0) | |
{ | |
if(lastlow>curlow) ExtMapBuffer[lastlowpos]=0; | |
else ExtMapBuffer[shift]=0; | |
} | |
//--- | |
if((curlow<lastlow)||(lastlow<0)) | |
{ | |
lastlow=curlow; | |
lastlowpos=shift; | |
} | |
lasthigh=-1; | |
} | |
} | |
for(shift=iBars(pair,tf)-1; shift>=0; shift--) | |
{ | |
if(shift>=count) ExtMapBuffer[shift]=0.0; | |
else | |
{ | |
res=ExtMapBuffer2[shift]; | |
if(res!=0.0) ExtMapBuffer2[shift]=res; | |
} | |
} | |
return(0); | |
} | |
void GetValid() | |
{ | |
up_cur = 0; | |
int upbar = 0; | |
dn_cur = 0; | |
int dnbar = 0; | |
double cur_hi = 0; | |
double cur_lo = 0; | |
double last_up = 0; | |
double last_dn = 0; | |
double low_dn = 0; | |
double hi_up = 0; | |
int i; | |
for(i=0;i<iBars(pair,tf);i++) | |
{ | |
if(BuferUp[i] > 0) | |
{ | |
up_cur = BuferUp[i]; | |
cur_lo = BuferUp[i]; | |
last_up = cur_lo; | |
break; | |
} | |
} | |
for(i=0;i<iBars(pair,tf);i++) | |
{ | |
if(BuferDn[i] > 0) | |
{ | |
dn_cur = BuferDn[i]; | |
cur_hi = BuferDn[i]; | |
last_dn = cur_hi; | |
break; | |
} | |
} | |
for(i=0;i<iBars(pair,tf);i++) // remove higher lows and lower highs | |
{ | |
if(BuferDn[i] >= last_dn) | |
{ | |
last_dn = BuferDn[i]; | |
dnbar = i; | |
} | |
else BuferDn[i] = 0.0; | |
if(BuferDn[i] <= dn_cur && BuferUp[i] > 0.0) BuferDn[i] = 0.0; | |
if(BuferUp[i] <= last_up && BuferUp[i] > 0) | |
{ | |
last_up = BuferUp[i]; | |
upbar = i; | |
} | |
else BuferUp[i] = 0.0; | |
if(BuferUp[i] > up_cur) BuferUp[i] = 0.0; | |
} | |
if(kill_retouch) | |
{ | |
if(use_narrow_bands) | |
{ | |
low_dn = MathMax(iOpen(pair,tf,dnbar),iClose(pair,tf,dnbar)); | |
hi_up = MathMin(iOpen(pair,tf,upbar),iClose(pair,tf,upbar)); | |
} | |
else | |
{ | |
low_dn = MathMin(iOpen(pair,tf,dnbar),iClose(pair,tf,dnbar)); | |
hi_up = MathMax(iOpen(pair,tf,upbar),iClose(pair,tf,upbar)); | |
} | |
for(i=MathMax(upbar,dnbar);i>=0;i--) // work back to zero and remove reentries into s/d | |
{ | |
if(BuferDn[i] > low_dn && BuferDn[i] != last_dn) BuferDn[i] = 0.0; | |
else if(use_narrow_bands && BuferDn[i] > 0) | |
{ | |
low_dn = MathMax(iOpen(pair,tf,i),iClose(pair,tf,i)); | |
last_dn = BuferDn[i]; | |
} | |
else if(BuferDn[i] > 0) | |
{ | |
low_dn = MathMin(iOpen(pair,tf,i),iClose(pair,tf,i)); | |
last_dn = BuferDn[i]; | |
} | |
if(BuferUp[i] <= hi_up && BuferUp[i] > 0 && BuferUp[i] != last_up) BuferUp[i] = 0.0; | |
else if(use_narrow_bands && BuferUp[i] > 0) | |
{ | |
hi_up = MathMin(iOpen(pair,tf,i),iClose(pair,tf,i)); | |
last_up = BuferUp[i]; | |
} | |
else if(BuferUp[i] > 0) | |
{ | |
hi_up = MathMax(iOpen(pair,tf,i),iClose(pair,tf,i)); | |
last_up = BuferUp[i]; | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
#property indicator_buffers 2 | |
#property indicator_color1 Aqua | |
#property indicator_color2 Gold | |
int RISK = 4; | |
double g_ibuf_80[]; | |
double g_ibuf_84[]; | |
int gi_88 = 0; | |
int gi_92 = 0; | |
int init() { | |
SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, 2); | |
SetIndexArrow(0, 159); | |
SetIndexBuffer(0, g_ibuf_80); | |
SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, 2); | |
SetIndexArrow(1, 159); | |
SetIndexBuffer(1, g_ibuf_84); | |
return (0); | |
} | |
int deinit() { | |
return (0); | |
} | |
int start() { | |
double ld_0; | |
double ld_8; | |
int l_count_16; | |
int li_20; | |
int li_24; | |
int li_28; | |
double ld_32; | |
double ld_40; | |
double ld_48; | |
double ld_56; | |
double lda_64[500][2]; | |
double ld_68 = 10; | |
double ld_76 = 70; | |
double ld_84 = 30; | |
int li_92 = IndicatorCounted(); | |
ld_68 = RISK * 2 + 3; | |
ld_76 = RISK + 67; | |
ld_84 = 33 - RISK; | |
double l_period_96 = ld_68; | |
if (li_92 < 0) return (-1); | |
if (li_92 > 0) li_92--; | |
int li_104 = Bars - li_92 - 1; | |
for (int li_108 = li_104; li_108 > 0; li_108--) { | |
li_20 = li_108; | |
ld_32 = 0; | |
ld_40 = 0; | |
for (li_20 = li_108; li_20 <= li_108 + 9; li_20++) ld_40 += MathAbs(High[li_20] - Low[li_20]); | |
ld_32 = ld_40 / 10.0; | |
li_20 = li_108; | |
l_count_16 = 0; | |
while (li_20 < li_108 + 9 && l_count_16 < 1) { | |
if (MathAbs(Open[li_20] - (Close[li_20 + 1])) >= 2.0 * ld_32) l_count_16++; | |
li_20++; | |
} | |
if (l_count_16 >= 1) li_24 = li_20; | |
else li_24 = -1; | |
li_20 = li_108; | |
l_count_16 = 0; | |
while (li_20 < li_108 + 6 && l_count_16 < 1) { | |
if (MathAbs(Close[li_20 + 3] - Close[li_20]) >= 4.6 * ld_32) l_count_16++; | |
li_20++; | |
} | |
if (l_count_16 >= 1) li_28 = li_20; | |
else li_28 = -1; | |
if (li_24 > -1) l_period_96 = 3; | |
else l_period_96 = ld_68; | |
if (li_28 > -1) l_period_96 = 4; | |
else l_period_96 = ld_68; | |
ld_0 = 100 - MathAbs(iWPR(NULL, 0, l_period_96, li_108)); | |
lda_64[li_108][0] = li_108; | |
lda_64[li_108][1] = ld_0; | |
ld_48 = 0; | |
ld_56 = 0; | |
ld_8 = 0; | |
if (ld_0 < ld_84) { | |
for (int li_112 = 1; lda_64[li_108 + li_112][1] >= ld_84 && lda_64[li_108 + li_112][1] <= ld_76; li_112++) { | |
} | |
if (lda_64[li_108 + li_112][1] > ld_76) { | |
ld_8 = High[li_108] + ld_32 / 2.0; | |
ld_48 = ld_8; | |
} | |
} | |
if (ld_0 > ld_76) { | |
for (li_112 = 1; lda_64[li_108 + li_112][1] >= ld_84 && lda_64[li_108 + li_112][1] <= ld_76; li_112++) { | |
} | |
if (lda_64[li_108 + li_112][1] < ld_84) { | |
ld_8 = Low[li_108] - ld_32 / 2.0; | |
ld_56 = ld_8; | |
} | |
} | |
if (ld_56 != 0.0 && gi_88 == FALSE) { | |
g_ibuf_80[li_108] = ld_56 - 1.0 * Point; | |
gi_88 = TRUE; | |
gi_92 = FALSE; | |
if (li_104 <= 2) Alert(Symbol(), " ", Period(), "M ReadyFire BUY "); | |
} | |
if (ld_48 != 0.0 && gi_92 == FALSE) { | |
g_ibuf_84[li_108] = ld_48 + 1.0 * Point; | |
gi_92 = TRUE; | |
gi_88 = FALSE; | |
if (li_104 <= 2) Alert(Symbol(), " ", Period(), "M ReadyFire SELL "); | |
} | |
} | |
return (0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
extern string QQ = ""; | |
int eiPercent = 5; | |
int eiOffsetY = 120; | |
int eiStepY = 12; | |
int eiX1Row = 30; | |
int eiX2Row = 165; | |
int eiX3Row = 180; | |
int eiX4Row = 180; | |
int eiX5Row = 275; | |
color ecText = White; | |
color ecProfit = GreenYellow; | |
color ecLoss = Red; | |
//+----------------------------------------------------------------------------+ | |
//| Custom indicator initialization function | | |
//+----------------------------------------------------------------------------+ | |
void init() { | |
DeleteObjects(); | |
if (QQ == ".. . . ") { | |
eiX4Row = 245; | |
eiX5Row = 335; | |
} | |
} | |
//+----------------------------------------------------------------------------+ | |
//| Custom indicator deinitialization function | | |
//+----------------------------------------------------------------------------+ | |
void deinit() { | |
DeleteObjects(); | |
} | |
//+----------------------------------------------------------------------------+ | |
//| Custom indicator iteration function | | |
//+----------------------------------------------------------------------------+ | |
void start() { | |
datetime d0, d1, d2, d3, d4, d5, d6, d7, d8; | |
d0=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)); | |
while (TimeDayOfWeek(d0)<1 || TimeDayOfWeek(d0)>5) d0-=24*60*60; | |
d1=d0-24*60*60; | |
while (TimeDayOfWeek(d1)<1 || TimeDayOfWeek(d1)>5) d1-=24*60*60; | |
d2=d1-24*60*60; | |
while (TimeDayOfWeek(d2)<1 || TimeDayOfWeek(d2)>5) d2-=24*60*60; | |
d3=d2-24*60*60; | |
while (TimeDayOfWeek(d3)<1 || TimeDayOfWeek(d3)>5) d3-=24*60*60; | |
d4=d3-24*60*60; | |
while (TimeDayOfWeek(d4)<1 || TimeDayOfWeek(d4)>5) d4-=24*60*60; | |
d5=DateOfMonday(); | |
d6=StrToTime(Year()+"."+Month()+".01"); | |
d7=DateBeginQuarter(); | |
d8=StrToTime(Year()+".01.01"); | |
double tu=GetProfitOpenPosInPoint(); | |
double u0=GetProfitFromDateInPoint("", -1, -1, d0); | |
double u1=GetProfitFromDateInPoint("", -1, -1, d1)-u0; | |
double u2=GetProfitFromDateInPoint("", -1, -1, d2)-u1-u0; | |
double u3=GetProfitFromDateInPoint("", -1, -1, d3)-u2-u1-u0; | |
double u4=GetProfitFromDateInPoint("", -1, -1, d4)-u3-u2-u1-u0; | |
double u5=GetProfitFromDateInPoint("", -1, -1, d5); | |
double u6=GetProfitFromDateInPoint("", -1, -1, d6); | |
double u7=GetProfitFromDateInPoint("", -1, -1, d7); | |
double u8=GetProfitFromDateInPoint("", -1, -1, d8); | |
double tb=AccountBalance(), tp=AccountProfit(); | |
double p0=GetProfitFromDateInCurrency("", -1, -1, d0); | |
double p1=GetProfitFromDateInCurrency("", -1, -1, d1)-p0; | |
double p2=GetProfitFromDateInCurrency("", -1, -1, d2)-p1-p0; | |
double p3=GetProfitFromDateInCurrency("", -1, -1, d3)-p2-p1-p0; | |
double p4=GetProfitFromDateInCurrency("", -1, -1, d4)-p3-p2-p1-p0; | |
double p5=GetProfitFromDateInCurrency("", -1, -1, d5); | |
double p6=GetProfitFromDateInCurrency("", -1, -1, d6); | |
double p7=GetProfitFromDateInCurrency("", -1, -1, d7); | |
double p8=GetProfitFromDateInCurrency("", -1, -1, d8); | |
string st; | |
switch (eiPercent) { | |
case 0 : st="情報" ; break; | |
case 1 : tb-=p0; st="情報" ; break; | |
case 2 : tb-=p5; st="情報" ; break; | |
case 3 : tb-=p6; st="情報" ; break; | |
case 4 : tb-=p7; st="情報"; break; | |
default: tb-=p8; st="情報" ; break; | |
} | |
double tr=tp*100/tb; | |
double r0=p0*100/tb; | |
double r1=p1*100/tb; | |
double r2=p2*100/tb; | |
double r3=p3*100/tb; | |
double r4=p4*100/tb; | |
double r5=p5*100/tb; | |
double r6=p6*100/tb; | |
double r7=p7*100/tb; | |
double r8=p8*100/tb; | |
if (QQ == ".. . . ") { | |
double l=GetSumLot("",-1,-1); | |
double lu=NormalizeDouble(l,2); | |
double l0=GetLotFromDate("", -1, -1, d0); | |
double l1=GetLotFromDate("", -1, -1, d1)-l0; | |
double l2=GetLotFromDate("", -1, -1, d2)-l1-l0; | |
double l3=GetLotFromDate("", -1, -1, d3)-l2-l1-l0; | |
double l4=GetLotFromDate("", -1, -1, d4)-l3-l2-l1-l0; | |
double l5=GetLotFromDate("", -1, -1, d5); | |
double l6=GetLotFromDate("", -1, -1, d6); | |
double l7=GetLotFromDate("", -1, -1, d7); | |
double l8=GetLotFromDate("", -1, -1, d8); | |
SetLabel("iProfit08", "Lots", ecText, eiX3Row, eiOffsetY+105); | |
SetLabel("iProfit15", DoubleToStr(lu, 2), ColorOnSign(tp), eiX3Row, eiOffsetY+1*eiStepY+120); | |
SetLabel("iProfit25", DoubleToStr(l0, 2), ColorOnSign(l0), eiX3Row, eiOffsetY+2*eiStepY+125); | |
SetLabel("iProfit35", DoubleToStr(l1, 2), ColorOnSign(l1), eiX3Row, eiOffsetY+3*eiStepY+130); | |
SetLabel("iProfit45", DoubleToStr(l2, 2), ColorOnSign(l2), eiX3Row, eiOffsetY+4*eiStepY+135); | |
SetLabel("iProfit55", DoubleToStr(l3, 2), ColorOnSign(l3), eiX3Row, eiOffsetY+5*eiStepY+140); | |
SetLabel("iProfit65", DoubleToStr(l4, 2), ColorOnSign(l4), eiX3Row, eiOffsetY+6*eiStepY+145); | |
SetLabel("iProfit75", DoubleToStr(l5, 2), ColorOnSign(l5), eiX3Row, eiOffsetY+7*eiStepY+150); | |
SetLabel("iProfit85", DoubleToStr(l6, 2), ColorOnSign(l6), eiX3Row, eiOffsetY+8*eiStepY+155); | |
//SetLabel("iProfit95", DoubleToStr(l7, 2), ColorOnSign(l7), eiX3Row, eiOffsetY+9*eiStepY+160); | |
SetLabel("iProfit95", DoubleToStr(l8, 2), ColorOnSign(l8), eiX3Row, eiOffsetY+9*eiStepY+160); | |
SetLabel("iProfit05", DoubleToStr(l8+lu, 2), ColorOnSign(l8+lu), eiX3Row, eiOffsetY+10*eiStepY+165); | |
} | |
SetLabel("iProfit09", "Score % based ", ecText, eiX1Row-28, eiOffsetY+105); | |
SetLabel("iProfit07", "SCORE IN$", ecText, eiX4Row, eiOffsetY+105); | |
SetLabel("iProfit10", "SCORE IN%", ecText, eiX5Row, eiOffsetY+105); | |
SetLabel("iProfit11", "Score for open trades", ecText, eiX1Row-28, eiOffsetY+1*eiStepY+120); | |
SetLabel("iProfit21", "Score for today", ecText, eiX1Row-28, eiOffsetY+2*eiStepY+125); | |
SetLabel("iProfit31", "Score for"+TimeToStr(d1, TIME_DATE), ecText, eiX1Row-28, eiOffsetY+3*eiStepY+130); | |
SetLabel("iProfit41", "Score for"+TimeToStr(d2, TIME_DATE), ecText, eiX1Row-28, eiOffsetY+4*eiStepY+135); | |
SetLabel("iProfit51", "Score for"+TimeToStr(d3, TIME_DATE), ecText, eiX1Row-28, eiOffsetY+5*eiStepY+140); | |
SetLabel("iProfit61", "Score for"+TimeToStr(d4, TIME_DATE), ecText, eiX1Row-28, eiOffsetY+6*eiStepY+145); | |
SetLabel("iProfit71", "Score for the week", ecText, eiX1Row-28, eiOffsetY+7*eiStepY+150); | |
SetLabel("iProfit81", "Score for the month", ecText, eiX1Row-28, eiOffsetY+8*eiStepY+155); | |
SetLabel("iProfit91", "Score for the time", ecText, eiX1Row-28, eiOffsetY+9*eiStepY+160); | |
SetLabel("iProfit01", "Score for net profit", ecText, eiX1Row-28, eiOffsetY+10*eiStepY+165); | |
SetLabel("iProfit13", DoubleToStr(tp, 2), ColorOnSign(tp), eiX4Row, eiOffsetY+1*eiStepY+120); | |
SetLabel("iProfit23", DoubleToStr(p0, 2), ColorOnSign(p0), eiX4Row, eiOffsetY+2*eiStepY+125); | |
SetLabel("iProfit33", DoubleToStr(p1, 2), ColorOnSign(p1), eiX4Row, eiOffsetY+3*eiStepY+130); | |
SetLabel("iProfit43", DoubleToStr(p2, 2), ColorOnSign(p2), eiX4Row, eiOffsetY+4*eiStepY+135); | |
SetLabel("iProfit53", DoubleToStr(p3, 2), ColorOnSign(p3), eiX4Row, eiOffsetY+5*eiStepY+140); | |
SetLabel("iProfit63", DoubleToStr(p4, 2), ColorOnSign(p4), eiX4Row, eiOffsetY+6*eiStepY+145); | |
SetLabel("iProfit73", DoubleToStr(p5, 2), ColorOnSign(p5), eiX4Row, eiOffsetY+7*eiStepY+150); | |
SetLabel("iProfit83", DoubleToStr(p6, 2), ColorOnSign(p6), eiX4Row, eiOffsetY+8*eiStepY+155); | |
SetLabel("iProfit93", DoubleToStr(p8, 2), ColorOnSign(p8), eiX4Row, eiOffsetY+9*eiStepY+160); | |
SetLabel("iProfit03", DoubleToStr(p8+tp, 2), ColorOnSign(p8+tp), eiX4Row, eiOffsetY+10*eiStepY+165); | |
SetLabel("iProfit14", DoubleToStr(tr, 2)+" %", ColorOnSign(tr), eiX5Row, eiOffsetY+1*eiStepY+120); | |
SetLabel("iProfit24", DoubleToStr(r0, 2)+" %", ColorOnSign(r0), eiX5Row, eiOffsetY+2*eiStepY+125); | |
SetLabel("iProfit34", DoubleToStr(r1, 2)+" %", ColorOnSign(r1), eiX5Row, eiOffsetY+3*eiStepY+130); | |
SetLabel("iProfit44", DoubleToStr(r2, 2)+" %", ColorOnSign(r2), eiX5Row, eiOffsetY+4*eiStepY+135); | |
SetLabel("iProfit54", DoubleToStr(r3, 2)+" %", ColorOnSign(r3), eiX5Row, eiOffsetY+5*eiStepY+140); | |
SetLabel("iProfit64", DoubleToStr(r4, 2)+" %", ColorOnSign(r4), eiX5Row, eiOffsetY+6*eiStepY+145); | |
SetLabel("iProfit74", DoubleToStr(r5, 2)+" %", ColorOnSign(r5), eiX5Row, eiOffsetY+7*eiStepY+150); | |
SetLabel("iProfit84", DoubleToStr(r6, 2)+" %", ColorOnSign(r6), eiX5Row, eiOffsetY+8*eiStepY+155); | |
SetLabel("iProfit94", DoubleToStr(r8, 2)+" %", ColorOnSign(r7), eiX5Row, eiOffsetY+9*eiStepY+160); | |
SetLabel("iProfit04", DoubleToStr(r8+tr, 2)+" %", ColorOnSign(r8+tr), eiX5Row, eiOffsetY+10*eiStepY+165); | |
} | |
color ColorOnSign(double nu) { | |
color lcColor=ecText; | |
if (nu>0) lcColor=ecProfit; | |
if (nu<0) lcColor=ecLoss; | |
return(lcColor); | |
} | |
datetime DateBeginQuarter(int nk=0) { | |
int ye=Year()-MathFloor(nk/4); | |
nk=MathMod(nk, 4); | |
int mo=Month()-MathMod(Month()+2, 3)+3*nk; | |
if (mo<1) { | |
mo+=12; | |
ye--; | |
} | |
if (mo>12) { | |
mo-=12; | |
ye++; | |
} | |
return(StrToTime(ye+"."+mo+".01")); | |
} | |
datetime DateOfMonday(int no=0) { | |
datetime dt=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)); | |
while (TimeDayOfWeek(dt)!=1) dt-=24*60*60; | |
dt+=no*7*24*60*60; | |
return(dt); | |
} | |
void DeleteObjects() { | |
string st="iProfit"; | |
int i, j; | |
for (i=0; i<12; i++) { | |
for (j=1; j<=10; j++) | |
{ | |
ObjectDelete(st+j); | |
ObjectDelete(st+i+j); | |
} | |
} | |
} | |
double GetProfitFromDateInCurrency(string sy="", int op=-1, int mn=-1, datetime dt=0) | |
{ | |
double p=0; | |
int i, k=OrdersHistoryTotal(); | |
if (sy=="0") sy=Symbol(); | |
for (i=0; i<k; i++) { | |
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) { | |
if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) { | |
if (OrderType()==OP_BUY || OrderType()==OP_SELL) { | |
if (mn<0 || OrderMagicNumber()==mn) { | |
if (dt<OrderCloseTime()) { | |
p+=OrderProfit()+OrderCommission()+OrderSwap(); | |
} | |
} | |
} | |
} | |
} | |
} | |
return(p); | |
} | |
//+-------------------------------------------- | |
double GetProfitFromDateInPoint(string sy="", int op=-1, int mn=-1, datetime dt=0) | |
{ | |
double p=0, po; | |
int i, k=OrdersHistoryTotal(); | |
if (sy=="0") sy=Symbol(); | |
for (i=0; i<k; i++) { | |
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) { | |
if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) { | |
if (OrderType()==OP_BUY || OrderType()==OP_SELL) { | |
if (mn<0 || OrderMagicNumber()==mn) { | |
if (dt<OrderCloseTime()) { | |
po=MarketInfo(OrderSymbol(), MODE_POINT); | |
if (po==0) if (StringFind(sy, "JPY")<0) po=0.0001; else po=0.01; | |
if (OrderType()==OP_BUY) { | |
p+=(OrderClosePrice()-OrderOpenPrice())/po; | |
} | |
if (OrderType()==OP_SELL) { | |
p+=(OrderOpenPrice()-OrderClosePrice())/po; | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
return(p); | |
} | |
//+----------------------------------------------------------------------------+ | |
//+----------------------------------------------------------------------------+ | |
int GetProfitOpenPosInPoint(string sy="", int op=-1, int mn=-1) { | |
double p; | |
int i, k=OrdersTotal(), pr=0; | |
if (sy=="0") sy=Symbol(); | |
for (i=0; i<k; i++) { | |
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { | |
if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) { | |
if (mn<0 || OrderMagicNumber()==mn) { | |
p=MarketInfo(OrderSymbol(), MODE_POINT); | |
if (p==0) if (StringFind(OrderSymbol(), "JPY")<0) p=0.0001; else p=0.01; | |
if (OrderType()==OP_BUY) { | |
pr+=(MarketInfo(OrderSymbol(), MODE_BID)-OrderOpenPrice())/p; | |
} | |
if (OrderType()==OP_SELL) { | |
pr+=(OrderOpenPrice()-MarketInfo(OrderSymbol(), MODE_ASK))/p; | |
} | |
} | |
} | |
} | |
} | |
return(pr); | |
} | |
void SetLabel(string nm, string tx, color cl, int xd, int yd, int cr=0, int fs=9) { | |
if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_LABEL, 0, 0,0); | |
ObjectSetText(nm, tx, fs); | |
ObjectSet(nm, OBJPROP_COLOR , cl); | |
ObjectSet(nm, OBJPROP_XDISTANCE, xd); | |
ObjectSet(nm, OBJPROP_YDISTANCE, yd); | |
ObjectSet(nm, OBJPROP_CORNER , cr); | |
ObjectSet(nm, OBJPROP_FONTSIZE , fs); | |
} | |
//+----------------------------------------------------------------------------+ | |
double GetSumLot(string sy="", int op=-1, int mn=-1) | |
{ | |
double b=0,s=0,p=0; | |
int i; | |
if (sy=="0") sy=Symbol(); | |
for (i=0; i<OrdersTotal(); i++) { | |
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { | |
if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) { | |
if (mn<0 || OrderMagicNumber()==mn) { | |
if (OrderType()==OP_BUY) { | |
b+=OrderLots(); | |
} | |
if (OrderType()==OP_SELL) { | |
s+=OrderLots(); | |
} | |
}p=b+s; | |
} | |
} | |
} | |
return(p); | |
} | |
double GetLotFromDate(string sy="", int op=-1, int mn=-1, datetime dt=0) | |
{ | |
double p=0; | |
int i, k=OrdersHistoryTotal(); | |
if (sy=="0") sy=Symbol(); | |
for (i=0; i<k; i++) { | |
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) { | |
if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) { | |
if (OrderType()==OP_BUY || OrderType()==OP_SELL) { | |
if (mn<0 || OrderMagicNumber()==mn) { | |
if (dt<OrderCloseTime()) { | |
p+=OrderLots(); | |
} | |
} | |
} | |
} | |
} | |
} | |
return(p); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
int eiPercent = 6; | |
int gi_80 = 180; | |
int gi_84 = 16; | |
int gi_88 = 3; | |
int gi_92 = 295; | |
int gi_96 = 390; | |
color ecText = White; | |
color ecProfit = GreenYellow; | |
color ecLoss = Red; | |
void init() { | |
DeleteObjects(); | |
Comment(""); | |
} | |
void deinit() { | |
DeleteObjects(); | |
Comment(""); | |
} | |
void start() { | |
string ls_136; | |
for (int li_0 = StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)); TimeDayOfWeek(li_0) < 1 || TimeDayOfWeek(li_0) > 5; li_0 -= 86400) { | |
} | |
for (int li_4 = li_0 - 86400; TimeDayOfWeek(li_4) < 1 || TimeDayOfWeek(li_4) > 5; li_4 -= 86400) { | |
} | |
for (int li_8 = li_4 - 86400; TimeDayOfWeek(li_8) < 1 || TimeDayOfWeek(li_8) > 5; li_8 -= 86400) { | |
} | |
for (int li_12 = li_8 - 86400; TimeDayOfWeek(li_12) < 1 || TimeDayOfWeek(li_12) > 5; li_12 -= 86400) { | |
} | |
for (int li_16 = li_12 - 86400; TimeDayOfWeek(li_16) < 1 || TimeDayOfWeek(li_16) > 5; li_16 -= 86400) { | |
} | |
int li_20 = DateOfMonday(); | |
int li_24 = StrToTime(Year() + "." + Month() + ".01"); | |
int li_28 = DateBeginQuarter(); | |
int li_32 = StrToTime(Year() + ".01.01"); | |
int li_36 = StrToTime("1901.01.01"); | |
double ld_40 = AccountBalance(); | |
double ld_48 = AccountProfit(); | |
double ld_56 = GetProfitFromDateInCurrency("", -1, -1, li_0); | |
double ld_64 = GetProfitFromDateInCurrency("", -1, -1, li_4) - ld_56; | |
double ld_72 = GetProfitFromDateInCurrency("", -1, -1, li_8) - ld_64 - ld_56; | |
double ld_80 = GetProfitFromDateInCurrency("", -1, -1, li_12) - ld_72 - ld_64 - ld_56; | |
double ld_88 = GetProfitFromDateInCurrency("", -1, -1, li_16) - ld_80 - ld_72 - ld_64 - ld_56; | |
double ld_96 = GetProfitFromDateInCurrency("", -1, -1, li_20); | |
double ld_104 = GetProfitFromDateInCurrency("", -1, -1, li_24); | |
double ld_112 = GetProfitFromDateInCurrency("", -1, -1, li_28); | |
double ld_120 = GetProfitFromDateInCurrency("", -1, -1, li_32); | |
double ld_128 = GetProfitFromDateInCurrency("", -1, -1, li_36); | |
switch (eiPercent) { | |
case 0: | |
ls_136 = "current account balance"; | |
break; | |
case 1: | |
ld_40 -= ld_56; | |
ls_136 = "balance at the beginning of the day"; | |
break; | |
case 2: | |
ld_40 -= ld_96; | |
ls_136 = "balance at the beginning of the week"; | |
break; | |
case 3: | |
ld_40 -= ld_104; | |
ls_136 = "balance at the beginning of the month"; | |
break; | |
case 4: | |
ld_40 -= ld_112; | |
ls_136 = "balance at the beginning of the quarter"; | |
break; | |
case 5: | |
ld_40 -= ld_120; | |
ls_136 = "balance at the beginning of the year"; | |
break; | |
case 6: | |
ld_40 -= ld_128; | |
ls_136 = "the account opening capital"; | |
} | |
double ld_148 = 100.0 * ld_48 / ld_40; | |
double ld_156 = 100.0 * ld_56 / ld_40; | |
double ld_164 = 100.0 * ld_64 / ld_40; | |
double ld_172 = 100.0 * ld_72 / ld_40; | |
double ld_180 = 100.0 * ld_80 / ld_40; | |
double ld_188 = 100.0 * ld_88 / ld_40; | |
double ld_196 = 100.0 * ld_96 / ld_40; | |
double ld_204 = 100.0 * ld_104 / ld_40; | |
double ld_212 = 100.0 * ld_112 / ld_40; | |
double ld_220 = 100.0 * ld_120 / ld_40; | |
double ld_228 = 100.0 * ld_128 / ld_40; | |
SetLabel("iProfit0", "Score % based on " + ls_136, ecText, gi_88, gi_80 +1* gi_84); | |
SetLabel("iProfit11", "目前戰況", ecText, gi_88, gi_80+3* gi_84); | |
SetLabel("iProfit21", "今日擄獲外星戰俘數量", ecText, gi_88, gi_80 +4* gi_84); | |
SetLabel("iProfit31", "擄獲外星戰俘數量 " + TimeToStr(li_4, TIME_DATE), ecText, gi_88, gi_80 + 5* gi_84); | |
SetLabel("iProfit41", "擄獲外星戰俘數量 " + TimeToStr(li_8, TIME_DATE), ecText, gi_88, gi_80 + 6 * gi_84); | |
SetLabel("iProfit51", "擄獲外星戰俘數量 " + TimeToStr(li_12, TIME_DATE), ecText, gi_88, gi_80 + 7 * gi_84); | |
SetLabel("iProfit61", "擄獲外星戰俘數量 " + TimeToStr(li_16, TIME_DATE), ecText, gi_88, gi_80 + 8 * gi_84); | |
SetLabel("iProfit71", "周擄獲外星戰俘數量", ecText, gi_88, gi_80 + 9 * gi_84); | |
SetLabel("iProfit81", "月擄獲外星戰俘數量", ecText, gi_88, gi_80 + 10 * gi_84); | |
SetLabel("iProfit91", "季擄獲外星戰俘數量", ecText, gi_88, gi_80 + 11 * gi_84); | |
SetLabel("iProfit01", "年擄獲外星戰俘數量", ecText, gi_88, gi_80 + 12 * gi_84); | |
SetLabel("iProfit111", "擄獲外星戰俘數量總計", ecText, gi_88, gi_80 + 13 * gi_84); | |
SetLabel("iProfit2", "SCORE IN $", ecText, gi_92, gi_80 + 1* gi_84); | |
SetLabel("iProfit12", DoubleToStr(ld_48, 2), ColorOnSign(ld_48), gi_92, gi_80+3* gi_84); | |
SetLabel("iProfit22", DoubleToStr(ld_56, 2), ColorOnSign(ld_56), gi_92, gi_80 +4* gi_84 ); | |
SetLabel("iProfit32", DoubleToStr(ld_64, 2), ColorOnSign(ld_64), gi_92, gi_80 + gi_84 * 5); | |
SetLabel("iProfit42", DoubleToStr(ld_72, 2), ColorOnSign(ld_72), gi_92, gi_80 + 6 * gi_84); | |
SetLabel("iProfit52", DoubleToStr(ld_80, 2), ColorOnSign(ld_80), gi_92, gi_80 + 7 * gi_84); | |
SetLabel("iProfit62", DoubleToStr(ld_88, 2), ColorOnSign(ld_88), gi_92, gi_80 + 8 * gi_84); | |
SetLabel("iProfit72", DoubleToStr(ld_96, 2), ColorOnSign(ld_96), gi_92, gi_80 + 9 * gi_84); | |
SetLabel("iProfit82", DoubleToStr(ld_104, 2), ColorOnSign(ld_104), gi_92, gi_80 + 10 * gi_84); | |
SetLabel("iProfit92", DoubleToStr(ld_112, 2), ColorOnSign(ld_112), gi_92, gi_80 + 11 * gi_84); | |
SetLabel("iProfit02", DoubleToStr(ld_120, 2), ColorOnSign(ld_120), gi_92, gi_80 + 12 * gi_84); | |
SetLabel("iProfit112", DoubleToStr(ld_128, 2), ColorOnSign(ld_128), gi_92, gi_80 + 13 * gi_84); | |
SetLabel("iProfit3", "SCORE IN %", ecText, gi_96, gi_80 + 1* gi_84); | |
SetLabel("iProfit13", DoubleToStr(ld_148, 2) + " %", ColorOnSign(ld_148), gi_96, gi_80+3* gi_84); | |
SetLabel("iProfit23", DoubleToStr(ld_156, 2) + " %", ColorOnSign(ld_156), gi_96, gi_80 + 4* gi_84); | |
SetLabel("iProfit33", DoubleToStr(ld_164, 2) + " %", ColorOnSign(ld_164), gi_96, gi_80 + gi_84 * 5); | |
SetLabel("iProfit43", DoubleToStr(ld_172, 2) + " %", ColorOnSign(ld_172), gi_96, gi_80 + 6 * gi_84); | |
SetLabel("iProfit53", DoubleToStr(ld_180, 2) + " %", ColorOnSign(ld_180), gi_96, gi_80 + 7 * gi_84); | |
SetLabel("iProfit63", DoubleToStr(ld_188, 2) + " %", ColorOnSign(ld_188), gi_96, gi_80 + 8 * gi_84); | |
SetLabel("iProfit73", DoubleToStr(ld_196, 2) + " %", ColorOnSign(ld_196), gi_96, gi_80 + 9 * gi_84); | |
SetLabel("iProfit83", DoubleToStr(ld_204, 2) + " %", ColorOnSign(ld_204), gi_96, gi_80 + 10 * gi_84); | |
SetLabel("iProfit93", DoubleToStr(ld_212, 2) + " %", ColorOnSign(ld_212), gi_96, gi_80 + 11 * gi_84); | |
SetLabel("iProfit03", DoubleToStr(ld_220, 2) + " %", ColorOnSign(ld_220), gi_96, gi_80 + 12 * gi_84); | |
SetLabel("iProfit113", DoubleToStr(ld_228, 2) + " %", ColorOnSign(ld_220), gi_96, gi_80 + 13 * gi_84); | |
} | |
int ColorOnSign(double ad_0) { | |
int li_8 = ecText; | |
if (ad_0 > 0.0) li_8 = ecProfit; | |
if (ad_0 < 0.0) li_8 = ecLoss; | |
return (li_8); | |
} | |
int DateBeginQuarter(int ai_0 = 0) { | |
int li_4 = Year() - MathFloor(ai_0 / 4); | |
ai_0 = MathMod(ai_0, 4); | |
int li_8 = Month() - MathMod(Month() + 2, 3) + 3 * ai_0; | |
if (li_8 < 1) { | |
li_8 += 12; | |
li_4--; | |
} | |
if (li_8 > 12) { | |
li_8 -= 12; | |
li_4++; | |
} | |
return (StrToTime(li_4 + "." + li_8 + ".01")); | |
} | |
int DateOfMonday(int ai_0 = 0) { | |
for (int li_4 = StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)); TimeDayOfWeek(li_4) != 1; li_4 -= 86400) { | |
} | |
li_4 += 60 * (60 * (24 * (7 * ai_0))); | |
return (li_4); | |
} | |
void DeleteObjects() { | |
string ls_0 = "iProfit"; | |
for (int li_8 = 0; li_8 < 10; li_8++) for (int li_12 = 1; li_12 < 4; li_12++) ObjectDelete(ls_0 + li_8 + li_12); | |
} | |
double GetProfitFromDateInCurrency(string as_0 = "", int ai_8 = -1, int ai_12 = -1, int ai_16 = 0) { | |
double ld_20 = 0; | |
int li_32 = OrdersHistoryTotal(); | |
if (as_0 == "0") as_0 = Symbol(); | |
for (int li_28 = 0; li_28 < li_32; li_28++) { | |
if (OrderSelect(li_28, SELECT_BY_POS, MODE_HISTORY)) { | |
if (OrderSymbol() == as_0 || as_0 == "" && ai_8 < OP_BUY || OrderType() == ai_8) { | |
if (OrderType() == OP_BUY || OrderType() == OP_SELL) { | |
if (ai_12 < 0 || OrderMagicNumber() == ai_12) | |
if (ai_16 < OrderCloseTime()) ld_20 += OrderProfit() + OrderCommission() + OrderSwap(); | |
} | |
} | |
} | |
} | |
return (ld_20); | |
} | |
void SetLabel(string as_0, string as_8, color ai_16, int ai_20, int ai_24, int ai_28 = 0, int ai_32 = 9) { | |
if (ObjectFind(as_0) < 0) ObjectCreate(as_0, OBJ_LABEL, 0, 0, 0); | |
ObjectSetText(as_0, as_8, ai_32); | |
ObjectSet(as_0, OBJPROP_COLOR, ai_16); | |
ObjectSet(as_0, OBJPROP_XDISTANCE, ai_20); | |
ObjectSet(as_0, OBJPROP_YDISTANCE, ai_24); | |
ObjectSet(as_0, OBJPROP_CORNER, ai_28); | |
ObjectSet(as_0, OBJPROP_FONTSIZE, ai_32); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
#property indicator_buffers 2 | |
#property indicator_color1 Aqua | |
#property indicator_color2 Red | |
int period = 80; | |
int method = 3; | |
int price = 0; | |
double gda_88[]; | |
double gda_92[]; | |
double gda_96[]; | |
int init() { | |
IndicatorBuffers(3); | |
SetIndexBuffer(0, gda_88); | |
SetIndexBuffer(1, gda_92); | |
SetIndexBuffer(2, gda_96); | |
ArraySetAsSeries(gda_96, TRUE); | |
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2); | |
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2); | |
IndicatorShortName("Slope Direction Line(" + period + ")"); | |
return (0); | |
} | |
int deinit() { | |
return (0); | |
} | |
double WMA(int ai_0, int ai_4) { | |
return (iMA(NULL, 0, ai_4, 0, method, price, ai_0)); | |
} | |
int start() { | |
double lda_16[]; | |
double lda_20[]; | |
int li_0 = IndicatorCounted(); | |
if (li_0 < 0) return (-1); | |
int li_4 = 0; | |
int li_8 = MathSqrt(period); | |
int li_12 = Bars - li_0 + period + 1; | |
if (li_12 > Bars) li_12 = Bars; | |
ArrayResize(lda_16, li_12); | |
ArraySetAsSeries(lda_16, TRUE); | |
ArrayResize(lda_20, li_12); | |
ArraySetAsSeries(lda_20, TRUE); | |
for (li_4 = 0; li_4 < li_12; li_4++) lda_16[li_4] = 2.0 * WMA(li_4, period / 2) - WMA(li_4, period); | |
for (li_4 = 0; li_4 < li_12 - period; li_4++) gda_96[li_4] = iMAOnArray(lda_16, 0, li_8, 0, method, li_4); | |
for (li_4 = li_12 - period; li_4 >= 0; li_4--) { | |
lda_20[li_4] = lda_20[li_4 + 1]; | |
if (gda_96[li_4] > gda_96[li_4 + 1]) lda_20[li_4] = 1; | |
if (gda_96[li_4] < gda_96[li_4 + 1]) lda_20[li_4] = -1; | |
if (lda_20[li_4] > 0.0) { | |
gda_88[li_4] = gda_96[li_4]; | |
if (lda_20[li_4 + 1] < 0.0) gda_88[li_4 + 1] = gda_96[li_4 + 1]; | |
gda_92[li_4] = EMPTY_VALUE; | |
} else { | |
if (lda_20[li_4] < 0.0) { | |
gda_92[li_4] = gda_96[li_4]; | |
if (lda_20[li_4 + 1] > 0.0) gda_92[li_4 + 1] = gda_96[li_4 + 1]; | |
gda_88[li_4] = EMPTY_VALUE; | |
} | |
} | |
} | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment