Hi there, I m having problems figuring out how to set stoploss and take profit.
I have found a few answers online but cant seem to find a solution that works with my problem, and running out of ideas.
I can set vaules manually, im using Alpari UK demo account. I think the minimum SL TK is 30 pips.
Any help would be greatly appreciated :-)
<CODE REMOVED>
Please edit your post . . .
Hi there, I m having problems figuring out how to set stoploss and take profit.
I have found a few answers online but cant seem to find a solution that works with my problem, and running out of ideas.
I can set vaules manually, im using Alpari UK demo account. I think the minimum SL TK is 30 pips.
Any help would be greatly appreciated :-)
Your code . . .
double stop_loss = NormalizeDouble((price + SL*Point),Digits); double take_profit= NormalizeDouble((price + TP*Point),Digits);
The NormalizeDouble() is not needed you can get rid of it.
For a Buy the SL is below Ask and the TP is above Ask, for a Sell the SL is above Bid and the TP is below Bid . . . your code has the SL and TP above Ask/Bid
double SL = 5000000; double TP = 5000000;and SL below Bid and can not be negative
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there, I m having problems figuring out how to set stoploss and take profit.
I have found a few answers online but cant seem to find a solution that works with my problem, and running out of ideas.
I can set vaules manually, im using Alpari UK demo account. I think the minimum SL TK is 30 pips.
Any help would be greatly appreciated :-)
//=====================================================================================
//======================================make_trade======================================
//=====================================================================================
bool make_trade(int trade_type, double price, color Color)
{
//buy at Ask
//sell at bid
double Lots = 0.1;
double SL = 5000000;
double TP = 5000000;
int Magic = 12345;
double stop_loss = NormalizeDouble((price + SL*Point),Digits);
double take_profit= NormalizeDouble((price + TP*Point),Digits);
//Alert (Symbol() + " " + price + " " + stop_loss + " " + take_profit);
RefreshRates();
//int ticket=-1;
int ticket = OrderSend(Symbol(), trade_type, Lots, price, 3, 0, 0, "", Magic, 0, Color);
if (ticket == -1)
{
Print("OrderSend() error - ", GetLastError());
}
if (ticket > -1)
{
RefreshRates();
OrderSelect(ticket, SELECT_BY_TICKET);
bool retrn = OrderModify(OrderTicket(), OrderOpenPrice(), stop_loss,take_profit , 0, Color);
if (retrn == false)
{
Print("OrderModify() error - ", GetLastError());
}
}
}