Hi,
I've figured it out. adding RefreshRates() withing the 'while loop' solced the issue.
Regards,
lucidlamp
I've figured it out. adding RefreshRates() withing the 'while loop' solced the issue.
Regards,
lucidlamp
while(iTicket==iOrderTicket()) { Print(Low[1]); if(Low[1]>dStop) // Why does Low[1] return the same value it returned when the script was initiated, even when new bars are drawn? { dStop=Low[1]; vOrderModify(dStop); } RefreshRates(); }
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
Consider this trailing stop script for a long position (it actually opens an order then tracks it, setting stoplosses). Furthermore consider that Lows are ascending (making new highs so to speak). I would think that the script would have no problem updating the stopLoss according to the previous bars low. It doesnt. I use a 'while loop' to scan for price change to trigger the order modification, but it does nothing. I added a 'Print' statement to check the values being returned and I noticed that once in the 'while loop' the value of 'Low[1]' would remain the same as the value it returned when the script was initiated, regardless of how many new bars were being drawn.
I am trying to write a script that will open an order and place an initial stoploss. A stoploss which is to be modified automatically until the stop is hit, closing the order and canceling out the script.
Any thoughts, suggestions and or help would be most appreciated,
lucidlamp