Please continue this in your old thread.
ubzen:
First, thank you for your help you gave me before but it seems any of them are wrong.
In my first code part here:
if (OrderType()==0 && Bid-OrderStopLoss() > 150*Point) { double SL_Buy = Bid-150*Point; bool Answer=OrderModify(OrderTicket(),OrderOpenPrice(),SL_Buy,OrderTakeProfit(),0,CLR_NONE); int timewait = TimeCurrent() + 7200; while (TimeCurrent() < timewait) { Alert("not yet"); } }
What I already know:
1. The strategy tester only use TimeCurrent() function at testing
2. The strategy tester don't use TimeLocal() and Sleep() function at testing
3. RefreshRates() is also doesn't work ( in the while cycle at least )
4. This solution is also doesn't work for me:
datetime global_updateTime = 0; int start(){ if(global_updateTime == 0 || TimeCurrent() > global_updateTime){ // do your stuff global_updateTime += 7200; }else{ // do nothing, go into next cycle } }
I fixed it to this: global_updateTime += TimeCurrent() + 7200;
and I also tried it with static global_updateTime in the start() function but it doesn't work
Please help me how can I make a trailing stop with the use of TimeCurrent()
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
First, thank you for your help you gave me before but it seems any of them are wrong.
I my first code part here:
if (OrderType()==0 && Bid-OrderStopLoss() > 150*Point)
{
double SL_Buy = Bid-150*Point;
bool Answer=OrderModify(OrderTicket(),OrderOpenPrice(),SL_Buy,OrderTakeProfit(),0,CLR_NONE);
int timewait = TimeCurrent() + 7200;
while (TimeCurrent() < timewait)
{
Alert("not yet");
}
}
What I already know:
1. The strategy tester only use TimeCurrent() function at testing
2. The strategy tester don't use TimeLocal() and Sleep() function at testing
3. RefreshRates() is also doesn't work ( at least in the while cycle )
4. This solution is also wrong:
datetime global_updateTime = 0;
int start(){
if(global_updateTime == 0 || TimeCurrent() > global_updateTime){
// do your stuff
global_updateTime += 7200;
}else{
// do nothing, go into next cycle
}
}
I fixed it to this: global_updateTime += TimeCurrent() + 7200;
and I also tried it with static global_updateTime in the start() function but it doesn't work
Please help me how can I make a trailing stop with the use of TimeCurrent()
Thank you!