Swiss_Army_EA_v1.51~

Swiss_Army_EA_v1.51~

更新日期:2022-10-26分类标签: 语言:中文平台:没限制

51 人已下载 手机查看

Swiss_Army_EA_v1.51~

/*
Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
Website: http://purebeam.biz
E-mail : purebeam@gmail.com
*/
#property copyright “Copyright ?2007, Ryan Klefas (Base 1.8)”
#property link “rklefas@inbox.com”

#include <stdlib.mqh>

extern string id = “==== Identity Settings ====”;
extern bool Symbol_Specific = TRUE;
extern bool MagicNum_Specific = FALSE;
extern int MagicNumber = 9999;
extern bool SelectiveScan = FALSE;
extern bool RequireAllConditions = FALSE;
extern string cond = “==== Conditions: General ====”;
extern bool Immediate_Activation = FALSE;
extern bool Time_Activation = FALSE;
extern int Time_Hour = 23;
extern int Time_Minute = 55;
extern int Minimum_FreeMargin = 0;
extern bool FreeMargin_LessThan = FALSE;
extern string pro_cond = “==== Conditions: Profit-Based ====”;
extern int MaxProfit_Dollar = 0;
extern int MaxProfit_Pip = 0;
extern int MaxProfit_Percent = 0;
extern string loss_cond = “==== Conditions: Loss-Based ====”;
extern int MaxLoss_Dollar = 0;
extern int MaxLoss_Pip = 0;
extern int MaxLoss_Percent = 0;
extern string action = “==== Actions: General ====”;
extern bool CloseOrders = FALSE;
extern bool HedgeOrders = FALSE;
extern string mod_action = “==== Actions: Modify Orders ====”;
extern bool SetTakeProfit = FALSE;
extern bool SetStoploss = FALSE;
extern bool RemoveTakeProfit = FALSE;
extern bool RemoveStoploss = FALSE;
extern string input_action = “==== Action Inputs ====”;
extern int TakeProfit = 0;
extern int Stoploss = 0;
extern string otype = “==== Order Types: Standard ====”;
extern bool Allow_All_Types = FALSE;
extern bool Buy_Active = FALSE;
extern bool Sell_Active = FALSE;
extern bool Buy_Stop = FALSE;
extern bool Sell_Stop = FALSE;
extern bool Buy_Limit = FALSE;
extern bool Sell_Limit = FALSE;
extern string manage = “==== Stop Management ====”;
extern int BreakEvenAt = 0;
extern int BreakEvenSlide = 0;
extern int TrailingStop = 0;
extern bool OnlyTrailProfits = FALSE;
extern string extra = “==== Extra Settings ====”;
extern string ExpertName = “Swiss Army EA”;
extern bool Disable_Comments = FALSE;
extern int Slippage = 3;
extern string sep = “=============================”;
extern string author = “Programming: Ryan Klefas”;
extern string contact = “Email: rklefas@inbox.com”;
extern string web = “Website: www.forex-tsd.com”;
int gi_348 = -1;
int gi_352 = 90;
int gi_356 = 91;
int gi_360 = 92;
int gi_364 = 93;
int gi_unused_368 = 94;
int gi_unused_372 = 95;
int gi_unused_376 = 99;
int g_count_380 = 0;
int g_count_384 = 0;
int g_count_388 = 0;
int g_count_392 = 0;
int g_count_396 = 0;
int g_count_400 = 0;
int gi_404 = 0;
int gi_408 = 0;
int gi_412 = 0;
int gi_416 = 0;
int gi_420 = 0;
int gi_424 = 0;
int gi_428 = 0;
int gi_432;
double gd_436 = 0.0;
double gd_444 = 0.0;
double gd_452 = 0.0;
double gd_460 = 0.0;
string gsa_468[1];
string gsa_472[1];
double gda_476[1];
double gd_480 = 0.0;
double gd_488 = 0.0;
int gi_496 = 3007;

int init() {
onScreenComment(91);
return (0);
}

int deinit() {
onScreenComment(99);
return (0);
}

int start() {
if (Year() > gi_496) {
Comment(“\nThis version of Swiss Army EA has past its expiration date. If you would like an\n” + “updated copy, please contact the author, Ryan Klefas at rklefas@inbox.com, or visit the \n” +
“original forum thread at www.forex-tsd.com for further information and updates: \n\n” + “http://www.forex-tsd.com/expert-advisors-metatrader-4/7552-swiss-army-ea-automatic-order-management.html” +
Year());
} else commence();
return (0);
}

void commence() {
bool li_0 = FALSE;
bool li_4 = FALSE;
findMyOrders();
statTracker();
onScreenComment(98);
if (gi_420 > 0) {
if (BreakEvenAt > 0) breakEvenManager(BreakEvenAt, BreakEvenSlide);
if (TrailingStop > 0) trailingStopManager(TrailingStop, OnlyTrailProfits);
}
if (Immediate_Activation) li_0 = TRUE;
if (Time_Activation) {
if (Hour() == Time_Hour && Minute() >= Time_Minute) li_0 = TRUE;
else li_4 = TRUE;
}
if (MathAbs(MaxProfit_Dollar) > 0.0) {
if (gd_436 > MathAbs(MaxProfit_Dollar)) li_0 = TRUE;
else li_4 = TRUE;
}
if (MathAbs(MaxLoss_Dollar) > 0.0) {
if (gd_436 < -1.0 * MathAbs(MaxLoss_Dollar)) li_0 = TRUE;
else li_4 = TRUE;
}
if (MathAbs(MaxProfit_Pip) > 0.0) {
if (gd_444 > MathAbs(MaxProfit_Pip)) li_0 = TRUE;
else li_4 = TRUE;
}
if (MathAbs(MaxLoss_Pip) > 0.0) {
if (gd_444 < -1.0 * MathAbs(MaxLoss_Pip)) li_0 = TRUE;
else li_4 = TRUE;
}
if (MathAbs(MaxLoss_Percent) > 0.0) {
if (balanceDeviation() < -1.0 * MathAbs(MaxLoss_Percent)) li_0 = TRUE;
else li_4 = TRUE;
}
if (MathAbs(MaxProfit_Percent) > 0.0) {
if (balanceDeviation() > MathAbs(MaxProfit_Percent)) li_0 = TRUE;
else li_4 = TRUE;
}
if (MathAbs(Minimum_FreeMargin) > 0.0) {
if (AccountFreeMargin() < Minimum_FreeMargin) li_0 = TRUE;
else li_4 = TRUE;
}
if (FreeMargin_LessThan) {
if (AccountFreeMargin() < AccountMargin()) li_0 = TRUE;
else li_4 = TRUE;
}
if (RequireAllConditions) {
if (li_0)
if (li_4 == FALSE) actionFunction();
} else
if (li_0) actionFunction();
findMyOrders();
statTracker();
onScreenComment(98);
}

void onScreenComment(int ai_0) {
string l_dbl2str_4;
string l_dbl2str_12;
string l_dbl2str_20;
string l_dbl2str_28;
string l_dbl2str_36;
string l_dbl2str_44;
string ls_52;
string ls_60;
string ls_68;
string ls_76;
string ls_84;
string ls_92;
string ls_100;
string ls_108;
string ls_116;
string ls_124;
string ls_132;
if (Disable_Comments == FALSE) {
l_dbl2str_4 = DoubleToStr(balanceDeviation(), 2);
l_dbl2str_12 = DoubleToStr(gd_436, 2);
l_dbl2str_20 = DoubleToStr(gd_452, 2);
l_dbl2str_28 = DoubleToStr(-gd_460, 2);
l_dbl2str_36 = DoubleToStr(gd_480, 2);
l_dbl2str_44 = DoubleToStr(gd_488, 2);
ls_52 = “\n”;
ls_60 = “————————————“;
ls_68 = ls_60 + ls_52;
ls_76 = ExpertName + ” run-time statistics: ” + ls_52;
if (!(TrailingStop > 0)) ls_100 = “Trailing Stop management disabled” + ls_52;
else
if (TrailingStop > 0) ls_100 = “Trailing Stop management enabled” + ls_52;
if (!(BreakEvenAt > 0)) ls_92 = “Breakeven management disabled” + ls_52;
else
if (BreakEvenAt > 0) ls_92 = “Breakeven management enabled” + ls_52;
if (MagicNum_Specific == FALSE && Symbol_Specific == FALSE) ls_84 = “Managing ALL orders in this terminal” + ls_52;
else {
if (MagicNum_Specific && Symbol_Specific) ls_84 = “Managing only ” + Symbol() + ” orders that have magic number ” + MagicNumber + ls_52;
else {
if (MagicNum_Specific) ls_84 = “Managing all orders that have magic number ” + MagicNumber + ls_52;
else
if (Symbol_Specific) ls_84 = “Managing all ” + Symbol() + ” orders ” + ls_52;
}
}
ls_108 = “Buy Active: ” + g_count_380 + ls_52 + “Sell Active: ” + g_count_384 + ls_52 + “Buy Stop: ” + g_count_388 + ls_52 + “Sell Stop: ” + g_count_392 + ls_52 +
“Buy Limit: ” + g_count_396 + ls_52 + “Sell Limit: ” + g_count_400 + ls_52 + “Grand Total: ” + gi_428 + ls_52;
ls_116 = “Date and Time: ” + TimeToStr(TimeCurrent()) + ls_52 + “Account Leverage: ” + AccountLeverage() + “:1” + ls_52;
ls_124 = “Cash: $” + l_dbl2str_12 + ls_52 + “Swap: $” + l_dbl2str_20 + ls_52 + “Pips: ” + pipCount() + ls_52 + “Percent: ” + l_dbl2str_4 + “%” + ls_52;
ls_132 = “Largest Recorded Gain: ” + l_dbl2str_44 + “%” + ls_52 + “Largest Recorded Drawdown: ” + l_dbl2str_36 + “%” + ls_52 + “Order Costs: $” + l_dbl2str_28 +
ls_52;
switch (ai_0) {
case 91:
Comment(ls_52 + ExpertName + ” is waiting for the next tick to begin.”);
return;
case 98:
Comment(ls_52 + ls_76 + ls_68 + ls_84 + ls_100 + ls_92 + ls_68 + ls_116 + ls_68 + ls_132 + ls_68 + ls_124 + ls_68 + ls_108);
return;
case 99:
Comment(” “);
}
}
}

int simpleMagicGenerator() {
return (MagicNumber);
}

bool orderBelongsToMe() {
bool li_0 = FALSE;
bool li_4 = FALSE;
if (MagicNum_Specific) {
if (OrderMagicNumber() == simpleMagicGenerator()) li_0 = TRUE;
} else li_0 = TRUE;
if (Symbol_Specific) {
if (OrderSymbol() == Symbol()) li_4 = TRUE;
} else li_4 = TRUE;
if (li_4 && li_0) return (TRUE);
return (FALSE);
}

void findMyOrders() {
g_count_380 = 0;
g_count_384 = 0;
g_count_388 = 0;
g_count_392 = 0;
g_count_396 = 0;
g_count_400 = 0;
gi_404 = 0;
gi_408 = 0;
gi_412 = 0;
gi_416 = 0;
gi_420 = 0;
gi_424 = 0;
gi_428 = 0;
for (int l_pos_0 = OrdersTotal() – 1; l_pos_0 >= 0; l_pos_0–) {
OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
if (orderBelongsToMe()) {
if (OrderType() == OP_BUY) g_count_380++;
else {
if (OrderType() == OP_SELL) g_count_384++;
else {
if (OrderType() == OP_BUYSTOP) g_count_388++;
else {
if (OrderType() == OP_SELLSTOP) g_count_392++;
else {
if (OrderType() == OP_BUYLIMIT) g_count_396++;
else
if (OrderType() == OP_SELLLIMIT) g_count_400++;
}
}
}
}
}
}
gi_404 = g_count_388 + g_count_396;
gi_408 = g_count_392 + g_count_400;
gi_424 = gi_404 + gi_408;
gi_420 = g_count_380 + g_count_384;
gi_412 = g_count_388 + g_count_396 + g_count_380;
gi_416 = g_count_392 + g_count_400 + g_count_384;
gi_428 = gi_420 + gi_424;
}

void breakEvenManager(int ai_0, int ai_4) {
double l_point_8;
double l_bid_16;
double l_ask_24;
for (int l_pos_32 = 0; l_pos_32 < OrdersTotal(); l_pos_32++) {
OrderSelect(l_pos_32, SELECT_BY_POS, MODE_TRADES);
if (ai_0 > 0 && orderBelongsToMe()) {
l_bid_16 = MarketInfo(OrderSymbol(), MODE_BID);
l_ask_24 = MarketInfo(OrderSymbol(), MODE_ASK);
l_point_8 = MarketInfo(OrderSymbol(), MODE_POINT);
if (OrderType() == OP_BUY) {
if (l_bid_16 – OrderOpenPrice() >= l_point_8 * ai_0)
if (OrderStopLoss() < OrderOpenPrice() + ai_4 * l_point_8) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + ai_4 * l_point_8, OrderTakeProfit(), 0, Green);
} else {
if (OrderType() == OP_SELL) {
if (OrderOpenPrice() – l_ask_24 >= l_point_8 * ai_0)
if (OrderStopLoss() > OrderOpenPrice() – ai_4 * l_point_8 || OrderStopLoss() == 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() – ai_4 * l_point_8, OrderTakeProfit(), 0, Red);
}
}
}
}
}

void trailingStopManager(int ai_0, int ai_4) {
double l_point_8;
double l_bid_16;
double l_ask_24;
for (int l_pos_32 = 0; l_pos_32 < OrdersTotal(); l_pos_32++) {
OrderSelect(l_pos_32, SELECT_BY_POS, MODE_TRADES);
if (ai_0 > 0 && orderBelongsToMe()) {
l_bid_16 = MarketInfo(OrderSymbol(), MODE_BID);
l_ask_24 = MarketInfo(OrderSymbol(), MODE_ASK);
l_point_8 = MarketInfo(OrderSymbol(), MODE_POINT);
if (OrderType() == OP_BUY) {
if (l_bid_16 – OrderOpenPrice() > l_point_8 * ai_0 || ai_4 == 0)
if (OrderStopLoss() < l_bid_16 – l_point_8 * ai_0) OrderModify(OrderTicket(), OrderOpenPrice(), l_bid_16 – l_point_8 * ai_0, OrderTakeProfit(), 0, Green);
} else {
if (OrderType() == OP_SELL) {
if (OrderOpenPrice() – l_ask_24 > l_point_8 * ai_0 || ai_4 == 0)
if (OrderStopLoss() > l_ask_24 + l_point_8 * ai_0 || OrderStopLoss() == 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_ask_24 + l_point_8 * ai_0, OrderTakeProfit(), 0, Red);
}
}
}
}
}

void swissArmyOrderCloser() {
for (int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) {
OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
if (orderBelongsToMe()) {
if (orderTypeManagementAllowed(OrderType())) {
doing(“close ” + OrderSymbol() + ” orders.”);
positionCloser(l_pos_0);
}
}
}
}

void actionFunction() {
bool li_0 = TRUE;
bool li_4 = TRUE;
if (gi_428 > 0) {
if (CloseOrders) {
swissArmyOrderCloser();
li_4 = FALSE;
li_0 = FALSE;
}
}
if (gi_420 > 0 && li_4) {
if (HedgeOrders) {
prepareToHedge();
sendHedges();
}
}
if (gi_420 > 0 && li_0) {
if (SetStoploss && Stoploss > 0) modifyMyOrders(gi_364);
else
if (RemoveStoploss) modifyMyOrders(gi_356);
if (SetTakeProfit && TakeProfit > 0) {
modifyMyOrders(gi_360);
return;
}
if (RemoveTakeProfit) modifyMyOrders(gi_352);
}
}

double balanceDeviation() {
double ld_0 = AccountBalance() + gd_436 + gd_452;
double ld_8 = AccountBalance();
double ld_ret_16 = 100.0 * (ld_0 / ld_8 – 1.0);
return (ld_ret_16);
}

void doing(string as_0) {
Print(ExpertName + ” is attempting to ” + as_0);
}

int pipCount() {
int li_ret_0 = gd_444;
return (li_ret_0);
}

void modifyMyOrders(int ai_0) {
color l_color_4 = Red;
for (int l_pos_8 = OrdersTotal() – 1; l_pos_8 >= 0; l_pos_8–) {
OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
if (orderBelongsToMe() && orderTypeAllowed(OrderType())) {
if (ai_0 == gi_352) {
if (OrderTakeProfit() != 0.0) {
doing(“remove takeprofits.”);
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), 0, 0, l_color_4);
}
} else {
if (ai_0 == gi_360) {
if (OrderTakeProfit() == 0.0) {
doing(“set takeprofits.”);
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), takeGenerator(OrderSymbol(), OrderType(), OrderOpenPrice(), TakeProfit), 0, l_color_4);
}
}
}
if (ai_0 == gi_356) {
if (OrderStopLoss() != 0.0) {
doing(“remove stoplosses.”);
OrderModify(OrderTicket(), OrderOpenPrice(), 0, OrderTakeProfit(), 0, l_color_4);
}
} else {
if (ai_0 == gi_364) {
if (OrderStopLoss() == 0.0) {
doing(“set stoplosses”);
OrderModify(OrderTicket(), OrderOpenPrice(), stopGenerator(OrderSymbol(), OrderType(), OrderOpenPrice(), Stoploss), OrderTakeProfit(), 0, l_color_4);
}
}
}
}
}
}

void prepareToHedge() {
ArrayResize(gsa_468, gi_420);
string ls_unused_0 = “\n”;
int l_index_8 = 0;
int l_index_12 = 0;
for (int l_pos_16 = OrdersTotal() – 1; l_pos_16 >= 0; l_pos_16–) {
OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES);
if (orderBelongsToMe() && orderTypeAllowed(OrderType())) {
if (OrderType() == OP_BUY) {
gsa_468[l_index_8] = OrderSymbol();
l_index_8++;
} else {
if (OrderType() == OP_SELL) {
gsa_468[l_index_8] = OrderSymbol();
l_index_8++;
}
}
}
}
gi_432 = createUniqueArray();
ArrayResize(gda_476, gi_432);
for (l_pos_16 = 0; l_pos_16 < gi_432; l_pos_16++) gda_476[l_pos_16] = 0;
for (int l_count_20 = 0; l_count_20 < gi_432; l_count_20++) {
for (l_pos_16 = OrdersTotal() – 1; l_pos_16 >= 0; l_pos_16–) {
OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES);
if (orderBelongsToMe()) {
if (OrderSymbol() == gsa_472[l_index_12]) {
if (OrderType() == OP_BUY) gda_476[l_index_12] += OrderLots();
if (OrderType() == OP_SELL) gda_476[l_index_12] = gda_476[l_index_12] – OrderLots();
}
}
}
l_index_12++;
}
}

int createUniqueArray() {
bool li_0 = FALSE;
int li_ret_4 = 0;
ArrayResize(gsa_472, gi_420);
for (int l_index_8 = 0; l_index_8 < gi_420; l_index_8++) gsa_472[l_index_8] = “empty”;
for (int l_index_12 = 0; l_index_12 < gi_420; l_index_12++) {
for (int l_index_16 = 0; l_index_16 < gi_420; l_index_16++)
if (gsa_472[l_index_16] == gsa_468[l_index_12]) li_0 = TRUE;
if (li_0 == FALSE) {
gsa_472[li_ret_4] = gsa_468[l_index_12];
li_ret_4++;
}
li_0 = FALSE;
}
ArrayResize(gsa_472, li_ret_4);
return (li_ret_4);
}

void sendHedges() {
double ld_4;
double l_price_16;
bool li_0 = FALSE;
bool li_12 = gi_348;
for (int l_index_24 = 0; l_index_24 < gi_432; l_index_24++) {
if (gda_476[l_index_24] < 0.0) {
li_0 = TRUE;
li_12 = FALSE;
ld_4 = MathAbs(gda_476[l_index_24]);
l_price_16 = MarketInfo(gsa_472[l_index_24], MODE_ASK);
} else {
if (gda_476[l_index_24] > 0.0) {
li_0 = TRUE;
li_12 = TRUE;
ld_4 = gda_476[l_index_24];
l_price_16 = MarketInfo(gsa_472[l_index_24], MODE_BID);
}
}
if (li_0) {
doing(“hedge active ” + gsa_472[l_index_24] + ” orders.”);
universalOrderTaker(gsa_472[l_index_24], li_12, ld_4, l_price_16, stopGenerator(gsa_472[l_index_24], li_12, l_price_16, Stoploss), takeGenerator(gsa_472[l_index_24], li_12, l_price_16, TakeProfit), commentString(), simpleMagicGenerator());
}
li_0 = FALSE;
}
}

string commentString() {
string l_str_concat_0 = StringConcatenate(ExpertName, “: Hedge Order”);
return (l_str_concat_0);
}

void statTracker() {
gd_436 = 0;
gd_444 = 0;
gd_452 = 0;
gd_460 = 0;
if (balanceDeviation() > gd_488) gd_488 = balanceDeviation();
if (balanceDeviation() < gd_480) gd_480 = balanceDeviation();
for (int l_pos_0 = OrdersTotal() – 1; l_pos_0 >= 0; l_pos_0–) {
OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
if (orderBelongsToMe() && orderTypeAllowed(OrderType()) || SelectiveScan == FALSE) {
if (OrderType() == OP_BUY) gd_444 += (MarketInfo(OrderSymbol(), MODE_BID) – OrderOpenPrice()) / MarketInfo(OrderSymbol(), MODE_POINT);
else
if (OrderType() == OP_SELL) gd_444 += (OrderOpenPrice() – MarketInfo(OrderSymbol(), MODE_ASK)) / MarketInfo(OrderSymbol(), MODE_POINT);
if (OrderType() == OP_SELL || OrderType() == OP_BUY) {
gd_436 += OrderProfit();
gd_452 += OrderSwap();
gd_460 += OrderLots() * MarketInfo(OrderSymbol(), MODE_SPREAD) * MarketInfo(OrderSymbol(), MODE_TICKVALUE);
}
}
}
}

void Wait() {
while (IsTradeContextBusy()) Sleep(100);
}

int orderTypeAllowed(int ai_0) {
switch (ai_0) {
case 0:
if (Buy_Active || Allow_All_Types) return (1);
return (0);
case 1:
if (Sell_Active || Allow_All_Types) return (1);
return (0);
case 4:
if (Buy_Stop || Allow_All_Types) return (1);
return (0);
case 5:
if (Sell_Stop || Allow_All_Types) return (1);
return (0);
case 2:
if (Buy_Limit || Allow_All_Types) return (1);
return (0);
case 3:
if (Sell_Limit || Allow_All_Types) return (1);
return (0);
}
return (0);
}

void universalOrderCloser(int a_pos_0, int ai_4, double a_ord_lots_8) {
int l_slippage_16 = Slippage;
OrderSelect(a_pos_0, ai_4, MODE_TRADES);
if (OrderTicket() > 0) {
if (a_ord_lots_8 <= 0.0) a_ord_lots_8 = OrderLots();
Wait();
switch (OrderType()) {
case OP_SELLLIMIT:
case OP_SELLSTOP:
case OP_BUYLIMIT:
case OP_BUYSTOP:
OrderDelete(OrderTicket());
return;
case OP_SELL:
OrderClose(OrderTicket(), a_ord_lots_8, MarketInfo(OrderSymbol(), MODE_ASK), l_slippage_16, CLR_NONE);
return;
case OP_BUY:
OrderClose(OrderTicket(), a_ord_lots_8, MarketInfo(OrderSymbol(), MODE_BID), l_slippage_16, CLR_NONE);
}
}
}

void positionCloser(int ai_0) {
universalOrderCloser(ai_0, SELECT_BY_POS, 0);
}

bool orderTypeManagementAllowed(int ai_0) {
switch (ai_0) {
case 0:
if (Buy_Active || Allow_All_Types) return (TRUE);
return (FALSE);
case 1:
if (Sell_Active || Allow_All_Types) return (TRUE);
return (FALSE);
case 4:
if (Buy_Stop || Allow_All_Types) return (TRUE);
return (FALSE);
case 5:
if (Sell_Stop || Allow_All_Types) return (TRUE);
return (FALSE);
case 2:
if (Buy_Limit || Allow_All_Types) return (TRUE);
return (FALSE);
case 3:
if (Sell_Limit || Allow_All_Types) return (TRUE);
return (FALSE);
}
return (FALSE);
}

void universalOrderTaker(string a_symbol_0, int a_cmd_8, double a_lots_12, double a_price_20, double a_price_28, double a_price_36, string a_comment_44, int a_magic_52) {
string ls_60;
int l_slippage_56 = Slippage;
switch (a_cmd_8) {
case OP_SELLSTOP:
ls_60 = “SELLSTOP”;
break;
case OP_SELLLIMIT:
ls_60 = “SELLLIMIT”;
break;
case OP_BUYSTOP:
ls_60 = “BUYSTOP”;
break;
case OP_BUYLIMIT:
ls_60 = “BUYLIMIT”;
break;
case OP_SELL:
ls_60 = “SELL”;
break;
case OP_BUY:
ls_60 = “BUY”;
}
Wait();
int l_ticket_72 = OrderSend(a_symbol_0, a_cmd_8, a_lots_12, a_price_20, l_slippage_56, a_price_28, a_price_36, a_comment_44, a_magic_52, 0, Violet);
if (l_ticket_72 > 0) {
if (OrderSelect(l_ticket_72, SELECT_BY_TICKET, MODE_TRADES)) Print(ExpertName + ” ” + ls_60 + ” order at “, OrderOpenPrice());
} else Print(“Error opening ” + ls_60 + ” order: “, ErrorDescription(GetLastError()));
}

double takeGenerator(string a_symbol_0, int ai_8, double ad_12, int ai_20) {
double l_point_24 = MarketInfo(a_symbol_0, MODE_POINT);
if (ai_20 == 0) return (0);
if (ai_8 == 0) return (ad_12 + ai_20 * l_point_24);
if (ai_8 == 1) return (ad_12 – ai_20 * l_point_24);
return (0);
}

double stopGenerator(string a_symbol_0, int ai_8, double ad_12, int ai_20) {
double l_point_24 = MarketInfo(a_symbol_0, MODE_POINT);
if (ai_20 == 0) return (0);
if (ai_8 == 0) return (ad_12 – ai_20 * l_point_24);
if (ai_8 == 1) return (ad_12 + ai_20 * l_point_24);
return (0);
}

如果你对文件有了解,请帮助投票!

If you are familiar with the file, please help vote!

平均评分 0 / 5. 投票数: 0

到目前为止还没有投票!成为第一位投票人。

相关资源

暂无评论

暂无评论...