Hi.
I know this is very basic, but I've tried to solve this on my own for two hours and I just can't make it work. Any help would be appreciated.
I'm starting to learn MQL4 and Im trying to do an EA.
The idea is to buy if indicator's signal is 1 and sell if it's -1, and I'd like to close the open order in case there's one active in that same chart (other orders may be active in other charts).
Thanks in advance.
I know this is very basic, but I've tried to solve this on my own for two hours and I just can't make it work. Any help would be appreciated.
I'm starting to learn MQL4 and Im trying to do an EA.
The idea is to buy if indicator's signal is 1 and sell if it's -1, and I'd like to close the open order in case there's one active in that same chart (other orders may be active in other charts).
Thanks in advance.
Inserted Code
double trigger = iCustom(NULL,0,"StochTest", TimeFrame, var1, var2, var3, 0, 0); if (trigger = 1) { if (OrderSend(Symbol(), OP_BUY, lots, Ask, 3, Ask - stopLoss * Point, Ask + takeProfit * Point, "my forex wall-e order", 12345, 0, Red)) { OrderClose(12345, OrderLots(), Bid, 3, Violet); Print("Buy order succeeded!"); } if (trigger = -1) { if (OrderSend(Symbol(), OP_SELL, lots, Bid, 3, Bid + stopLoss * Point, Bid - takeProfit * Point, "my forex wall-e order", 12345, 0, Red)) { OrderClose(12345, OrderLots(), Ask, 3, Violet); Print("Sell order succeeded!"); }
Hard work and patience.