Does anyone know, how to put takeprofit in code of this EA?
Files:
artificialintelligence.mq4
6 kb
Add this with the other extern variables near the top of the EA
extern int TakeProfit=60; // can be whatever number you want
In the OrderSend line
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 3, Bid - sl * Point, 0, "AI", MagicNumber, 0, Blue);
replace the 0 with something like
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 3, Bid - sl * Point, Ask+TakeProfit*Point, "AI", MagicNumber, 0, Blue);
and change this line
ticket = OrderSend(Symbol(), OP_SELL, lots * 2, Bid, 3, Ask + sl * Point, 0, "AI", MagicNumber, 0, Red);
to
ticket = OrderSend(Symbol(), OP_SELL, lots * 2, Bid, 3, Ask + sl * Point, Bid-TakeProfit*Point, "AI", MagicNumber, 0, Red);
NB - the TakeProfit is in pips, the TakeProfit value in the Order has to be a price
Good Luck
-BB-
BarrowBoy:
Add this with the other extern variables near the top of the EA
extern int TakeProfit=60; // can be whatever number you want
In the OrderSend line
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 3, Bid - sl * Point, 0, "AI", MagicNumber, 0, Blue);
replace the 0 with something like
ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 3, Bid - sl * Point, Ask+TakeProfit*Point, "AI", MagicNumber, 0, Blue);
and change this line
ticket = OrderSend(Symbol(), OP_SELL, lots * 2, Bid, 3, Ask + sl * Point, 0, "AI", MagicNumber, 0, Red);
to
ticket = OrderSend(Symbol(), OP_SELL, lots * 2, Bid, 3, Ask + sl * Point, Bid-TakeProfit*Point, "AI", MagicNumber, 0, Red);
NB - the TakeProfit is in pips, the TakeProfit value in the Order has to be a price
Good Luck
-BB-
Hello!
I try this but it doesn't work. Could you or someone else please look again what could be wrong.
By, Jure
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register