EA Code tweaking

To add comments, please log in or register
jeffkerwin
92
jeffkerwin  

Hi I have this EA code but for some reason I cant place trades with TP=6 and SL=2. Can anyone have a squizz at the code and let me know what needs changing and what to change it to?

Thanks

JK

extern double Lots = 0.1;

extern double TakeProfit = 10.0;

extern double StopLoss = 10.0;

extern int NumOfTrades = 10;

int gi_104 = 0;

bool gi_unused_108 = FALSE;

int g_ticket_112 = -1;

int g_ticket_116 = -1;

extern int slippage = 3;

extern int MAGIC = 12345;

double g_point_128;

int init() {

if (Point == 0.00001) g_point_128 = 0.0001;

else {

if (Point == 0.001) g_point_128 = 0.01;

else g_point_128 = Point;

}

return (0);

}

int deinit() {

return (0);

}

int start() {

Comment("Total Trades to Open " + NumOfTrades,

"\n", " Total Trades Opened " + gi_104);

if (OpenTrades() < 1 && gi_104 < NumOfTrades) {

g_ticket_112 = OrderSend(Symbol(), OP_BUY, Lots, Ask, slippage, Ask - StopLoss * g_point_128, Ask + TakeProfit * g_point_128, "EA", MAGIC, 0, Blue);

g_ticket_116 = OrderSend(Symbol(), OP_SELL, Lots, Bid, slippage, Bid + StopLoss * g_point_128, Bid - TakeProfit * g_point_128, "EA", MAGIC, 0, Red);

gi_104++;

}

return (0);

}

int OpenTrades() {

int l_count_0 = 0;

for (int l_pos_4 = OrdersTotal() - 1; l_pos_4 >= 0; l_pos_4--) {

OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);

if (OrderMagicNumber() == MAGIC) {

if (OrderSymbol() == Symbol()) {

if (OrderType() == OP_BUY) l_count_0++;

if (OrderType() == OP_SELL) l_count_0++;

}

}

}

return (l_count_0);

}

To add comments, please log in or register