In lieu of ticket: IF() statement problem

Optuma Forums Optuma Scripting In lieu of ticket: IF() statement problem

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #51759
    Colin
    • Topics: 11
    • Replies: 20
    • Posts: 31

    Hi,

    OK. I will post my ticket here just to get something happening.

    I am trying to do a simple peak-detector-with-reset (code below). There are 3 IF()s in the code. The code fails on the third IF() (the associated ‘plot’ variable disappears of the screen is the only symptom). There is self-referentiality in the 1st IF() that works fine. The code is accepted by the compiler as valid. There’s nothing obviously wrong with the 3rd IF().

    PRETRADE = SWITCH( ((NDTOT[1] <= 0.0) AND (NDTOT[0] > NDTOT[1])), NDTOT[0] < NDTOT[1]); BUY = PRETRADE[0] and (PRETRADE[1] <= 0); BUY_PRICE = if(BUY[1] > 0, open(), BUY_PRICE); ND = COUNTMATCHSINCESIGNAL( 1 , BUY); PROFIT = close() - BUY_PRICE; GO = if(ND <= 1, 1.000, close()/BUY_PRICE); Gad = 1.0 + (GO - 1)/ND; Gad_max = if(Gad > Gad_max, Gad, Gad_max);

    I have tried to see if other functions in the language can do what I want. They don’t seem to be useful for this, but maybe I’ve missed something. All I want is to capture and maintain the maximum in Gad (called Gad_max) and reset it when GO is reset to 1 (happens because of the BUY single-day pulse). 

    I can’t see why the script doesn’t work.

    cheers

    colin

    (happy to issue a ticket on this if you want, when the system works)

    #51767
    Colin
    • Topics: 11
    • Replies: 20
    • Posts: 31

    Hi

    Posting my code (a literal Ctrl-C of the Optuma code surrounded by

    , I thought), has failed in the forum editor. Maybe that’s the cause of the  failure in the ticket system?

    cheers

    colin

     

    #51771
    Colin
    • Topics: 11
    • Replies: 20
    • Posts: 31

    Another test to post the real code:

    PRETRADE = SWITCH( ((NDTOT[1] <= 0.0) AND (NDTOT[0] > NDTOT[1])), NDTOT[0] < NDTOT[1]); BUY = PRETRADE[0] and (PRETRADE[1] <= 0); BUY_PRICE = if(BUY[1] > 0, open(), BUY_PRICE); ND = COUNTMATCHSINCESIGNAL( 1 , BUY); PROFIT = close() - BUY_PRICE; GO = if(ND <= 1, 1.000, close()/BUY_PRICE); Gad = 1.0 + (GO - 1)/ND; Gad_max = if(Gad > Gad_max, Gad, Gad_max);

    #51795
    Matthew
    • Topics: 5
    • Replies: 481
    • Posts: 486

    Hi Colin,

    You mentioned in your other post that the issue had been resolved. I’m not sure what adjustment you made, but we had a look at the script and this is the adjustment we made to resolve it…

    The adjustments we made are on the last 2 lines of the script.

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

Pin It on Pinterest