Forex Tester Forum (Professional Training Software for Traders) Forum Index Forex Tester Forum (Professional Training Software for Traders)

Back to main site   Risk disclosure
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Let me know how to use the TimeCurrent() function

 
Post new topic   Reply to topic    Forex Tester Forum (Professional Training Software for Traders) Forum Index -> Indicators
View previous topic :: View next topic  
Author Message
Atsushi



Joined: 23 Apr 2012
Posts: 4

PostPosted: Mon Apr 23, 2012 11:09 am    Post subject: Let me know how to use the TimeCurrent() function Reply with quote

Hi,
I have to create a indicator by C++ Language.
I have been troubled for execution error occurs when using the TimeCurrent() function.

I was testing with the following sample code.
Result of checking the logs from Print() function, I'm sure that Time() function is executed without any problems.
And Pop-up message is displayed when executed the TimeCurrent() function.
Please check the following sample code and Screen Shot.

Let me know how to use the TimeCurrent() function.
Do I need to obtain the latest version of the "IndicatorInterfaceUnit.h"?
Code:
  EXPORT void __stdcall Calculate(int pIndex) {
     char    WorkText[100];

     if (pIndex == 0) {
        sprintf(WorkText, "Time(pIndex)=%f", Time(pIndex));
        Print(WorkText);

        sprintf(WorkText, "TimeCurrent()=%f", TimeCurrent());
        Print(WorkText);
     }
  }



[My development environment]
Windows 7 Home Edition Premiun (Service Pack 1) 64Bit
Microsoft Visual C++ 2010 Express (Version 10.0.40219.1 SP1Rel)


[Forex Tester environment(C++)]
TechnicalFunctions.h (2011/02/10 23:23)
IndicatorInterfaceUnit.h (2011/08/27 09:02)
Code:
  I was fixing the bug in IndicatorInterfaceUnit.h.
  ###Before###
  1678:  //-----Delete all objects------------------------------------------------------
  1679:  void ObjectsDeleteAll(int window = 0, TObjectType ObjType = obj_AnyObject)

  ###After###
  1678:  //-----Delete all objects------------------------------------------------------
  1679:  void ObjectsDeleteAll(int window, TObjectType ObjType)



ScrenShot.jpg
 Description:
Error Popup Message
 Filesize:  227.68 KB
 Viewed:  6786 Time(s)

ScrenShot.jpg


Back to top
View user's profile Send private message
Atsushi



Joined: 23 Apr 2012
Posts: 4

PostPosted: Sun Apr 29, 2012 5:54 am    Post subject: Reply with quote

Please help me who have programming skills.
Could you show me your sample code.

I think I should move to "Programming lessons Forum" this question.
But, I couldn't find operation for "Forum change".

Atsushi
Back to top
View user's profile Send private message
Stonev



Joined: 28 Jan 2010
Posts: 103

PostPosted: Sun Apr 29, 2012 6:05 am    Post subject: Reply with quote

Hi,
not sure about C++
I use TimeToStr function in Delphi to show time variable value:

Code:
  Print ('Current Time: '+TimeToStr (TimeCurrent()));

_________________
Coding & Converting
Back to top
View user's profile Send private message Send e-mail
Atsushi



Joined: 23 Apr 2012
Posts: 4

PostPosted: Sun Apr 29, 2012 10:20 am    Post subject: Reply with quote

Hi, Stonev.
Thank you for your reply.

I was able to understand that you can use the TimeCurrent() function in Delphi.
I believe TimeCurrent() function is also available in C++.

I think there is some problem in my environment(Include files).
However, I can create the indicator that don't use the TimeCurrent() function.


Anyone,
Please show me your "Include Files" and "C++ Sample Code".


Atsushi
Back to top
View user's profile Send private message
Stonev



Joined: 28 Jan 2010
Posts: 103

PostPosted: Sun Apr 29, 2012 1:27 pm    Post subject: Reply with quote

uses you mean?

Code:
uses
  SysUtils,
  classes,
  graphics,
  IndicatorInterfaceUnit,
  TechnicalFunctions;

_________________
Coding & Converting
Back to top
View user's profile Send private message Send e-mail
KelvinHand



Joined: 02 Jan 2011
Posts: 91

PostPosted: Thu May 10, 2012 2:23 am    Post subject: Reply with quote

Atsushi wrote:
Please help me who have programming skills.
Could you show me your sample code.

I think I should move to "Programming lessons Forum" this question.
But, I couldn't find operation for "Forum change".

Atsushi



I don't see any crash problem both release n debug builds in MS VC 2010 express.

Only issue i had is i dont see any Print() out.

Sample Code.
Code:

//---------------------------------------------------------------------------
// Forex Tester 2 Inside Bar C++ Example Provided by Wessel
//---------------------------------------------------------------------------

#include <windows.h>

#include "IndicatorInterfaceUnit.h"
#include "TechnicalFunctions.h"

#define   EMPTY_VALUE     0

// External variables
int insideBarSymbol = 225,
   insideBarX = 0,
    insideBarY = -10;

// Buffers
TIndexBuffer insideBarIndex;

//---------------------------------------------------------------------------
// Initialize indicator
//---------------------------------------------------------------------------
EXPORT void __stdcall Init()
{
  // define properties
  IndicatorShortName("Inside Bar");
  SetOutputWindow(ow_ChartWindow);
  SetEmptyValue(EMPTY_VALUE);

  // register options
  AddSeparator("Inside Bar, Coded by WesseldR v1.0 Feb2011");
  AddSeparator("Inside Bar Parameters");

  RegOption("Inside Bar Symbol", ot_Integer, &insideBarSymbol);
  SetOptionRange("Inside Bar Symbol", 1, 256);
 
  RegOption("Inside Bar X-offset", ot_Integer, &insideBarX);
  SetOptionRange("Inside Bar X-offset", -MaxInt, MaxInt);

  RegOption("Inside Bar Y-offset", ot_Integer, &insideBarY);
  SetOptionRange("Inside Bar Y-offset", -MaxInt, MaxInt);
 
  // create buffers
  insideBarIndex = CreateIndexBuffer();
 
 
  IndicatorBuffers(1);
 
  SetIndexBuffer(0, insideBarIndex);
  SetIndexStyle(0, ds_Symbol, psSolid, 1, clYellow);
  SetIndexSymbol(0, insideBarSymbol,insideBarX,insideBarY);
  SetIndexLabel(0, "Inside Bar");
}

EXPORT void __stdcall OnParamsChange()
{
   SetIndexSymbol(0,insideBarSymbol,insideBarX,insideBarY);
}

//---------------------------------------------------------------------------
// Calculate requested bar
//---------------------------------------------------------------------------
EXPORT void __stdcall Calculate(int index)
{

 char    WorkText[100];


   //if(index == 0) // We only pick completed bars
   {

      sprintf(WorkText, "Time(pIndex)=%f", Time(index));
        Print(WorkText);

        sprintf(WorkText, "TimeCurrent()=%f", TimeCurrent());
        Print(WorkText);
      //return;
   }
   double myLow = Low( index );
   double myHigh = High( index );

   if( Low(index+1) < myLow && High(index+1) > myHigh){      
      insideBarIndex[ index ] = myLow;
   } else {
      insideBarIndex[ index ] = EMPTY_VALUE;   // We do this in case we want tick by tick indication
   }
}

Back to top
View user's profile Send private message
Atsushi



Joined: 23 Apr 2012
Posts: 4

PostPosted: Wed May 16, 2012 2:33 am    Post subject: Reply with quote

Hi KelvinHand.

Thanks your Sample Code.
And You gave me the big hint about this problem.

I was sure that there is some problem in "IndicatorInterfaceUnit.h".
Because I hear that You were not able to perform the TimeCurrent() & Print().

I found the problem in "IndicatorInterfaceUnit.h".

Code:

I was fixing the bug in IndicatorInterfaceUnit.h.
###Before###
//-----Get current time-------------------------------------------------------
TDateTime TimeCurrent()
{
  if (IntrfProcsRec.TimeCurrent = NULL) return 0;
  return IntrfProcsRec.TimeCurrent(IntrfProcsRec.pTimeCurrent);
}

###After###
//-----Get current time-------------------------------------------------------
TDateTime TimeCurrent()
{
  //if (IntrfProcsRec.TimeCurrent = NULL) return 0;
  return IntrfProcsRec.TimeCurrent(IntrfProcsRec.pTimeCurrent);
}
Back to top
View user's profile Send private message
KelvinHand



Joined: 02 Jan 2011
Posts: 91

PostPosted: Wed May 16, 2012 3:43 pm    Post subject: Reply with quote

Atsushi wrote:
Hi KelvinHand.

Thanks your Sample Code.
And You gave me the big hint about this problem.

I was sure that there is some problem in "IndicatorInterfaceUnit.h".
Because I hear that You were not able to perform the TimeCurrent() & Print().

I found the problem in "IndicatorInterfaceUnit.h".




Fantastic !!! You found bugs in FT2.
Salute You.
Back to top
View user's profile Send private message
FT Support



Joined: 11 Jul 2009
Posts: 902

PostPosted: Fri May 18, 2012 1:19 pm    Post subject: Reply with quote

Guys,

Thank you for your notes, i think that it should be changed to:

Code:

TDateTime TimeCurrent()
{
  if (IntrfProcsRec.TimeCurrent == NULL) return 0;
  return IntrfProcsRec.TimeCurrent(IntrfProcsRec.pTimeCurrent);
}



(i replaced "=" with "==")

_________________
Check our other products here:
www.fx-metropolis.com
www.forexcopier.com
Back to top
View user's profile Send private message Visit poster's website
Robopip



Joined: 21 Jun 2012
Posts: 24

PostPosted: Sun Sep 23, 2012 11:22 pm    Post subject: Reply with quote

This is still not fixed in version 2.9.3. Embarassed

These changes needs also to be done in strategyinterfaceunit.h
EXPORT void __stdcall ReplaceStr(PChar& dest, PChar source)
{
free((void *)dest);
dest = (PChar)malloc(strlen((char*)source) + 1);
strcpy(dest, source);
Change to:
strcpy_s(dest, strlen((char*)source) + 1, source);
}


int CreateIndicator(PChar Symbol, int TimeFrame, PChar IndicatorName, PChar parameters)
{
if (IntrfProcsRec.pCreateIndicator == NULL) return 0;

PChar IndicatorNameEx = (PChar)malloc(strlen(IndicatorName) + 4 + 1);
strcpy(IndicatorNameEx, IndicatorName);
strcat(IndicatorNameEx, ".dll");

Change to:
strcpy_s(IndicatorNameEx, strlen(IndicatorName) + 4 + 1, IndicatorName);
strcat_s(IndicatorNameEx, strlen(IndicatorName) + 4 + 1, ".dll");

return rec.CreateIndicator(rec.pCreateIndicator, Symbol, TimeFrame,
IndicatorNameEx, parameters);

free(IndicatorNameEx);
}
Back to top
View user's profile Send private message
Terranin
Site Admin


Joined: 21 Oct 2006
Posts: 831

PostPosted: Thu Oct 11, 2012 7:34 pm    Post subject: Reply with quote

What is wrong with this code?
_________________
Hasta la vista
Mike
Back to top
View user's profile Send private message
Robopip



Joined: 21 Jun 2012
Posts: 24

PostPosted: Thu Oct 11, 2012 9:15 pm    Post subject: Reply with quote

Terranin wrote:
What is wrong with this code?


If you mean "strcpy", you will get a warning when compiling in Visual Studio.
By changing strcpy to strcpy_s (="safe"), you will suppress warnings.

If you mean "if (IntrfProcsRec.TimeCurrent = NULL) return 0; "
It means that IntrfProcsRec.TimeCurrent is always set to NULL.

By changing to "if (IntrfProcsRec.TimeCurrent == NULL) return 0; "
It means that if IntrfProcsRec.TimeCurrent is NULL then return 0
Back to top
View user's profile Send private message
Steven Smith



Joined: 17 Jan 2013
Posts: 7
Location: USA

PostPosted: Thu Jan 17, 2013 7:02 am    Post subject: Reply with quote

I agree and i was able to understand that you can use the TimeCurrent() function in Delphi.
I believe TimeCurrent() function is also available in C++.
You should be try it once.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Forex Tester Forum (Professional Training Software for Traders) Forum Index -> Indicators All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group