[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Metastock List: Developers, help me please !



PureBytes Links

Trading Reference Links

subscribe metastock  analyst@xxxxxxxxx

Dear Sirs,
I can't build this code (the red one at the end of the following list) in
Powerbasic .bas format
Can you help me please?
Thanks a lot

 Mark

-----------------------------------------------------------------------

#COMPILE DLL
OPTION EXPLICIT
#INCLUDE "WIN32API.INC"
#INCLUDE "MSXStruc.BAS"

FUNCTION DllMain(BYVAL hInstance   AS LONG, _
                 BYVAL fwdReason   AS LONG, _
                 BYVAL lpvReserved AS LONG) EXPORT AS LONG

 LOCAL l_bRtrn AS LONG

  SELECT CASE fwdReason
    CASE %DLL_PROCESS_ATTACH
        l_bRtrn = %TRUE
    CASE %DLL_PROCESS_DETACH
        l_bRtrn = %TRUE
    CASE ELSE
        l_bRtrn = %FALSE
  END SELECT
  DllMain = l_bRtrn
END FUNCTION

FUNCTION MSXInfo SDECL ALIAS "MSXInfo" (a_psDLLDef AS MSXDLLDef PTR) _
    EXPORT AS LONG
  @a_psDLLDef.szCopyright =  "Copyright (c) 2001 Financial Systems Srl -
Tutti i diritti riservati"
  @a_psDLLDef.iNFuncs = 1
  @a_psDLLDef.iVersion = %MSX_VERSION
  MSXInfo = %MSX_SUCCESS
END FUNCTION

FUNCTION MSXNthFunction SDECL ALIAS "MSXNthFunction" (BYVAL a_iNthFunc AS
LONG, _
a_psFuncDef AS MSXFuncDef PTR) EXPORT AS LONG

  MSXNthFunction = %MSX_SUCCESS

  SELECT CASE a_iNthFunc
  CASE 0
    @a_psFuncDef.szFunctionName = "Sample"
    @a_psFuncDef.szFunctionDescription = "Sample"
    @a_psFuncDef.iNArguments = 0
 CASE ELSE
    MSXNthFunction = %MSX_ERROR
  END SELECT
END FUNCTION

FUNCTION ForceFloatRange (BYVAL a_lfDbl AS DOUBLE) AS DOUBLE
    LOCAL s_MaxSingle AS DOUBLE
    LOCAL s_MinSingle AS DOUBLE

    s_MaxSingle = 3.371E+38
    s_MinSingle = 8.431E-37

    IF a_lfDbl > 0.0 THEN
       a_lfDbl = MIN (a_lfDbl, s_MaxSingle) ' force pos num <= s_MaxSingle
       a_lfDbl = MAX (a_lfDbl, s_MinSingle) ' force pos num >= s_MinSingle
    ELSE
       IF a_lfDbl < 0.0 THEN
          a_lfDbl = MAX (a_lfDbl, -s_MaxSingle) ' force neg num
>= -s_MaxSingle
          a_lfDbl = MIN (a_lfDbl, -s_MinSingle) ' force neg num
<= -s_MinSingle
       END IF
    END IF
    ForceFloatRange = a_lfDbl
END FUNCTION

FUNCTION Sample SDECL ALIAS "Sample" _
         (a_psDataRec AS MSXDataRec PTR, _
          a_psDataInfoArgs AS MSXDataInfoRecArgsArray PTR, _
          a_psNumericArgs AS MSXNumericArgsArray PTR, _
          a_psStringArgs AS MSXStringArgsArray PTR, _
          a_psCustomArgs AS MSXCustomArgsArray PTR, _
          a_psResultRec AS MSXResultRec PTR) EXPORT AS LONG

  LOCAL l_iFirst AS INTEGER
  LOCAL l_iLast AS INTEGER
  LOCAL l_Op AS INTEGER
  LOCAL l_OpM AS INTEGER
  LOCAL l_PvH1 AS INTEGER
  LOCAL l_bRtrn AS LONG

  l_bRtrn = %MSX_SUCCESS
'---------------------------------------------------------------------------
----------------------
'My function in Metastock Format is:
'Op:=If(DayOfMonth()<=Ref(DayOfMonth(),-1),OPEN,0);
'OpM:=ValueWhen(1,Op>0,Op);
'PvH1:=
'If(DayOfWeek()<>Ref(DayOfWeek(),-1),If(Ref(DayOfWeek(),-1)<>Ref(DayOfWeek()
,-2),OpM*2, OpM*3),0);
'---------------------------------------------------------------------------
----------------------

Sample = l_bRtrn

END FUNCTION