Jump to content

Indi-for-indo & info


4xmeter

Recommended Posts

Thanks for your sharing (2) :D

 

You are welcome!

 

A friend sent me this nice indicator originally called Bluejay's lines

 

#property indicator_chart_window

 

extern double StartPrice = 0.0;

extern int NumLines = 2;

extern int Spacing = 25;

extern string AboveBelow = "AB";

extern color LineColor = Gray;

extern int LineWidth = 1;

extern int LineStyle = 0;

extern string TimeFrames = "M1, M5, M15, M30, H1, H4, D1, W1, MN";

string gs_120;

 

int init() {

int li_0 = 0;

string ls_4 = NumberToStr(StartPrice, "2.5") + NumberToStr(NumLines, "3") + NumberToStr(Spacing, "4.1") + AboveBelow + TimeToStr(TimeLocal(), TIME_SECONDS);

for (int li_12 = 0; li_12 < StringLen(ls_4); li_12++) li_0 += li_12 * StringGetChar(ls_4, li_12);

gs_120 = "SpacedLines-" + li_0;

IndicatorShortName(gs_120);

del_obj();

plot_obj();

return (0);

}

 

int deinit() {

del_obj();

return (0);

}

 

int start() {

return (0);

}

 

int MathSign(double ad_0) {

if (ad_0 > 0.0) return (1);

if (ad_0 < 0.0) return (-1);

return (0);

}

 

double MathFix(double ad_0, int ai_8) {

return (MathRound(ad_0 * MathPow(10, ai_8) + 0.0 * MathSign(ad_0)) / MathPow(10, ai_8));

}

 

void plot_obj() {

double ld_4;

double ld_12;

string l_name_32;

TimeFrames = StringUpper(TimeFrames) + ",";

int li_0 = 0;

if (StringFind(TimeFrames, "M1,") >= 0) li_0++;

if (StringFind(TimeFrames, "M5,") >= 0) li_0 += 2;

if (StringFind(TimeFrames, "M15,") >= 0) li_0 += 4;

if (StringFind(TimeFrames, "M30,") >= 0) li_0 += 8;

if (StringFind(TimeFrames, "H1,") >= 0) li_0 += 16;

if (StringFind(TimeFrames, "H4,") >= 0) li_0 += 32;

if (StringFind(TimeFrames, "D1,") >= 0) li_0 += 64;

if (StringFind(TimeFrames, "W1,") >= 0) li_0 += 128;

if (StringFind(TimeFrames, "MN,") >= 0) li_0 += 256;

if (Digits >= 4) {

ld_4 = 0.0001;

ld_12 = MathFix(Close[0], 2);

} else {

ld_4 = 0.01;

ld_12 = MathFix(Close[0], 0);

}

if (StartPrice > 0.0) ld_12 = StartPrice;

AboveBelow = StringUpper(AboveBelow);

int li_20 = 0;

int li_24 = 0;

if (AboveBelow == "A") {

li_20 = -1;

li_24 = NumLines - 2;

} else {

if (AboveBelow == "B") {

li_20 = (-NumLines) + 2;

li_24 = 1;

} else {

if (AboveBelow == "AB") {

li_20 = (-NumLines) + 1;

li_24 = NumLines - 1;

}

}

}

for (int li_28 = li_20; li_28 <= li_24; li_28++) {

l_name_32 = gs_120 + "-" + li_28;

ObjectCreate(l_name_32, OBJ_HLINE, 0, 0, ld_12 + Spacing * ld_4 * li_28);

ObjectSet(l_name_32, OBJPROP_COLOR, LineColor);

ObjectSet(l_name_32, OBJPROP_WIDTH, LineWidth);

ObjectSet(l_name_32, OBJPROP_STYLE, LineStyle);

ObjectSet(l_name_32, OBJPROP_TIMEFRAMES, li_0);

}

}

 

void del_obj() {

string l_name_4;

int li_0 = 0;

while (li_0 < ObjectsTotal()) {

l_name_4 = ObjectName(li_0);

if (StringSubstr(l_name_4, 0, StringLen(gs_120)) == gs_120) ObjectDelete(l_name_4);

else li_0++;

}

}

 

string StringUpper(string as_0) {

int li_36;

string ls_ret_8 = "";

string ls_16 = "abcdefghijklmnopqrstuvwxyz";

string ls_24 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

for (int li_32 = 0; li_32 < StringLen(as_0); li_32++) {

li_36 = StringFind(ls_16, StringSubstr(as_0, li_32, 1), 0);

if (li_36 >= 0) ls_ret_8 = ls_ret_8 + StringSubstr(ls_24, li_36, 1);

else ls_ret_8 = ls_ret_8 + StringSubstr(as_0, li_32, 1);

}

return (ls_ret_8);

}

 

string NumberToStr(double ad_0, string as_8) {

string ls_36;

bool li_68;

bool li_72;

bool li_76;

bool li_80;

bool li_84;

bool li_88;

bool li_92;

string ls_108;

bool li_116;

bool li_120;

string ls_124;

string ls_132;

int l_str_len_144;

as_8 = StringUpper(as_8);

int li_16 = 0;

int li_20 = StringFind(as_8, ".", 0);

if (li_20 < 0) {

li_20 = StringLen(as_8);

li_16 = 1;

}

int li_24 = 0;

int li_28 = 0;

for (int li_32 = 0; li_32 < li_20; li_32++) {

ls_36 = StringSubstr(as_8, li_32, 1);

if (ls_36 >= "0" && ls_36 <= "9") li_24 = 10 * li_24 + StrToInteger(ls_36);

}

if (li_16 == 0) {

for (li_32 = li_20 + 1; li_32 <= StringLen(as_8); li_32++) {

ls_36 = StringSubstr(as_8, li_32, 1);

if (ls_36 >= "0" && ls_36 <= "9") li_28 = 10 * li_28 + StrToInteger(ls_36);

}

}

li_28 = MathMin(li_28, 7);

if (li_16 == 1) {

for (li_32 = 0; li_32 < StringLen(as_8); li_32++) {

ls_36 = StringSubstr(as_8, li_32, 1);

if (ls_36 >= "0" && ls_36 <= "9") {

li_20 = li_32;

break;

}

}

}

string ls_44 = "";

if (StringFind(as_8, "$", 0) >= 0) ls_44 = "$";

if (StringFind(as_8, "£", 0) >= 0) ls_44 = "£";

if (StringFind(as_8, "€", 0) >= 0) ls_44 = "€";

if (StringFind(as_8, "¥", 0) >= 0) ls_44 = "¥";

string ls_52 = "";

string ls_60 = "";

if (StringFind(as_8, "+", 0) >= 0 && StringFind(as_8, "+", 0) < li_20) {

ls_52 = " ";

if (ad_0 > 0.0) ls_52 = "+";

if (ad_0 < 0.0) ls_52 = "-";

}

if (StringFind(as_8, "-", 0) >= 0 && StringFind(as_8, "-", 0) < li_20) {

if (ad_0 < 0.0) ls_52 = "-";

else ls_52 = " ";

}

if (StringFind(as_8, "-", 0) >= 0 && StringFind(as_8, "-", 0) > li_20) {

if (ad_0 < 0.0) ls_60 = "-";

else ls_60 = " ";

}

if (StringFind(as_8, "(", 0) >= 0 || StringFind(as_8, ")", 0) >= 0) {

ls_52 = " ";

ls_60 = " ";

if (ad_0 < 0.0) {

ls_52 = "(";

ls_60 = ")";

}

}

if (StringFind(as_8, ",", 0) >= 0) li_68 = TRUE;

else li_68 = FALSE;

if (StringFind(as_8, "Z", 0) >= 0) li_72 = TRUE;

else li_72 = FALSE;

if (StringFind(as_8, "B", 0) >= 0) li_76 = TRUE;

else li_76 = FALSE;

if (StringFind(as_8, "R", 0) >= 0) li_80 = TRUE;

else li_80 = FALSE;

if (StringFind(as_8, "*", 0) >= 0) li_84 = TRUE;

else li_84 = FALSE;

if (StringFind(as_8, "L", 0) >= 0) li_88 = TRUE;

else li_88 = FALSE;

if (StringFind(as_8, ";", 0) >= 0) li_92 = TRUE;

else li_92 = FALSE;

if (li_80) ad_0 = MathFix(ad_0, li_28);

string ls_ret_96 = ad_0;

int l_count_104 = 0;

for (li_32 = 0; li_32 < StringLen(ls_ret_96); li_32++) {

ls_36 = StringSubstr(ls_ret_96, li_32, 1);

if (ls_36 >= "0" && ls_36 <= "9") l_count_104++;

if (ls_36 == ".") break;

}

if (li_72) ls_108 = "0";

else ls_108 = " ";

if (ad_0 < 0.0) ls_ret_96 = "-" + StringRepeat(ls_108, li_24 - l_count_104) + StringSubstr(ls_ret_96, 1, StringLen(ls_ret_96) - 1);

else ls_ret_96 = StringRepeat(ls_108, li_24 - l_count_104) + StringSubstr(ls_ret_96, 0, StringLen(ls_ret_96));

ls_ret_96 = StringSubstr(ls_ret_96, StringLen(ls_ret_96) - 9 - li_24, li_24 + 1 + li_28 - li_16);

if (li_68) {

li_116 = FALSE;

li_120 = FALSE;

ls_124 = "";

ls_132 = "";

for (li_32 = 0; li_32 < StringLen(ls_ret_96); li_32++) {

ls_36 = StringSubstr(ls_ret_96, li_32, 1);

if (ls_36 == ".") li_120 = TRUE;

if (!li_120 && li_24 - li_32 == 3 || li_24 - li_32 == 6 || li_24 - li_32 == 9) {

if (li_116) ls_124 = ls_124 + ",";

else ls_124 = ls_124 + " ";

}

ls_124 = ls_124 + ls_36;

if (ls_36 >= "0" && ls_36 <= "9") li_116 = TRUE;

}

ls_ret_96 = ls_124;

}

ls_ret_96 = ls_44 + ls_52 + ls_ret_96 + ls_60;

ls_124 = "";

ls_132 = "";

bool li_140 = TRUE;

for (li_32 = 0; li_32 < StringLen(ls_ret_96); li_32++) {

ls_36 = StringSubstr(ls_ret_96, li_32, 1);

if (ls_36 >= "0" && ls_36 <= "9") li_140 = FALSE;

if ((ls_36 == " " && li_140) || (li_76 && ad_0 == 0.0)) ls_124 = ls_124 + " ";

else ls_132 = ls_132 + ls_36;

}

ls_ret_96 = ls_124 + ls_132;

if (li_84 && l_count_104 > li_24) ls_ret_96 = "*" + StringSubstr(ls_ret_96, 1, StringLen(ls_ret_96) - 1);

if (li_88) {

l_str_len_144 = StringLen(ls_ret_96);

ls_ret_96 = StringLeftTrim(ls_ret_96);

ls_ret_96 = ls_ret_96 + StringRepeat(" ", l_str_len_144 - StringLen(ls_ret_96));

}

if (li_92) {

ls_124 = "";

for (li_32 = 0; li_32 < StringLen(ls_ret_96); li_32++) {

ls_36 = StringSubstr(ls_ret_96, li_32, 1);

if (ls_36 == ".") ls_124 = ls_124 + ",";

else {

if (ls_36 == ",") ls_124 = ls_124 + ".";

else ls_124 = ls_124 + ls_36;

}

}

ls_ret_96 = ls_124;

}

return (ls_ret_96);

}

 

string StringLeftTrim(string as_0) {

bool li_8 = TRUE;

string ls_ret_12 = "";

for (int li_20 = 0; li_20 < StringLen(as_0); li_20++) {

if (StringSubstr(as_0, li_20, 1) != " " || !li_8) {

ls_ret_12 = ls_ret_12 + StringSubstr(as_0, li_20, 1);

li_8 = FALSE;

}

}

return (ls_ret_12);

}

 

string StringRepeat(string as_0, int ai_8) {

string ls_ret_12 = "";

for (int l_count_20 = 0; l_count_20 < ai_8; l_count_20++) ls_ret_12 = ls_ret_12 + as_0;

return (ls_ret_12);

}

Edited by 4xmeter
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...