Order, profit and stop loss triggered wrong

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #83575 quote
    Hiraokii
    Participant
    Junior

    Hi brothers, I want to ask another thing, I searched in fóruns already and I didn’t read anything to help me solve my problem.
    I have a code simple like this one, but when I run the backtest, the buy entry is always at the close of the previous bar level and not at the high level. And the stop is the same thing, it didn’t stop at the low of the previous bar and close at the low of the actual. Thanks

    If not longonmarket and close>=high[1] then 
    Buy 1 lot at high[1] limit
    Set target profit range[1]
    Set stop loss low[1]
    Endif
    If longonmarket (barindex-tradeindex=2) then
    Sell at market
    Endif
    #83576 quote
    Vonasi
    Moderator
    Master

    Your buy at a limit (better) price should work as you describe – are you allowing for spread?

    SET TARGET and SET STOP expects a distance and not a level or price so your SET TARGET should work (use SET TARGET pPROFIT to look for it in pips) but your SET STOP is unlikely to ever be hit.

    You have a typo in line 6 as an AND is missing.

    An image would help to show where you think a trade is being opened or closed incorrectly.

    #83581 quote
    Hiraokii
    Participant
    Junior

    Thanks brother, I am starting to understand better now.

    But I didn’t understand the spread thing, ig spread is 0,3 so it’s 0.003 right?
    In this picture it’s buying on the close of the candle and not at the higher. And it’s not stopping.

    220546FD-0C7B-4979-A417-FB6CC89D5521.png 220546FD-0C7B-4979-A417-FB6CC89D5521.png
    #83583 quote
    Vonasi
    Moderator
    Master

    In the image it does exactly what you have coded.

    [attachment file=83584]

    Screenshot_5-1.png Screenshot_5-1.png
    #83592 quote
    Hiraokii
    Participant
    Junior

    I tough that the spinning top was the high[1] now my brain is bugging…

    #83593 quote
    robertogozzi
    Moderator
    Master

    0,3 spread is 0.00003 (three tenths of a pip), not 0.003!

    Set stop loss low[1] is WRONG, as Vonasi pointed out. It requires a difference in price (such as CLOSE – LOW[1]), not a price. Dax is quoting about 11,200, so it would be 11,200-PIP stop loss and will never get hit (your account would be wiped out long before that).
    #83598 quote
    Hiraokii
    Participant
    Junior

    Thanks guys, sorry for those beginners questions.
    I fixed the sell entry but the stop is not changing, no idea how to set the stop to stop at the high of the same candle that the entry was done.

    E34D40BF-E082-4D56-8E8D-3B168D820553.png E34D40BF-E082-4D56-8E8D-3B168D820553.png
    #83602 quote
    robertogozzi
    Moderator
    Master
    Set Stop Loss (high - close)
    #83628 quote
    Hiraokii
    Participant
    Junior

    Thanks guys really 🙂

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

Order, profit and stop loss triggered wrong


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Hiraokii @hiraokii Participant
Summary

This topic contains 8 replies,
has 3 voices, and was last updated by Hiraokii
7 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/26/2018
Status: Active
Attachments: 3 files
Logo Logo
Loading...