RegOption("TimeFrame", ..... behaviour in C++

How to create strategies and indicators
Message
Author
rgimen
Posts: 2
Joined: Thu Apr 24, 2008 8:00 am
Location: Bogotá - Colombia

RegOption("TimeFrame", ..... behaviour in C++

#1 Postby rgimen » Thu Apr 24, 2008 8:54 am

(Clarifying: I am not english-spanish bilingual, so please excuse my grammar and other mistakes)

Hi,

I am just trying to reproduce on C++ the "SimpleSMA Strategy" example writed on Delphi, and after that make my own improvements to this strategy. This because I have a little experience with C++ but not with Delphi.

When I run my C++ strategy I obtain results on the "Optimization properties" Tab showed on attached "Properties1.JPG" file, where on TimeFrame option the displayed value is "3" that it corresponds to the constant PERIOD_H1.

I want to reproduce the exact behaviour of the "Simple SMA Strategy" already instaled as example with the ForexTester application, which shows the image attached as "Properties2.JPG" file with PERIOD_H1 as displayed value.

This is my "partial" C++ source code (What´s wrong or missing?):

//--------------------------------------------------------------------------
// RGM C++ Test: Strategy based on 2 crossing SMA
//--------------------------------------------------------------------------

#include <windows.h>
#include "StrategyInterfaceUnit.h"
#include "TechnicalFunctions.h"
#include "Graphics.h"
#include "SimpleSMA.h"

// external parameters
PChar Currency = NULL;
int TimeFrame;
double LotSize;
int period1;
int period2;

// internal variables
int OrderHandle;
TTradePositionType OrderStyle;
TDateTime OpenTime;


//-----Init strategy----------------------------------------------------------
EXPORT void __stdcall InitStrategy()
{
StrategyShortName("RGM: Simple two SMA strategy");
StrategyDescription("RGM: Strategy based on 2 crossing SMA");

// Register external parameters
RegOption("Currency", ot_Currency, &Currency);
ReplaceStr(Currency, "EURUSD");

RegOption("TimeFrame", ot_Integer, &TimeFrame);
TimeFrame = PERIOD_H1;

RegOption("LotSize", ot_double, &LotSize);
SetOptionDigits("LotSize",1);
LotSize = 0.1;

RegOption("Period1", ot_Integer, &period1);
SetOptionRange("SMA1 Period",2,INT_MAX);
period1 = 16;

RegOption("Period2", ot_Integer, &period2);
SetOptionRange("SMA2 Period",2,INT_MAX);
period2 = 32;
}
...

Thanks in advance.
Attachments
Properties2.JPG
Original Delphi &quot;Simple SMA Strategy&quot; &quot;optimization properties&quot; tab.
Properties2.JPG (28.19 KiB) Viewed 8115 times
Properties1.JPG
My C++ &quot;Simple SMA Strategy&quot; &quot;optimization properties&quot; tab.
Properties1.JPG (27.29 KiB) Viewed 8115 times
Regards,

Richard Giménez Méndez

FinGeR
Posts: 72
Joined: Wed Apr 23, 2008 12:24 pm

#2 Postby FinGeR » Thu Apr 24, 2008 9:47 am

//--------------------------------------------------------------------------
// RGM C++ Test: Strategy based on 2 crossing SMA
//--------------------------------------------------------------------------

#include <windows.h>
#include "StrategyInterfaceUnit.h"
#include "TechnicalFunctions.h"
#include "Graphics.h"
#include "SimpleSMA.h"

// external parameters
PChar Currency = NULL;
int TimeFrame;
double LotSize;
int period1;
int period2;

// internal variables
int OrderHandle;
TTradePositionType OrderStyle;
TDateTime OpenTime;


//-----Init strategy----------------------------------------------------------
EXPORT void __stdcall InitStrategy()
{
StrategyShortName("RGM: Simple two SMA strategy");
StrategyDescription("RGM: Strategy based on 2 crossing SMA");

// Register external parameters
RegOption("Currency", ot_Currency, &Currency);
ReplaceStr(Currency, "EURUSD");

RegOption("TimeFrame", ot_TimeFrame, &TimeFrame);
TimeFrame = PERIOD_H1;

RegOption("LotSize", ot_double, &LotSize);
SetOptionDigits("LotSize",1);
LotSize = 0.1;

RegOption("Period1", ot_Integer, &period1);
SetOptionRange("SMA1 Period",2,INT_MAX);
period1 = 16;

RegOption("Period2", ot_Integer, &period2);
SetOptionRange("SMA2 Period",2,INT_MAX);
period2 = 32;
}
...


:)
Attachments
Capture_123.jpg
Capture_123.jpg (21.14 KiB) Viewed 8110 times

rgimen
Posts: 2
Joined: Thu Apr 24, 2008 8:00 am
Location: Bogotá - Colombia

#3 Postby rgimen » Thu Apr 24, 2008 10:44 am

Oops. A rookie´s mistake.

Thanks a lot. Now is working as expected.
Regards,



Richard Giménez Méndez


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 10 guests