Quantcast
Channel: Forex Forum - World Wide Invest
Viewing all articles
Browse latest Browse all 14445

How to modify spreadlimit

$
0
0
Hi guys. I need help. Anyone can help me to tell me from where to modify spreadlimit? The spreadlimit is 4 and i want to modify to 5.

here is the code:

.........................
int AproBuyS0(double a0, double a1, int a2, double a3, string a4);
int AproSellS0(double a0, double a1, int a2, double a3, string a4);
int AproSellS1(double a0, double a1, double a2, double a3, int a4, double a5, double a6, int a7, string a8);
int AproBuyS2(double a0, double a1, double a2, double a3, double a4, string a5);
int AproSellS2(double a0, double a1, double a2, double a3, double a4, string a5);
#import

int gi_76 = D'01.01.2013 23:00';
int gi_80 = D'17.01.2013 23:00';
extern string GMT_OFFSET = "----- Difference between Broker Time and GMT Time -----";
extern bool AutoGMT_Offset = TRUE;
extern int GMT_Offset = 2;
extern string AGGRESSIVE = "----- Aggressive Trades -----";
extern bool Aggressive = FALSE;
extern string NFA_RULES = "----- NFA Rules -----";
extern bool NFA = FALSE;
extern string RISK = "----- Percentage Risk Trade -----";
extern double Risk = 10.0;
extern string FIXEDLOTS = "----- If FixedLots = 0 use Percentage RiskTrade -----";
extern double FixedLots = 0.0;
extern string USEDMARGIN = "----- Max Percentage of the FREE Margin Used -----";
extern double MaxUsedMargin = 100.0;
extern string MAGICNUMBER = "----- Strategy MagicNumber -----";
string g_comment_180 = "olykit EURCHF1 2013";
extern int MagicNumberS0 = 1;
string g_comment_192 = "olykit EURCHF2 2013";
extern int MagicNumberS1 = 2;
string g_comment_204 = "olykit EURCHF3 2013";
extern int MagicNumberS2 = 3;
extern string SLIPPAGE = "----- Slippage -----";
extern int Slippage = 2;
extern string COMMENTS = "----- Comment -----";
extern bool Visible_Comments = TRUE;
bool gi_240 = FALSE;
bool gi_244 = FALSE;
int gi_248;
bool gi_252;
double g_lots_256;
double gd_264;
int gi_272;
int gi_276;
double gd_280;
int gi_288;
int g_timeframe_292;
int gi_296;
double gd_300;
int g_period_308;
int g_period_312;
int g_period_316;
int gi_320;
int gi_324;
int gi_328;
int gi_332;
int gi_336;
int gi_340;
int gi_unused_344 = 1;
int gi_348;
int gi_352;
int gi_356;
int gi_360;
int gi_364;
string gs_unused_368 = "GIORNI X TRADARE";
bool gi_376;
bool gi_380;
bool gi_384;
bool gi_388;
bool gi_392;
bool gi_396;
int g_ticket_400;
double gd_404;
double gd_412;
double g_ord_profit_420;
double gd_428;
int gi_unused_436;
int g_datetime_440;
double g_irsi_444;
double g_irsi_452;
double g_icci_460;
double g_irsi_468;
double g_irsi_476;
double g_icci_484;
double g_icci_492;
double g_ima_500;
int gi_508;
string gs_512;

int init() {
if (!Visible_Comments) {
g_comment_180 = "";
g_comment_192 = "";
g_comment_204 = "";
}
gs_512 = StringSubstr(Symbol(), 0, 6);
gi_252 = TRUE;
SetSpreadLimit();
if (AutoGMT_Offset && (!IsTesting())) {
GMT_Offset = TimeZoneServer();
if (gs_512 != "USDJPY" && TimeCurrent() >= gi_76 && TimeCurrent() <= gi_80) GMT_Offset--;
}
return (0);
}

double TimeZoneServer() {
int li_0 = (TimeCurrent() - TimeLocal()) / 60;
int li_4 = MathRound(li_0 / 30.0);
li_0 = 30 * li_4;
double ld_ret_8 = TimeZoneLocal() + li_0 / 60.0;
return (ld_ret_8);
}

double TimeZoneLocal() {
int lia_0[43];
switch (GetTimeZoneInformation(lia_0)) {
case 0:
return (lia_0[0] / (-60.0));
case 1:
return (lia_0[0] / (-60.0));
case 2:
return ((lia_0[0] + lia_0[42]) / (-60.0));
}
return (0);
}

int deinit() {
Delete();
return (0);
}

int start() {
if (Minute() >= 10 && Minute() <= 50 && (!IsTesting())) {
if (AutoGMT_Offset) {
GMT_Offset = TimeZoneServer();
if (gs_512 != "USDJPY" && TimeCurrent() >= gi_76 && TimeCurrent() <= gi_80) GMT_Offset--;
}
}
if (gs_512 != "EURCHF") {
Comment("THIS PAIR IS NOT SUPPORTED. olykit WORKS ON EURCHF AND M15 TIMEFRAME!");
return (0);
}
if (Period() != PERIOD_M15) {
Comment("olykit WORKS ON M15 TIMFRAME! olykit WILL NOT TRADE UNTIL YOU SELECT M15 TIMEFRAME.");
return (0);
}
if (iBars(NULL, PERIOD_H1) != gi_248 || gi_244 == TRUE) {
gi_248 = iBars(NULL, PERIOD_H1);

gi_252 = TRUE;
}
gi_244 = FALSE;
if (FixedLots != 0.0) g_lots_256 = FixedLots;
else g_lots_256 = Lots();
if (NFA == TRUE) {
S0();
return (0);
}
S0();
if (Aggressive == TRUE) {
S1();
S2();
}
return (0);
}

void Delete() {
ObjectDelete("olykit lb: 1");
ObjectDelete("olykit lb: 2");
ObjectDelete("olykit lb: 3");
ObjectDelete("olykit lb: 4");
ObjectDelete("olykit lb: 5");
ObjectDelete("olykit lb: 6");
ObjectDelete("olykit lb: 7");
ObjectDelete("olykit lb: 8");
ObjectDelete("olykit lb: 9");
ObjectDelete("olykit lb: 10");
ObjectDelete("olykit lb: 11");
ObjectDelete("olykit lb: 12");
ObjectDelete("olykit lb: 13");
}

void DisplayError() {
Delete();
ScriviErr("You are trying to run olykit on an unauthorized ", Red, 4, 4, 1);
ScriviErr("Live account, or are authorized for the wrong Live account. ", Red, 5, 5, 1);
ScriviErr("Your actual account number is " + AccountNumber(), Red, 6, 6, 1);
ScriviErr("Email this number to [Dear Guest/Member you can't see link before click here to register]", Red, 7, 7, 1);
ScriviErr("For Authorization", Red, 8, 8, 1);
}

void DisplayInfo() {
string l_str_concat_0;
Delete();
Scrivi("olykit Scalper for EURCHF", White, 1, 1);
if (AutoGMT_Offset) l_str_concat_0 = "AUTO GMT TRUE";
if (!AutoGMT_Offset) l_str_concat_0 = "AUTO GMT FALSE";
Scrivi(l_str_concat_0, White, 3, 3, 1);
if (GMT_Offset >= 0) l_str_concat_0 = StringConcatenate("GMT +", DoubleToStr(GMT_Offset, 0));
else l_str_concat_0 = StringConcatenate("GMT ", DoubleToStr(GMT_Offset, 0));
Scrivi(l_str_concat_0, White, 4, 4, 1);
if (Aggressive == FALSE) l_str_concat_0 = "AGGRESSIVE FALSE";
if (Aggressive == TRUE) l_str_concat_0 = "AGGRESSIVE TRUE";
Scrivi(l_str_concat_0, White, 5, 5, 1);
Scrivi("-----NORMAL MODE-----", White, 8, 8, 1);
Scrivi("---AGGRESSIVE MODE---", White, 11, 11, 1);
double ld_8 = MathAbs(Ask - Bid) / Point;
double ld_16 = gd_264;
if (Point == 0.00001 || Point == 0.001) {
ld_8 /= 10.0;
ld_16 /= 10.0;
}
l_str_concat_0 = StringConcatenate("SPREAD: ", DoubleToStr(ld_8, 1));
if (ld_8 <= ld_16) Scrivi(l_str_concat_0, White, 6, 6, 1);
else Scrivi(l_str_concat_0, Red, 6, 6, 1);
l_str_concat_0 = StringConcatenate("SPREAD LIMIT: ", DoubleToStr(ld_16, 1));
Scrivi(l_str_concat_0, White, 7, 7, 1);
StandbyNormal();
StandbyAgg();
}

void StandbyNormal() {
string ls_unused_0;
int l_count_8 = 0;
int l_ord_total_12 = OrdersTotal();
for (int l_pos_16 = 0; l_pos_16 < l_ord_total_12; l_pos_16++) {
OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES);
if (OrderComment() == g_comment_180 && OrderSymbol() == Symbol()) l_count_8++;
}
if (l_count_8 == 0) {
Scrivi("STANDBY", Red, 9, 9, 1);
return;
}
Scrivi("OPERATION OPEN", Green, 9, 9, 1);
}

void StandbyAgg() {
int l_count_0 = 0;
int l_ord_total_4 = OrdersTotal();
for (int l_pos_8 = 0; l_pos_8 < l_ord_total_4; l_pos_8++) {
OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
if (OrderComment() == g_comment_192 || OrderComment() == g_comment_204 && OrderSymbol() == Symbol()) l_count_0++;
}
if (l_count_0 == 0) {
if (Aggressive == FALSE) {
Scrivi("NOT ALLOWED", White, 12, 12, 1);
return;
}
Scrivi("STANDBY", Red, 12, 12, 1);
return;
}
Scrivi("OPERATION OPEN", Green, 12, 12, 1);
}

void S0() {
if (gi_240) AzzeraLog();
SetParamS0();
if (gi_240) ScriviLog("settati i parametri");
gd_412 = High[iHighest(NULL, 0, MODE_HIGH, gi_288, 1)];
gd_404 = Low[iLowest(NULL, 0, MODE_LOW, gi_288, 1)];
GestioneOrdiniS0();
if (!IsTesting()) {
if (gi_252 == TRUE || gi_252 == 3) DisplayInfo();
else {
DisplayError();
return;
}
}
if (isTimetoTrade(gi_360, gi_364) && TradaGiorno()) {
if ((!SpreadLimit()) && LimitMargin()) {
if (gi_240) ScriviLog("vedo da dll se posso aprire buy");
if (!isOrderBuy(MagicNumberS0) && AproBuyS0(gd_404, gd_412, gi_288, Bid, DoubleToStr(AccountNumber(), 0)) == 1) {
if (gi_240) ScriviLog("provo ad aprire buy");
ApriS0(1);
} else {
if (gi_240) ScriviLog("vedo da dll se posso aprire sell");
if (!isOrderSell(MagicNumberS0) && AproSellS0(gd_404, gd_412, gi_288, Bid, DoubleToStr(AccountNumber(), 0)) == 1) {
if (gi_240) ScriviLog("provo ad aprire sell");
ApriS0(2);
}
}
}
}
}

void S1() {
gi_508 = TimeCurrent() - 3600 * GMT_Offset;
SetParamS1();
GestioneOrdiniS1();
if (isTimetoTrade(gi_360, gi_364) && TradaGiorno()) {
if ((!SpreadLimit()) && LimitMargin()) {
if (!isOrderBuy(MagicNumberS1) && AproBuyS1(Ask, g_icci_460, g_ima_500, gi_296 * Point, gi_332, g_irsi_452, g_irsi_444, gi_324, DoubleToStr(AccountNumber(), 0)) == 1) ApriS1(1);
else
if (!isOrderSell(MagicNumberS1) && AproSellS1(Bid, g_icci_460, g_ima_500, gi_296 * Point, gi_328, g_irsi_452, g_irsi_444, gi_320, DoubleToStr(AccountNumber(), 0)) == 1) ApriS1(2);
}
}
}

void S2() {
gi_508 = TimeCurrent() - 3600 * GMT_Offset;
if (SetParamS2() != 0) {
GestioneOrdiniS2();
if (isTimetoTrade(gi_360, gi_364) && TradaGiorno() && TradeMonth()) {
if ((!SpreadLimit()) && LimitMargin()) {
if (!isOrderBuy(MagicNumberS2) && AproBuyS2(gd_404, gd_412, g_icci_460, Ask, Bid, DoubleToStr(AccountNumber(), 0)) == 1) ApriS2(1);
else
if (!isOrderSell(MagicNumberS2) && AproSellS2(gd_404, gd_412, g_icci_460, Ask, Bid, DoubleToStr(AccountNumber(), 0)) == 1) ApriS2(2);
}
}
}
}

void GestioneOrdiniS0() {
if (isOrderBuy(MagicNumberS0))
if (AproSellS0(gd_404, gd_412, gi_288, Bid, DoubleToStr(AccountNumber(), 0)) || isMinProfittoClose()) CloseBuyOrder(MagicNumberS0);
if (isOrderSell(MagicNumberS0))
if (AproBuyS0(gd_404, gd_412, gi_288, Bid, DoubleToStr(AccountNumber(), 0)) || isMinProfittoClose()) CloseSellOrder(MagicNumberS0);
}

void GestioneOrdiniS1() {
if (isOrderBuy(MagicNumberS1)) {
if (MinTradeHours())
if (MaxTradeHours() || IndiBad()) CloseBuyOrder(MagicNumberS1);
}
if (isOrderSell(MagicNumberS1)) {
if (MinTradeHours())
if (MaxTradeHours() || IndiBad()) CloseSellOrder(MagicNumberS1);
}
}

void GestioneOrdiniS2() {
if (isOrderBuy(MagicNumberS2)) {
if (MinTradeHours()) {
if (g_icci_460 > 100.0 && g_ord_profit_420 > 0.0) {
CloseBuyOrder(MagicNumberS2);
return;
}
}
if (MinTradeHours2() && g_ord_profit_420 > 0.0) {
CloseBuyOrder(MagicNumberS2);
return;
}
if (MinTradeHours3() || Bid >= gd_412) {
CloseBuyOrder(MagicNumberS2);
return;
}
}
if (isOrderSell(MagicNumberS2)) {
if (MinTradeHours()) {
if (g_icci_460 < -100.0 && g_ord_profit_420 > 0.0) {
CloseSellOrder(MagicNumberS2);
return;
}
}
if (MinTradeHours2() && g_ord_profit_420 > 0.0) {
CloseSellOrder(MagicNumberS2);
return;
}
if (MinTradeHours3() || Ask <= gd_404) {
CloseSellOrder(MagicNumberS2);
return;
}
}
}

void ApriS1(int ai_0) {
double ld_4;
bool l_bool_12;
double l_pips_16 = 0;
double l_price_24 = 0;
if (ai_0 == 1) {
if (gd_404 > 0.0) {
l_pips_16 = gd_280;
ld_4 = (Bid - gd_404) / Point;
if (Digits == 5 || Digits == 3) ld_4 /= 10.0;
if (ld_4 > gd_280) l_pips_16 = gd_280;
if (ld_4 < gd_300) l_pips_16 = gd_300;
} else l_pips_16 = gd_300;
l_pips_16 = NormalizeDouble(Bid - l_pips_16 * Point, Digits);
l_price_24 = NormalizeDouble(Ask + gi_272 * Point, Digits);
g_ticket_400 = OrderSend(Symbol(), OP_BUY, g_lots_256, NormalizeDouble(Ask, Digits), Slippage, 0, 0, g_comment_192, MagicNumberS1, 0, Blue);
}
if (ai_0 == 2) {
if (gd_412 > 0.0) {
l_pips_16 = gd_280;
ld_4 = (gd_412 - Ask) / Point;
if (Digits == 5 || Digits == 3) ld_4 /= 10.0;
if (ld_4 > gd_280) l_pips_16 = gd_280;
if (ld_4 < gd_300) l_pips_16 = gd_300;
} else l_pips_16 = gd_300;
l_pips_16 = NormalizeDouble(Ask + l_pips_16 * Point, Digits);
l_price_24 = NormalizeDouble(Bid - gi_272 * Point, Digits);
g_ticket_400 = OrderSend(Symbol(), OP_SELL, g_lots_256, NormalizeDouble(Bid, Digits), Slippage, 0, 0, g_comment_192, MagicNumberS1, 0, Red);
}
if (g_ticket_400 != 0) {
l_bool_12 = FALSE;
while (l_bool_12 == FALSE) {
l_bool_12 = OrderSelect(g_ticket_400, SELECT_BY_TICKET, MODE_TRADES);
Sleep(100);
}
l_bool_12 = FALSE;
while (l_bool_12 == FALSE) {
Sleep(5000);
l_bool_12 = OrderModify(g_ticket_400, OrderOpenPrice(), 0, l_price_24, 0, White);
}
l_bool_12 = FALSE;
while (l_bool_12 == FALSE) {
Sleep(5000);
l_bool_12 = OrderSelect(g_ticket_400, SELECT_BY_TICKET, MODE_TRADES);
l_bool_12 = OrderModify(g_ticket_400, OrderOpenPrice(), l_pips_16, l_price_24, 0, White);
}
}
}

int IndiBad() {
if (isOrderBuy(MagicNumberS1) && MinTradeHours())
if (g_icci_460 > 0.0 && g_irsi_444 > 50.0 && g_ord_profit_420 > 0.0) return (1);
if (isOrderSell(MagicNumberS1) && MinTradeHours())
if (g_icci_460 < 0.0 && g_irsi_444 < 50.0 && g_ord_profit_420 > 0.0) return (1);
return (0);
}

void ApriS2(int ai_0) {
bool l_bool_4;
double l_price_8 = 0;
double l_price_16 = 0;
if (gi_348 > 0) {
l_price_8 = gi_348 * (gd_412 - gd_404) / Point;
if (l_price_8 > gd_280) l_price_8 = gd_280;
if (l_price_8 < gd_300) l_price_8 = gd_300;
} else l_price_8 = gd_300;
if (ai_0 == 1) {
l_price_8 = NormalizeDouble(Bid - l_price_8 * Point, Digits);
l_price_16 = NormalizeDouble(Ask + gi_272 * Point, Digits);
g_ticket_400 = OrderSend(Symbol(), OP_BUY, g_lots_256, NormalizeDouble(Ask, Digits), Slippage, 0, 0, g_comment_204, MagicNumberS2, 0, Blue);
}
if (ai_0 == 2) {
l_price_8 = NormalizeDouble(Ask + l_price_8 * Point, Digits);
l_price_16 = NormalizeDouble(Bid - gi_272 * Point, Digits);
g_ticket_400 = OrderSend(Symbol(), OP_SELL, g_lots_256, NormalizeDouble(Bid, Digits), Slippage, 0, 0, g_comment_204, MagicNumberS2, 0, Red);
}
if (g_ticket_400 != 0) {
l_bool_4 = FALSE;
while (l_bool_4 == FALSE) {
l_bool_4 = OrderSelect(g_ticket_400, SELECT_BY_TICKET, MODE_TRADES);
Sleep(100);
}
l_bool_4 = FALSE;
while (l_bool_4 == FALSE) {
Sleep(5000);
l_bool_4 = OrderModify(g_ticket_400, OrderOpenPrice(), 0, l_price_16, 0, White);
}
l_bool_4 = FALSE;
while (l_bool_4 == FALSE) {
Sleep(5000);
l_bool_4 = OrderSelect(g_ticket_400, SELECT_BY_TICKET, MODE_TRADES);
l_bool_4 = OrderModify(g_ticket_400, OrderOpenPrice(), l_price_8, l_price_16, 0, White);
}
}
}

int MaxTradeHours() {
if (TimeCurrent() - g_datetime_440 > 3600 * gi_340) return (1);
return (0);
}

bool MinTradeHours() {
if (TimeCurrent() - g_datetime_440 > 3600 * gi_336) return (TRUE);
return (FALSE);
}

int MinTradeHours2() {
if (TimeCurrent() - g_datetime_440 > 3600 * gi_352) return (1);
return (0);
}

int MinTradeHours3() {
if (TimeCurrent() - g_datetime_440 > 3600 * gi_356) return (1);
return (0);
}

int TradeMonth() {
if (TimeDay(gi_508) > 28) return (0);
return (1);
}

bool isOrderBuy(int a_magic_0) {
string l_time2str_4;
if (gi_240) ScriviLog("vedo se non ho ordini buy aperti");
bool li_ret_12 = FALSE;
int l_pos_16 = 0;
int l_ord_total_20 = OrdersTotal();
for (l_pos_16 = 0; l_pos_16 < l_ord_total_20; l_pos_16++) {
OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == a_magic_0) {
li_ret_12 = TRUE;
g_ord_profit_420 = OrderProfit();
gd_428 = (Bid - OrderOpenPrice()) / Point;
l_time2str_4 = TimeToStr(OrderOpenTime());
l_time2str_4 = StringSubstr(l_time2str_4, 11, 2);
gi_unused_436 = StrToDouble(l_time2str_4);
g_datetime_440 = OrderOpenTime();
break;
}
}
return (li_ret_12);
}

bool isOrderSell(int a_magic_0) {
string l_time2str_4;
bool li_ret_12 = FALSE;
int l_pos_16 = 0;
int l_ord_total_20 = OrdersTotal();
for (l_pos_16 = 0; l_pos_16 < l_ord_total_20; l_pos_16++) {
OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderType() == OP_SELL && OrderMagicNumber() == a_magic_0) {
li_ret_12 = TRUE;
g_ord_profit_420 = OrderProfit();
gd_428 = (OrderOpenPrice() - Ask) / Point;
l_time2str_4 = TimeToStr(OrderOpenTime());
l_time2str_4 = StringSubstr(l_time2str_4, 11, 2);
gi_unused_436 = StrToDouble(l_time2str_4);
g_datetime_440 = OrderOpenTime();
break;
}
}
return (li_ret_12);
}

int isTimetoTrade(int ai_0, int ai_4) {
if (gi_240) ScriviLog("verifico se ora ok");
bool li_ret_8 = FALSE;
int l_hour_12 = Hour();
if (ai_0 > 23 || ai_0 < 0) ai_0 = 0;
if (ai_4 > 23 || ai_4 < 0) ai_4 = 0;
if (ai_0 < ai_4 && (Hour() >= ai_0 && Hour() < ai_4)) li_ret_8 = TRUE;
if (ai_0 > ai_4 && Hour() >= ai_0 || Hour() < ai_4) li_ret_8 = TRUE;
return (li_ret_8);
}

int TradaGiorno() {
if (gi_240) ScriviLog("vedo se il giorno ok");
int li_0 = Hour() + GMT_Offset;
if (gi_380 == TRUE && DayOfWeek() == 0 || (DayOfWeek() == 1 && li_0 >= 0 && li_0 <= 3)) return (0);
if (gi_384 == TRUE && (DayOfWeek() == 1 && li_0 >= 19) || (DayOfWeek() == 2 && li_0 <= 3)) return (0);
if (gi_388 == TRUE && (DayOfWeek() == 2 && li_0 >= 19) || (DayOfWeek() == 3 && li_0 <= 3)) return (0);
if (gi_392 == TRUE && (DayOfWeek() == 3 && li_0 >= 19) || (DayOfWeek() == 4 && li_0 <= 3)) return (0);
if (gi_396 == TRUE && (DayOfWeek() == 4 && li_0 >= 19) || (DayOfWeek() == 5 && li_0 <= 3)) return (0);
if (gi_376 == TRUE && (DayOfWeek() == 5 && li_0 >= 19) || DayOfWeek() == 6) return (0);
return (1);
}

int ApriS0(int ai_0) {
bool l_bool_4;
double l_price_8;
double l_price_16;
double l_price_24 = gd_280;
double l_price_32 = gi_272;
int l_ticket_40 = 0;
if (ai_0 == 1) {
if (l_price_24 != 0.0) {
if (l_price_24 < MarketInfo(Symbol(), MODE_STOPLEVEL)) l_price_24 = MarketInfo(Symbol(), MODE_STOPLEVEL);
l_price_24 = NormalizeDouble(Bid - l_price_24 * Point, MarketInfo(Symbol(), MODE_DIGITS));
}
if (l_price_32 != 0.0) {
if (l_price_32 < MarketInfo(Symbol(), MODE_STOPLEVEL)) l_price_32 = MarketInfo(Symbol(), MODE_STOPLEVEL);
l_price_32 = NormalizeDouble(Ask + l_price_32 * Point, MarketInfo(Symbol(), MODE_DIGITS));
}
RefreshRates();
l_ticket_40 = OrderSend(Symbol(), OP_BUY, NormalizeDouble(g_lots_256, 2), Ask, Slippage, 0, 0, g_comment_180, MagicNumberS0, 0, Blue);
if (l_ticket_40 > 0) {
if (OrderSelect(l_ticket_40, SELECT_BY_TICKET, MODE_TRADES)) {
l_bool_4 = OrderModify(l_ticket_40, OrderOpenPrice(), l_price_24, l_price_32, 0, CLR_NONE);
if (!l_bool_4) Print("Error modifying BUY order : ", ErrorDescription(GetLastError()));
}
}
return (1);
}
if (ai_0 == 2) {
l_price_8 = gd_280;
l_price_16 = gi_272;
if (l_price_8 != 0.0) {
if (l_price_8 < MarketInfo(Symbol(), MODE_STOPLEVEL)) l_price_8 = MarketInfo(Symbol(), MODE_STOPLEVEL);
l_price_8 = NormalizeDouble(Ask + l_price_8 * Point, MarketInfo(Symbol(), MODE_DIGITS));
}
if (l_price_16 != 0.0) {
if (l_price_16 < MarketInfo(Symbol(), MODE_STOPLEVEL)) l_price_16 = MarketInfo(Symbol(), MODE_STOPLEVEL);
l_price_16 = NormalizeDouble(Bid - l_price_16 * Point, MarketInfo(Symbol(), MODE_DIGITS));
}
l_ticket_40 = OrderSend(Symbol(), OP_SELL, NormalizeDouble(g_lots_256, 2), Bid, Slippage, 0, 0, g_comment_180, MagicNumberS0, 0, Red);
if (l_ticket_40 > 0) {
if (OrderSelect(l_ticket_40, SELECT_BY_TICKET, MODE_TRADES)) {
l_bool_4 = OrderModify(l_ticket_40, OrderOpenPrice(), l_price_8, l_price_16, 0, CLR_NONE);
if (!l_bool_4) Print("Error modifying Sell order : ", ErrorDescription(GetLastError()));
}
}
return (1);
}
return (0);
}

int isMinProfittoClose() {
bool li_ret_0 = FALSE;
if (gd_428 > 0.0 && gd_428 >= gi_276 && gi_276 != 0) li_ret_0 = TRUE;
return (li_ret_0);
}

int CloseBuyOrder(int a_magic_0) {
bool l_bool_4;
bool li_8 = FALSE;
int l_pos_12 = 0;
int l_ord_total_16 = OrdersTotal();
while (li_8 == FALSE) {
for (l_pos_12 = 0; l_pos_12 < l_ord_total_16; l_pos_12++) {
l_bool_4 = OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == a_magic_0) {
Print("...Try to close order ", DoubleToStr(OrderTicket(), 0), " at ", DoubleToStr(NormalizeDouble(Bid, Digits), Digits));
if (OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid, Digits), Slippage, Blue)) Print("...Succesfully closed!");
else Print("...Error Closing order ", DoubleToStr(OrderTicket(), 0), " - Try the next Tick");
return (0);
}
}
}
return (0);
}

int CloseSellOrder(int a_magic_0) {
bool l_bool_4;
bool li_8 = FALSE;
int l_pos_12 = 0;
int l_ord_total_16 = OrdersTotal();
while (li_8 == FALSE) {
for (l_pos_12 = 0; l_pos_12 < l_ord_total_16; l_pos_12++) {
l_bool_4 = OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderType() == OP_SELL && OrderMagicNumber() == a_magic_0) {
Print("...Try to close order ", DoubleToStr(OrderTicket(), 0), " at ", DoubleToStr(NormalizeDouble(Ask, Digits), Digits));
if (OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask, Digits), Slippage, Red)) Print("...Succesfully closed!");
else Print("...Error Closing order ", DoubleToStr(OrderTicket(), 0), " - Try the next Tick");
return (0);
}
}
}
return (0);
}

double Lots() {
int li_0;
double ld_4 = NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSTEP), 2);
double ld_12 = NormalizeDouble(MarketInfo(Symbol(), MODE_MINLOT), 2);
double ld_20 = NormalizeDouble(MarketInfo(Symbol(), MODE_MAXLOT), 2);
if (ld_4 == 0.01) li_0 = 2;
else li_0 = 1;
double ld_ret_28 = NormalizeDouble(AccountFreeMargin() * Risk / 100000.0, li_0);
if (ld_ret_28 > ld_20) ld_ret_28 = ld_20;
if (ld_ret_28 < ld_12) ld_ret_28 = ld_12;
return (ld_ret_28);
}

bool SpreadLimit() {
if (gi_240) ScriviLog("verifico spreadlimit");
double ld_0 = MathAbs(Ask - Bid) / Point;
if (Point == 0.00001 || Point == 0.001) {
}
if (ld_0 > gd_264) {
Print("Spread Over the Limit! - Actual Spread:", DoubleToStr(ld_0, Digits), " - Spread Limit:", DoubleToStr(gd_264, Digits));
return (TRUE);
}
return (FALSE);
}

string GetObjName(int ai_0) {
return (StringConcatenate("olykit", " lb: ", ai_0));
}

void Scrivi(string a_text_0, color a_color_8 = -1, int ai_12 = -1, double ad_16 = -1.0, int ai_24 = 0) {
bool li_28 = FALSE;
int li_32 = 12;
bool li_36 = FALSE;
if (a_color_8 == CLR_NONE) a_color_8 = White;
if (ai_12 == -1) ai_12 = 0;
if (ad_16 == -1.0) ad_16 = li_28;
string l_name_40 = GetObjName(ai_12);
if (ObjectFind(l_name_40) != 0) {
ObjectCreate(l_name_40, OBJ_LABEL, 0, 0, 0);
ObjectSet(l_name_40, OBJPROP_CORNER, 0);
}
ObjectSetText(l_name_40, a_text_0, 8, "Tahoma", a_color_8);
ObjectSet(l_name_40, OBJPROP_XDISTANCE, li_32 + ai_24);
ObjectSet(l_name_40, OBJPROP_YDISTANCE, li_36 + 14.0 * ad_16);
}

void ScriviErr(string a_text_0, color a_color_8 = -1, int ai_12 = -1, double ad_16 = -1.0, int ai_24 = 0) {
bool li_28 = FALSE;
int li_32 = 12;
bool li_36 = FALSE;
if (a_color_8 == CLR_NONE) a_color_8 = White;
if (ai_12 == -1) ai_12 = 0;
if (ad_16 == -1.0) ad_16 = li_28;
string l_name_40 = GetObjName(ai_12);
if (ObjectFind(l_name_40) != 0) {
ObjectCreate(l_name_40, OBJ_LABEL, 0, 0, 0);
ObjectSet(l_name_40, OBJPROP_CORNER, 0);
}
ObjectSetText(l_name_40, a_text_0, 12, "Tahoma", a_color_8);
ObjectSet(l_name_40, OBJPROP_XDISTANCE, li_32 + ai_24);
ObjectSet(l_name_40, OBJPROP_YDISTANCE, li_36 + 14.0 * ad_16);
}

void SetParamS0() {
if (gs_512 == "EURCHF") {
gd_264 = 4;
gi_376 = TRUE;
gi_380 = TRUE;
gi_384 = FALSE;
gi_388 = FALSE;
gi_392 = FALSE;
gi_396 = FALSE;
gi_272 = 30;
gd_280 = 54;
gi_276 = 3;
gi_288 = 7;
gi_360 = 22;
gi_364 = 23;
}
gi_360 += GMT_Offset;
gi_364 += GMT_Offset;
if (gi_360 > 23) gi_360 -= 24;
if (gi_364 > 23) gi_364 -= 24;
if (Point == 0.00001 || Point == 0.001) {
gi_272 = 10 * gi_272;
gd_280 = 10.0 * gd_280;
gd_264 = 10.0 * gd_264;
gi_276 = 10 * gi_276;
}
}

void SetParamS1() {
if (gs_512 == "EURCHF") {
g_timeframe_292 = 15;
gi_272 = 50;
gi_296 = 7;
gd_280 = 76;
gd_300 = 63;
g_period_308 = 9;
g_period_312 = 18;
g_period_316 = 11;
gi_320 = 92;
gi_324 = 30;
gi_328 = 64;
gi_332 = 8;
gi_336 = 0;
gi_340 = 12;
gd_264 = 4;
gi_360 = 21;
gi_364 = 24;
gi_376 = TRUE;
gi_380 = TRUE;
gi_384 = FALSE;
gi_388 = TRUE;
gi_392 = FALSE;
gi_396 = FALSE;
}
gi_360 += GMT_Offset;
gi_364 += GMT_Offset;
if (gi_360 > 23) gi_360 -= 24;
if (gi_364 > 23) gi_364 -= 24;
if (Point == 0.00001 || Point == 0.001) {
gi_272 = 10 * gi_272;
gi_296 = 10 * gi_296;
gd_280 = 10.0 * gd_280;
gd_300 = 10.0 * gd_300;
gd_264 = 10.0 * gd_264;
}
g_irsi_444 = iRSI(NULL, g_timeframe_292, g_period_308, PRICE_CLOSE, 0);
g_irsi_468 = iRSI(NULL, g_timeframe_292, g_period_308, PRICE_CLOSE, 1);
g_irsi_476 = iRSI(NULL, g_timeframe_292, g_period_308, PRICE_CLOSE, 2);
g_irsi_452 = iRSI(NULL, PERIOD_M1, g_period_312, PRICE_CLOSE, 0);
g_icci_460 = iCCI(NULL, g_timeframe_292, g_period_316, PRICE_TYPICAL, 0);
g_icci_484 = iCCI(NULL, g_timeframe_292, g_period_316, PRICE_TYPICAL, 1);
g_icci_492 = iCCI(NULL, g_timeframe_292, g_period_316, PRICE_TYPICAL, 2);
g_ima_500 = iMA(NULL, g_timeframe_292, g_period_316, 0, MODE_SMA, PRICE_MEDIAN, 0);
int li_0 = TimeCurrent() - 3600.0 * TimeHour(gi_508) - 60 * TimeMinute(gi_508) - TimeSeconds(gi_508);
if (TimeCurrent() - li_0 < 43200.0) gi_288 = iBarShift(NULL, g_timeframe_292, li_0 - 86400);
else gi_288 = iBarShift(NULL, g_timeframe_292, li_0);
gd_412 = iHigh(NULL, g_timeframe_292, iHighest(NULL, g_timeframe_292, MODE_HIGH, gi_288, 0));
gd_404 = iLow(NULL, g_timeframe_292, iLowest(NULL, g_timeframe_292, MODE_LOW, gi_288, 0));
}

int SetParamS2() {
if (gs_512 == "EURCHF") {
g_timeframe_292 = 5;
gi_272 = 50;
gd_280 = 70;
gd_300 = 63;
gi_348 = 2;
gi_288 = 4;
g_period_316 = 56;
gi_336 = 0;
gi_352 = 2;
gi_356 = 6;
gd_264 = 4;
gi_360 = 22;
gi_364 = 24;
gi_376 = TRUE;
gi_380 = TRUE;
gi_384 = FALSE;
gi_388 = FALSE;
gi_392 = FALSE;
gi_396 = FALSE;
}
gi_360 += GMT_Offset;
gi_364 += GMT_Offset;
if (gi_360 > 23) gi_360 -= 24;
if (gi_364 > 23) gi_364 -= 24;
if (Point == 0.00001 || Point == 0.001) {
gi_272 = 10 * gi_272;
gd_280 = 10.0 * gd_280;
gd_300 = 10.0 * gd_300;
gd_264 = 10.0 * gd_264;
}
g_icci_460 = iCCI(NULL, g_timeframe_292, g_period_316, PRICE_TYPICAL, 0);
gd_412 = iHigh(NULL, g_timeframe_292, iHighest(NULL, g_timeframe_292, MODE_HIGH, gi_288, 1));
gd_404 = iLow(NULL, g_timeframe_292, iLowest(NULL, g_timeframe_292, MODE_LOW, gi_288, 1));
return (0);
}

void SetSpreadLimit() {
if (gs_512 == "EURCHF") gd_264 = 4;
if (Point == 0.00001 || Point == 0.001) gd_264 = 10.0 * gd_264;
}

int AproBuyS1(double ad_0, double ad_8, double ad_16, double ad_24, int ai_32, double ad_36, double ad_44, int ai_52, string as_unused_56) {
if (ad_8 < 0.0 && ad_16 - ad_0 >= ad_24 && (ai_32 > ad_36 && ad_36 < 50.0 || ai_52 > ad_44)) return (1);
return (0);
}

int LimitMargin() {
if (gi_240) ScriviLog("verifico limitmargin");
double ld_0 = 100.0 * AccountMargin() / AccountFreeMargin();
if (ld_0 > MaxUsedMargin) {
Print("Trades will not be opened: Used Margin ", DoubleToStr(ld_0, 2), "% - Limit Used Margin ", DoubleToStr(MaxUsedMargin, 0), "%");
return (0);
}
return (1);
}

void AzzeraLog() {
string l_str_concat_0 = StringConcatenate(Symbol(), "_Log.csv");
int l_file_8 = FileOpen(l_str_concat_0, FILE_CSV|FILE_WRITE, ';');
if (l_file_8 < 1) {
Print(l_str_concat_0, " - Impossibile scrivere il file Log");
return;
}
FileClose(l_file_8);
}

void ScriviLog(string as_0) {
string l_str_concat_8 = StringConcatenate(Symbol(), "_Log.csv");
int l_file_16 = FileOpen(l_str_concat_8, FILE_CSV|FILE_WRITE|FILE_READ, ';');
if (l_file_16 < 1) {
Print(l_str_concat_8, " - Impossibile scrivere il file Log");
return;
}
bool l_bool_20 = FileSeek(l_file_16, 0, SEEK_END);
FileWrite(l_file_16, TimeToStr(TimeCurrent()), as_0);
FileClose(l_file_16);
}

Viewing all articles
Browse latest Browse all 14445

Trending Articles