Why Buy order is not placed when calculated Stoploss and Take profit are used
Why Buy order is not placed when calculated Stoploss and Take profit are used
Loading saved threads...
migdal menora · External communityPost link
External question — Stack Overflow Stack Exchange
Author: migdal menora
Original post: https://stackoverflow.com/questions/72518241
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I have a simple BUY order that, when the Take Profit and Stoploss are in points (ie: Ask+10*_Point), operates correctly. But when I change the take profit and stop loss from points to my own calculated values (CL_OP), the BUY order is not placing trades. How can I solve the issue:
input int _Hour =16;
input int _Minute =30;
bool NewBar()
{
static datetime OldTime = 0;
if(OldTime < Time[0])
{
OldTime = Time[0];
return(true);
}
else
{
return(false);
}
}
void OnTick()
{
int Hour_Int = Hour();
int Minute_Int = Minute();
double CL_OP = (Close[1] - Open[1]);
bool LastBearHiLoEngulf = (Close[1] < Open[1] && High[1] > High[2] && Low[1] < Low[2] );
if(NewBar())
if(OrdersTotal()==0)
// Apply signals on Buy opportunities
if( Hour_Int == _Hour && Minute_Int == _Minute && LastBearHiLoEngulf == TRUE)
{
int buyticket = OrderSend
(
Symbol(), // all symbols
OP_BUY, // Buy without delay
1, // 1 Microlots
Ask, // for market price
3, // 3 pips slippage
Ask - CL_OP, // Stop Loss - 1000*_Point
Ask + CL_OP , // Take profitworks with 100*_Point
"Buy LastBearHiLoEngulf Target: ", // comment
144, // Magic number
0, // no experiation day
Green // draw green arrow
);
}
}
Quote
Report
Forexipy · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: Forexipy
Original post: https://stackoverflow.com/a/72657538
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
double CL_OP = (Close[1] - Open[1]);
CL_OP is not a normal price to open trade. Actually, it is the Size of the Candle 1!
It should be something like this:
double CL_OP = Close[1] + (Close[1] - Open[1]);
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: migdal menora Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/72518241 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I have a simple BUY order that, when the Take Profit and Stoploss are in points (ie: Ask+10*_Point), operates correctly. But when I change the take profit and stop loss from points to my own calculated values (CL_OP), the BUY order is not placing trades. How can I solve the issue: input int _Hour =16; input int _Minute =30; bool NewBar() { static datetime OldTime = 0; if(OldTime < Time[0]) { OldTime = Time[0]; return(true); } else { return(false); } } void OnTick() { int Hour_Int = Hour(); int Minute_Int = Minute(); double CL_OP = (Close[1] - Open[1]); bool LastBearHiLoEngulf = (Close[1] < Open[1] && High[1] > High[2] && Low[1] < Low[2] ); if(NewBar()) if(OrdersTotal()==0) // Apply signals on Buy opportunities if( Hour_Int == _Hour && Minute_Int == _Minute && LastBearHiLoEngulf == TRUE) { int buyticket = OrderSend ( Symbol(), // all symbols OP_BUY, // Buy without delay 1, // 1 Microlots Ask, // for market price 3, // 3 pips slippage Ask - CL_OP, // Stop Loss - 1000*_Point Ask + CL_OP , // Take profitworks with 100*_Point "Buy LastBearHiLoEngulf Target: ", // comment 144, // Magic number 0, // no experiation day Green // draw green arrow ); } }
Checking account access…