Sounds wrong coding, anyone can help pls

Forums ProRealTime English forum ProOrder support Sounds wrong coding, anyone can help pls

Viewing 13 posts - 1 through 13 (of 13 total)
  • #244086

     

    #244093

    I don’t see errors. The system buys when the DEMA (orange) crosses over ATX (blue).

    #244095

    When I use the strategy this what I get, Pls see attached

    #244100

    Try putting / embedding the called Indicator in with the code of the rest of Strategy.

    Also, isn’t Line 35 (see below) of the ‘Adaptive Ind’ wrong / ‘suspect’ as STR is not defined anywhere, but STR is used in the rest of the  ‘Adaptive Ind’?   This might be causing ProOrder to Reject the overall code?

    sTR = (sTR[1] – sTR[1]) / adxLen + tr

    #244101

    Here is the Indicator if anybody has any ideas about fixing Line 35??

     

    #244109
    JS

    Nicolas, Can you explain the numerator logic – e.g. Line 35 is (sTR[1] – sTR[1]) which would appear to be either null or zero.

    • avatar
      Nicolas • 06/29/2018 #You are right, this is useless. Since I converted it from another programming language, I assume it was in the original code…

    #244114

    Thanks JS, but please could not you (anybody) rejig the code so that the subsequent use of sTR in the Strategy is removed / replaced with something meaningful?
    Examples are Line 40 & 41 –

    DIP = sDMPos / sTR * 100
    DIN = sDMNeg / sTR * 100

    I recall ages ago working up a decent backtest performance with the ‘Adaptive Indicator’, but the Algo got Rejected every time it ran due to ‘not enough historical data’ (yes, I did use Defparam PreLoadbars = 10000.

    The error messages we see are not always ‘true to the words’ and I am thinking that this useless bit of code (STR) was causing my Rejection and also the problems now experienced by the OP / efahmy

     

    #244115

    Assuming that’s the source code:

    https://www.tradingview.com/script/8TQl2WyE-Adaptive-ATR-ADX-Trend-V2-Strategy/

    Then for line 35 mentionned by GraHal, I would keep it and go instead with brackets modified like this (equivalent to “no brackets”, but just for the sake of better visibility…):

     

    Same thing by the way for lines 37 and 38, which could be modified as follows:

     

    To be tested to see if it helps…
    1 user thanked author for this post.
    #244127
    JS

    I think the code should be adjusted like this:

     

    1 user thanked author for this post.
    #244180

    Thank you all for the coding of the indicator, it is working properly, now anyone could help in coding the strategy of crossing between DEMA and ATX Pls.

    #244182

    Regarding the original error message,  and just for future reference, I think this is what’s happening.

    In a INDICATOR, if you just return a variable like, a[1], via the return line, you get the ‘Variable is Undefined’ error message.

    Alternatively, if in the main code you have a=a[1],  and Return a, the code will run, but the line for ‘a’ doesn’t display in the chart.

    I believe this  is because, on the first bar, Barindex = 0, the value of a[1] is undefined still, so there’s  no value to display from the bar before bar zero.

    This means that the equation evaluates to undefined, and maybe on the following bars the prior value is always undefined because of the prior attempted calculation.

     

    In back-test, the a=a[1] does the same, the code runs, however, if you graph ‘a’, again no line is drawn for the variable, because it’s undefined, similar to above.

    One way  to check if variables are defined in the back-test code is to Graph them and look if their line displays/appears.

     

    It’s worth noting that, if you don’t assign a value/variable to a variable, then you get the red ‘~’ line in the editor and the ‘Unknown Command’ error message if you try to ‘ADD’.

    But you don’t get it is you assign a variable with a undefined variable, like here to the bar before zero.

     

    Now in ProOrder, apart from only a couple of options, there’s no user/ext interaction with the strategy, any error will ‘Stop’ the strategy.

    However, since the code is only run once a bar, it’s not until the end of the bar the strategy was started on, the Strategy is ‘Stopped’.

    On small timeframes, that would be quite quick, but on long timeframe it will be slow, both could get impression that they worked for a while, before they don’t.

    In fact the the strategy is not tried till the start next new bar.

     

    In this case, the above called indicator must have return an undefined value, which triggered the strategy to STOP.

    So the ‘ server.strategy.probacktest.error.missing_data.call’ must mean, an undefined value was returned from the call’ed file.

     

    If this undefined variable scenario happens with out a call file, you get the error message,

    ‘The Trading system was stopped because the historical data loaded was insufficient to

    calculate at least one indicator during the evaluation of the last candlestick.’

     

    Leading you to a problem with PRELOADBARS.

    If you cannot retrieve a value from before bar zero, no amount of PLB’s will cure problem.

     

    The simple explanation is just a undefined variable, trying to retrieve a value from the previous bar to bar zero.

     

    In the original TV code, the variables were parameters of the called ‘nv()’ function.

    This function defaulted the variable to zero, I believe,  if  it was undefined or NAN, this zero value allowed the equation to derive a proper result value.

     

    In proOrder, you get a ‘Stopped’ system, and the usual cryptic message, unless your lucky.

    Regards all

     

    1 user thanked author for this post.
    #244278

    So after druby superlative analysis of the problem … if you change Lines 35 to 38 (in JS code above) to below … Rejection for ‘historical data loaded was insufficient‘ does not occur!

    Now I understand why ‘If barindex > 2’ is a fix! 🙂  I have used it before to stop Rejections in other strategies, but on an intuitive basis, now I have the full understanding as to why it is a fix!

    Big Thank You to …
    js for the code amendment.
    druby for the analysis of [1] undefined / Strategy Rejection.

     

    2 users thanked author for this post.
    #244279

    Try putting / embedding the called Indicator in with the code of the rest of Strategy.

    Also, isn’t Line 35 (see below) of the ‘Adaptive Ind’ wrong / ‘suspect’ as STR is not defined anywhere, but STR is used in the rest of the ‘Adaptive Ind’? This might be causing ProOrder to Reject the overall code?

    sTR = (sTR[1] – sTR[1]) / adxLen + tr

    First sTR need to be defined first or in a different way than by its previous value…
    (sTR[1] – sTR[1]) = 0 🙂
    Mean sTR = 0 anytime…
    Then sTR is used to divide which means division by 0…

    1 user thanked author for this post.
Viewing 13 posts - 1 through 13 (of 13 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login