Scan For 50 sma higher than 150 sma but result are wrong

Optuma Forums Optuma Scripting Scan For 50 sma higher than 150 sma but result are wrong

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #56593
    AvatarDeepak
    • Topics: 30
    • Replies: 15
    • Posts: 45

    Hiii,

     

    I have written below code for finding stock which has 50 sma higher than 150 sma but results are wrong. Also some filter i have added which are not working.

     

    MA(BARS=20, STYLE=Exponential,CALC=Close)>MA(BARS=40, STYLE=Exponential,CALC=Close) AND

    MA(BARS=50, STYLE=Simple, CALC=Close)>MA(BARS=150, STYLE=Simple, CALC=Close) )

    AND

    ( close()>MA(BARS=50,CALC=Close) AND ( low()<MA(BARS=50, CALC=Close) OR low()[-1]<MA(BARS=50, CALC=Close)[-1] OR low()[-2]<MA(BARS=50, CALC=Close)[-2] OR low()[-3]<MA(BARS=50, CALC=Close)[-3])) or

    ( close()>MA(BARS=100,CALC=Close) AND ( low()<MA(BARS=100, CALC=Close) OR low()[-1]<MA(BARS=100, CALC=Close)[-1] OR low()[-2]<MA(BARS=100, CALC=Close)[-2] OR low()[-3]<MA(BARS=100, CALC=Close)[-3]))

     

     

    #56605
    AvatarTrevor R
    • Topics: 95
    • Replies: 276
    • Posts: 371

    Hi Deepak,

    I’ve been trying to post a response to your request for assistance but the Forum keeps rejecting my detailed postfrown I reported to problem to Optuma Support, but because of the Christmas/New Year holidays we are unlikely to see a resolution before mid-January.

    Send your email address to me at AuldTyma.Data@gmail.com and I’ll send my response directly to you.

    Cheers

    Trevor

    The Auld Tyma at

    Auld Tyma Data Logo with URL 1 cm

     

    #56699
    AvatarTrevor R
    • Topics: 95
    • Replies: 276
    • Posts: 371

    Hi Deepak,

    I’ve been trying to post this response for some time but the Forum keeps rejecting it for some reason the Optuma Guru’s have not identified, so here I go trying again at their request.

    I must admit that I really cannot work out what you are trying to do. You say you want to find stocks when the 50 sma is greater than the 150 sma, but then I find your script has ema20, ema40, sma50, sma150, ma50 and ma100. You do not describe what all the other moving averages are supposed to be doing.

    Your script has numerous “AND”, “OR”, “>” and “<” operators, in many cases it being unclear in which sequence they should be evaluated. As written they will be evaluated sequentially.

    What I mean is Var1 > Var2 Or Var3 < Var4 And Var5 > Var6 can result in a confused and unexpected result as the script will attempt to evaluate itself in a simple left to right sequence. To mark sure the sequence is evaluated correctly it needs to be written as  (Var1 > Var2) Or (Var3 < Var4) And (Var5 > Var6).  This clear definition of the groups of comparison and evaluations becomes even more critical as the scripts become more complex.

    I’ve taken your script and split it into individual variables and shown some different bracketing arrangement that will produce very different results. As  I can’t work out what you are trying to achieve with your complete script this will most probably not give you the results you are seeking.

    A few other comments:

    ·         It is well worth splitting your script into multiple simple evaluations as I’ve done above, and then combine the variables. Doing this allows you to easily comment out (// at the start of the line) to test the script step by step. It also makes bracketing the various sub-scripts easier and clearer.

    ·         I find it advisable to define all the properties of functions so you can be sure you have them the way you desire. (Many of your MA functions are relying in the default setting, whatever that may be.)

    ·         Function like CLOSE() and LOW() require the round brackets.

    ·         It’s simpler to put the bar offset for OPEN(), HIGH(), LOW() and CLOSE() between the round brackets, rather than appending the square bracketed offset, eg CLOSE(-1) is the same as CLOSE()[-1].

    ·         I must admit I don’t like the use of variable names like var1, var2 etc. I prefer meaningful, even though longer, variable names that have some meaning, eg the ema50 and ema150 which immediately can be understood as exponential moving average 50 or 150. It makes working out what you were trying to do when you go back to your script after a break of a few days or more. Have a shot at guessing at ClGtMA50 and LoLtMA50 – they’d be typical variable names I’d use in the above script.

    Happy scripting

    Cheers

    Trevor

    The Auld Tyma at

    Auld Tyma Data Logo with URL 1 cm

    #56739
    AvatarDeepak
    • Topics: 30
    • Replies: 15
    • Posts: 45

    Sir i have put simple formula as below but results are still not matching

     

    (MA(BARS=20, STYLE=Exponential,CALC=Close)>MA(BARS=40, STYLE=Exponential,CALC=Close)) and (MA(BARS=50, STYLE=Simple, CALC=Close)>MA(BARS=150, STYLE=Simple, CALC=Close))

     

    The above criteria in my understanding is 20 EMA > 40 EMA

    and

    50 SMA > 150 SMA

    so the result shall be on those which satisfy both of the above conditions.

     

    However i am getting result which is wrong.

     

    Below attached figure yellow average is 150 SMA & Blue is 50 SMA.

     

    whereas 20 EMA & 40 EMA are in order which are dotted respectively.

     

    PS: Also is i am putting semicolon at end optuma is restarting again & again.

     

    Attachments:
    #56743
    AvatarTrevor R
    • Topics: 95
    • Replies: 276
    • Posts: 371

    Hi Deepak,

    Your script:

    is working perfectly as can be seen on the following chart of the NDY:

    20200121 Deepak's Script

    I do not subscribe to the Indian market so cannot show you IIFL, so I’ve used NDY (NASDAQ100 Index) and as you can see your script has highlighted using SHOWBARs (the arrows) and SHOWPLOT (yellow shading using an unlinked layer) where your script conditions are met.

    Cheers

    Trevor

    The Auld Tyma at

    Auld Tyma Data Logo with URL 1 cm

     

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

Pin It on Pinterest

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close