System stopped

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #14748 quote
    Gordon Gekko
    Participant
    Average

    Hi

    How can i render this?

    This trading system was stopped because the program used a negative or zero offset (ex: close[-10]) during the evaluation of the last candlestick. Please add protections to your code to prevent negative or zero offsets.

    #14750 quote
    Nicolas
    Keymaster
    Master

    Because you have calculation period somewhere in your code and it returns a null or negative value. You might be able to fix this with ABS instruction.

    If it doesn’t work, please post your code for a complete explanation of what happened.

    #14792 quote
    Gordon Gekko
    Participant
    Average

    Thanks for answer

    #63413 quote
    namrevlis24
    Participant
    Average

    Hi all,

    since I ran into the issue which Gordon Gekko describes, I would like to show you how I solved it for my case.
    The original code was:

    ...
    IF NOT ONMARKET and (some conditions true) THEN
    BUY 3 CONTRACT AT MARKET
    ENDIF
    ...
    IF LONGONMARKET AND (highest[BarIndex - TradeIndex](high) < something) THEN
    do something ;-)
    ENDIF
    ...

     

    In every every trade, when the first candle ran through and the system tried to evaluate the next candle, it ran on error
    “… system was stopped because the program used a negative or zero offset (ex: close[-10]) during the evaluation of the last candlestick. …”

    I solved it by just preventing the code to check “BarIndex – TradeIndex” when it is 0. This is always 0 in the first candle of the trade. So I added a simple condition to my code so that it looks as follows:

    ...
    IF NOT ONMARKET and (some conditions true) THEN
    BUY 3 CONTRACT AT MARKET
    ENDIF
    ...
    IF BarIndex - TradeIndex > 0 THEN
    IF LONGONMARKET AND (highest[BarIndex - TradeIndex](high) < something) THEN
    do something ;-)
    ENDIF
    ENDIF
    ...

     

    This worked well and the system doesn’t stop anymore 🙂

    Nicolas thanked this post
    #63471 quote
    Nicolas
    Keymaster
    Master

    Thanks a lot for your feedback about how to resolve this kind of error. We could also test the Highest period with MAX instruction, to “force” the period to be at least 1 if it is inferior or Barindex-Tradeindex if it is superior:

    ...
    IF NOT ONMARKET and (some conditions true) THEN
    BUY 3 CONTRACT AT MARKET
    ENDIF
    ...
    
    IF LONGONMARKET AND (highest[max(1,BarIndex - TradeIndex)](high) < something) THEN
    do something 😉
    ENDIF
    ...
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

System stopped


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/12/2016
Status: Active
Attachments: No files
Logo Logo
Loading...