is there anybody who can tell me why this loop gives problem when backtesting :
if(TP_ameliore==true && OrderSelect(ticket,SELECT_BY_TICKET)==true)
if (Bid>(OrderOpenPrice()+takeprofit*Point) && OrderType()==OP_BUY)
for(int i=0;i<=1000;i++)
{
double previous_tick_on_bid=Bid;
while (RefreshRates()==false)
{
if(Bid<previous_tick_on_bid)
OrderClose(ticket,lots,Bid,3,Black);
}
}
This is an enhanced take profit
Why not try:
start(){
static double previous_tick_on_bid;
if(TP_ameliore==true && OrderSelect(ticket,SELECT_BY_TICKET)==true) {
if (Bid>(OrderOpenPrice()+takeprofit*Point) && OrderType()==OP_BUY) {
if(Bid<previous_tick_on_bid) {
OrderClose(ticket,lots,Bid,3,Black);
}
}
}
previous_tick_on_bid=Bid;
}
Why not try:
start(){
static double previous_tick_on_bid;
if(TP_ameliore==true && OrderSelect(ticket,SELECT_BY_TICKET)==true) {
if (Bid>(OrderOpenPrice()+takeprofit*Point) && OrderType()==OP_BUY) {
if(Bid<previous_tick_on_bid) {
OrderClose(ticket,lots,Bid,3,Black);
}
}
}
previous_tick_on_bid=Bid;
}
This is not a loop i think. To be clear i want to create a loop where i compare incoming tick to previous one and not close the order as long as bid is rising for example. But thank you for trying.
anyone else for a suggestion on this please. TY
The while-loop wouldn't work, as RefreshRates()==false means the Bid values hasn't changed, it remains as Bid == previous_tick_on_bid, so the if-statement never gets satisfied so the order never gets closed. Try something like this:
if (Bid>(OrderOpenPrice()+takeprofit*Point) && OrderType()==OP_BUY) for(int i=0;i<=1000;i++) { previous_tick_on_bid=Bid; if (RefreshRates()) { if (Bid<previous_tick_on_bid) { OrderClose(ticket,lots,Bid,3,Black); break; } } }
This is not a loop i think. To be clear i want to create a loop where i compare incoming tick to previous one and not close the order as long as bid is rising for example. But thank you for trying.
Yes it is. Each in comming tick will call start() If you don't exit start you won't get ticks.
Yes it is. Each in comming tick will call start() If you don't exit start you won't get ticks.
ok yes this true, but i l try this also, but i can't tell you if it works or not because i also have pb with my entries based on time. a great thank to you, your help is really appreciated. :)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
is there anybody who can tell me why this loop gives problem when backtesting :
if(TP_ameliore==true && OrderSelect(ticket,SELECT_BY_TICKET)==true)
if (Bid>(OrderOpenPrice()+takeprofit*Point) && OrderType()==OP_BUY)
for(int i=0;i<=1000;i++)
{
double previous_tick_on_bid=Bid;
while (RefreshRates()==false)
{
if(Bid<previous_tick_on_bid)
OrderClose(ticket,lots,Bid,3,Black);
}
}
This is an enhanced take profit
thanks in advance