OmniTrader Professional Forum
-
OmniScan
My own Olang Indicator |
^ Top | ||
Duxx![]() Posts: 881 Joined: 2/18/2009 ![]() | I feel dumb asking this question that by now I should probably know. I have written an Olang Indicator and I want to scan with it. I tried to scan but it returns 0. And by hand I know there must be at least 100 occurences of that indicator. I have basically written in the scan somehing along this lines: IndOGMarket(4,65)>2 Thank you | |
^ Top | ||
Jim Dean![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | The value that the indicator plots must be Returned also. #Indicator Dim myval as single Myval = SMA(6) Plotprice("SMA",myval) Return myval | |
^ Top | ||
Duxx![]() Posts: 881 Joined: 2/18/2009 ![]() | Hello Jim, I think I have it that way: #Indicator #param "CurrATRpds", 15 #param "HistATRpds", 660 Dim RatioHistVol as Single If Symboldata.Numrec - 1 < HistATRpds then RatioHistVol = ATR(CurrATRpds) / ATR(Symboldata.Numrec - 1) Else RatioHistVol = ATR(CurrATRpds) / ATR(HistATRpds) End If Plot( "HistVol", RatioHistVol ) PlotLabel(2) Return RatioHistVol | |
^ Top | ||
Jim Dean![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | Use "bar" instead of symboldata.numrec-1 | |
^ Top | ||
Duxx![]() Posts: 881 Joined: 2/18/2009 ![]() | Hi Jim Strangely, still giving me a zero after the change to bar. But Im sure there are many stocks that can be scan with that indicator. Thx | |
^ Top | ||
Jim Dean![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | Post your revised code please. | |
^ Top | ||
Duxx![]() Posts: 881 Joined: 2/18/2009 ![]() | Hi Jim I think I made a mistake but not on my computer right now to test. I left the -1 after bar - I should have just input bar - will test and post again once I get to the computer. Thank you Jim Here is what I input last night: #Indicator #param "CurrATRpds", 15 #param "HistATRpds", 660 Dim RatioHistVol as Single If bar - 1 < HistATRpds then RatioHistVol = ATR(CurrATRpds) / ATR(bar - 1) Else RatioHistVol = ATR(CurrATRpds) / ATR(HistATRpds) End If Plot( "HistVol", RatioHistVol ) PlotLabel(2) Return RatioHistVol | |
^ Top | ||
Jim Dean![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | Remove both -1's. And also wrap the whole thing in If bar > curratrpds then … stuff End if | |
^ Top | ||
Duxx![]() Posts: 881 Joined: 2/18/2009 ![]() | Hi Jim I erased the -1 Not sure I understand what you mean to wrap up the whole thing - Do you mean this? Thank you for bearing with me #Indicator #param "CurrATRpds", 15 #param "HistATRpds", 660 Dim RatioHistVol as Single If bar < HistATRpds then RatioHistVol = ATR(CurrATRpds) / ATR(bar) Else RatioHistVol = ATR(CurrATRpds) / ATR(HistATRpds) End If Plot( "HistVol", RatioHistVol ) PlotLabel(2) Return RatioHistVol | |
^ Top | ||
Jim Dean![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | Try this (not tested, from iPhone): #Indicator #param "CurrATRpds", 15 #param "HistATRpds", 660 Dim RatioHistVol as Single If bar >= CurrATRpds then If bar < HistATRpds then RatioHistVol = ATR(CurrATRpds) / ATR(bar) Else RatioHistVol = ATR(CurrATRpds) / ATR(HistATRpds) End If Plot( "HistVol", RatioHistVol ) PlotLabel(2) End if Return RatioHistVol | |
^ Top | ||
Duxx![]() Posts: 881 Joined: 2/18/2009 ![]() | Hi Jim, It continue to show zero on the scan. ![]() | |
^ Top | ||
Jim Dean![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | Check the value being used, by assigning that function to a custom focus list column. There was an issue reported quite a while ago, where OScan was improperly interpreting some OLang functions. I *thot* it had been fixed. Try using the "US Stocks" list for the scan. If your FL column shows a value for any symbols that is <= 1.5, and the scan does not show those symbols, you need to snapshot both screens, and bundle them with your code in a bug report. Also it would probably be useful to show a few snaps of charts of symbols for which the plot shows <= 1.5 but the symbol does not show up in the scan. | |
^ Top | ||
Duxx![]() Posts: 881 Joined: 2/18/2009 ![]() | Thank you Jim I posted them into the tech support folder. Have a nice weekend | |
^ Top | ||
![]() This accout has been deleted | I have a custom indicator that I want to use in an omniscan. What is the correct syntax? myIndicator()? myIndicator(Return)? myIndicator(variable)? | |
^ Top | ||
Jim Dean![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | Myindicator(Param,param,…) depending on how many #param stmts your Indic has. It will return the Return value to the script. If your Indic has no param's then use () | |
^ Top | ||
THOMAS HELGET![]() Posts: 610 Joined: 3/22/2006 Location: BALDWINSVILLE, NEW YORK ![]() | Don: In the OmniScan you also have to provide some sort of Boolean information in relation to the values the Indicator is "Return"ing (usually that last line in your Indicator) such as: MyIndicator(Param, Param, ....) > 5 Or MyIndicator() = 7 I hope that further clarifies things. Tom Helget | |
^ Top | ||
Jim Dean![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | Tom is correct that is the "normal" way for a scan to be structured. However, if the Return value from the called function is itself a true/false flag, no other Boolean operators or syntax are needed. That is, if myindicator() returns 0, it is interpreted as "false" … if it returns -1 (or any other nonzero value), it is interpreted as "true". Or you can combine it (as a T/F value) with other logical conditions, such as: myindicator() And Sma(V,50) > 1e5 Click here for a pretty extensive explanation about how and why the zero and nonzero answers are treated as false and true, plus a bunch of other interesting (to some people :-) factoids regarding Boolean math in OLang and OScript. |