• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 2:22pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 2:22pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Having MT4 on two computer and having to REDO stuff 16 replies

Anyone having trouble connecting to IBFX? 1 reply

Having Trouble with Cross Logic for Indicator. 1 reply

Having Trouble with MetaTrader 4 replies

Having Trouble with my Charting Program... 2 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe

Trying to make an EA but I'm having some trouble

  • Post #1
  • Quote
  • First Post: Edited at 2:58pm Mar 22, 2010 1:44pm | Edited at 2:58pm
  •  Esseintes
  • | Joined Feb 2010 | Status: Junior Member | 1 Post
hello

sorry for my terrible english

i try to make an ea but i have problems with icustom

i am using supertrend
http://codebase.mql4.com/3959
variables Nbr_Periods and Multiplier
and nonlagdot
http://codebase.mql4.com/3055
variables Price, Length, Displace, Filter, Color, ColorBarBack, Deviation

i have written some code but now i have trouble

here is my code

Inserted Code
#include <stdlib.mqh>

extern int TrailingStop11 = 10;
extern int NewTakeProfit11 = 30;
extern int TrailingGap11 = 3;
extern double BuyLots9 = 0.3;
extern int BuyStoploss9 = 50;
extern int BuyTakeprofit9 = 100;
double gd_104 = 1.0;
bool gi_112 = FALSE;

int init() {
Comment("");
return (0);
}

int start() {
if (Bars < 10) {
Comment("Not enough bars");
return (0);
}
if (gi_112 == TRUE) {
Comment("EA Terminated.");
return (0);
}
OnEveryTick2();
return (0);
}

void OnEveryTick2() {
TrailingStop11();
TechnicalAnalysis2x5();
TechnicalAnalysis2x1();
}

void TrailingStop11() {
for (int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) {
if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == 1) {
if (OrderType() == OP_BUY && Ask - OrderOpenPrice() > TrailingStop11 * gd_104 * Point)
if (OrderStopLoss() < Ask - (TrailingStop11 + TrailingGap11) * gd_104 * Point) OrderModify(OrderTicket(), OrderOpenPrice(), Ask - TrailingStop11 * gd_104 * Point, Ask + (NewTakeProfit11 + TrailingStop11) * gd_104 * Point, OrderExpiration(), White);
if (OrderType() == OP_SELL && OrderOpenPrice() - Bid > TrailingStop11 * gd_104 * Point)
if (OrderStopLoss() > Bid + (TrailingStop11 + TrailingGap11) * gd_104 * Point) OrderModify(OrderTicket(), OrderOpenPrice(), Bid + TrailingStop11 * gd_104 * Point, Bid - (NewTakeProfit11 + TrailingStop11) * gd_104 * Point, OrderExpiration(), White);
}
} else Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}
}

void TechnicalAnalysis2x5() {
if (iCustom(NULL, 0, "SuperTrend", 1, 1, 1, 0) > iCustom(NULL, 0, "SuperTrend", 1, 1, 1, 0) && iCustom(NULL, 0, "nonlagdot", 1, 1, 1, 1, 1, 1, 1, 1, 0) > iCustom(NULL, 0, "nonlagdot", 1, 1, 1, 1, 1, 1, 1, 1, 0)) IfOrderDoesNotExist6();
}

void IfOrderDoesNotExist6() {
bool li_0 = FALSE;
for (int l_pos_4 = OrdersTotal() - 1; l_pos_4 >= 0; l_pos_4--) {
if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) {
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) li_0 = TRUE;
} else Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}
if (li_0 == FALSE) {
}
}

void TechnicalAnalysis2x1() {
if (iCustom(NULL, 0, "SuperTrend", 1, 1, 1, 0) > iCustom(NULL, 0, "SuperTrend", 1, 1, 1, 0) && iCustom(NULL, 0, "nonlagdot", 1, 1, 1, 1, 1, 1, 1, 1, 0) > iCustom(NULL, 0, "nonlagdot", 1, 1, 1, 1, 1, 1, 1, 1, 0)) IfOrderDoesNotExist3();
}

void IfOrderDoesNotExist3() {
bool li_0 = FALSE;
for (int l_pos_4 = OrdersTotal() - 1; l_pos_4 >= 0; l_pos_4--) {
if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) {
if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) li_0 = TRUE;
} else Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}
if (li_0 == FALSE) IfOrderDoesNotExist7();
}

void IfOrderDoesNotExist7() {
bool li_0 = FALSE;
for (int l_pos_4 = OrdersTotal() - 1; l_pos_4 >= 0; l_pos_4--) {
if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) {
if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == 1) li_0 = TRUE;
} else Print("OrderSelect() error - ", ErrorDescription(GetLastError()));
}
if (li_0 == FALSE) BuyOrder9();
}

void BuyOrder9() {
bool l_bool_4;
int l_ticket_0 = OrderSend(Symbol(), OP_BUY, BuyLots9, Ask, 4, 0, 0, "My Expert", 1, 0, Blue);
if (l_ticket_0 > -1) {
OrderSelect(l_ticket_0, SELECT_BY_TICKET);
l_bool_4 = OrderModify(OrderTicket(), OrderOpenPrice(), Ask - BuyStoploss9 * gd_104 * Point, Ask + BuyTakeprofit9 * gd_104 * Point, 0, Blue);
if (l_bool_4 == FALSE) Print("OrderModify() error - ", ErrorDescription(GetLastError()));
} else Print("OrderSend() error - ", ErrorDescription(GetLastError()));
}

int deinit() {
return (0);
}



my plan
if the supertrend indicator change to uptrend (green) and the dots are blue (uptrend) > buy
if the supertrend indicator change to downtrend (red) and the dots are red (downtrend) > sell

thank you very much
  • Post #2
  • Quote
  • Last Post: Mar 22, 2010 2:39pm Mar 22, 2010 2:39pm
  •  7bit
  • Joined Mar 2009 | Status: Member | 1,231 Posts
I have some troubles reading your code

Quoting Esseintes
Disliked
here is my code
Ignored
It hurts the eyes and the brain having to look at unformatted code. Even the most beautiful looking and well structured code turns into a complete mess if you post it in variable font size and without indentation.

Could you please use the code button here in the forum posting toolbar when posting code snippets? Easily readable code will increase the chances that somebody will look at it for more than 2 minutes before giving up because of beginning headaches.
  • Platform Tech
  • /
  • Trying to make an EA but I'm having some trouble
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2021