SellAtStop isn't executed
Author: placebo76
Creation Date: 9/6/2015 4:47 PM
profile picture

placebo76

#1
Hi,

i'm a little bit confused.

I have an if-case for selling a EURUSD - position. Although the code in that if-case will be executed, the SellAtStop() - Position will not be executed. If i'm using other data than EURUSD, maybe Dow-Index, everything works fine. If i change the code to SellAtClose - everything works fine. Just the combination EURUSD/SellAtStop doesn't work.

CODE:
Please log in to see this code.


Maybe there is a problem because of the 4 decimals at forex-values?
profile picture

Eugene

#2
You should never pass "bar" to *AtStop/*AtLimit and *AtMarket methods. This is called peeking into the future. Please review:

* WealthScript Programming Guide > Programming Trading Strategies > Peeking
profile picture

placebo76

#3
Hi Eugene,

is that also a problem if i don't use any indicators based on close data like in this case?

If the low today is lower than a low before, than the SellAtStop is reached at any time this day, so in my opinion its no peeking.

But i think thats not the problem for the missing Stop-Trigger ...

profile picture

Eugene

#4
Hi Daniel,

Unfortunately, in this case your opinion is incorrect. In real life you can not execute a SellAtStop on this bar (today) after knowing this bar's Low. This knowledge is available to you only after this bar (today) has closed. Fix your broken code to execute on bar+1.
profile picture

placebo76

#5
Hi Eugene,

i have the same problem when i'm using "bar+1" in the SellAtStop()-function.

EDIT: ok bar + 1 plus Stop with Low is a problem in this case, i have to check that
profile picture

Eugene

#6
Could you paste the complete Strategy code for us to evaluate it?
profile picture

placebo76

#7
Hi Eugene,

if it is needed, then i can do that (tomorrow, after editing it).

But i try to show another demonstration, maybe that helps:

CODE:
Please log in to see this code.


In my opinion, if the green value is lower than the black value, the SellAtStop-Trigger should be executed.

You can see in my image example that in the red ellipses, the low of these bars (green) were lower than the previous defined low for check (black). But there was no closing of the positions.


profile picture

Eugene

#8
Daniel,

Let's see the complete code and I'll show what's wrong with it.
profile picture

Cone

#9
In addition to your code..

1. Do you have EURUSD set up in the Futures Symbol Manager?
2. What setting do you have for Preferences (F12) > Advanced Options > Pricing Decimals?
3. Is Preferences (F12) > Backtest Settings > Turn off limit/stop order rounding entirely selected (recommended)?

profile picture

placebo76

#10
Hi,

as i have supposed in my first post the decimals was the problem ((F12) > Advanced Options > Pricing Decimals)

Thanks Cone & Eugene for helping me.