Lesson 2. "No option avaible" problem

Examples step by step how to make your own automated strategy or user indicator
Message
Author
javierp
Posts: 8
Joined: Thu Apr 16, 2015 6:04 am

Lesson 2. "No option avaible" problem

#1 Postby javierp » Thu Apr 16, 2015 6:20 am

Hello

Lesson 2. Defining external parameters

I have load "Demostrategy.dll" c++ code (developed with CODE::BLOCK") whithout problems, but when I try to see the properties of the strategy , it doesn´t appear and the message "No option avaible" is displayed

The main C++ code I have used is:

#include <iostream>
#define DLL_EXPORT
#include <windows.h>
#include "FF2_lesson2.h"
#include "StrategyInterfaceUnit.h"
#include "TechnicalFunctions.h"

// Get rid of name mangeling
extern "C"

// external parameters
double Delta = 3.46;
int StopLoss = 20;
long Days = 7;
bool UseStopLoss = true;
int List = 0;
int timeframe = PERIOD_M15;
char* SomeInfo;
char* Currency;



DECLDIR void InitStrategy()
{
StrategyShortName("DemoStrategy");
StrategyDescription("Demo strategy that does nothing");
RegOption("Delta",ot_Double,&Delta);
SetOptionRange("Delta",0,100);
SetOptionDigits("Delta", 2);

RegOption("StopLoss", ot_Integer, &StopLoss);
RegOption("Days", ot_Longword, &Days);
RegOption("UseStopLoss", ot_Boolean, &UseStopLoss);

.....etc

May someone help me

Thanks

FX Helper
Posts: 957
Joined: Mon Apr 01, 2013 3:55 am

Re: Lesson 2. "No option avaible" problem

#2 Postby FX Helper » Thu Apr 16, 2015 7:24 am

Hello,

Can you please attach .dll file too so we can check if it works on our computers?

javierp
Posts: 8
Joined: Thu Apr 16, 2015 6:04 am

Re: Lesson 2. "No option avaible" problem

#3 Postby javierp » Thu Apr 16, 2015 9:15 am

Hello Fx Helper

It´s the first time I use this forum and I don´t know how to attach the DLL files

When I try to attach a file in the "Upload Attachement " window, I get the message :
"The extension xx is not allowed " (xx= ".h", ".txt", ".cpp")

So, I write the code bellow

Thanks in advance

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MAIN.CPP

#include <iostream>
#define DLL_EXPORT
#include <windows.h>
#include "FF2_lesson2.h"
#include "StrategyInterfaceUnit.h"
#include "TechnicalFunctions.h"

// Get rid of name mangeling
extern "C"

// external parameters
double Delta = 3.46;
int StopLoss = 20;
long Days = 7;
bool UseStopLoss = true;
int List = 0;
int timeframe = PERIOD_M15;
char* SomeInfo;
char* Currency;



DECLDIR void InitStrategy()
{
StrategyShortName("DemoStrategy");
StrategyDescription("Demo strategy that does nothing");
RegOption("Delta",ot_Double,&Delta);
SetOptionRange("Delta",0,100);
SetOptionDigits("Delta", 2);

RegOption("StopLoss", ot_Integer, &StopLoss);
RegOption("Days", ot_Longword, &Days);
RegOption("UseStopLoss", ot_Boolean, &UseStopLoss);

AddSeparator("Extra options");

RegOption("List", ot_EnumType, &List);
AddOptionValue("List", "string 1");
AddOptionValue("List", "string 2");
AddOptionValue("List", "string 3");
List = 1;

RegOption("Timeframe", ot_TimeFrame, &timeframe);

RegOption("SomeInfo", ot_String, &SomeInfo);
ReplaceStr(SomeInfo, "Information for user");
RegOption("Currency", ot_Currency, &Currency);
ReplaceStr(Currency, "EURUSD");
}

DECLDIR void DoneStrategy()
{
free(SomeInfo);
free(Currency);
}
DECLDIR void ResetStrategy()
{

}

DECLDIR void GetSingleTick()
{

}


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

FX_lesson2.h

// Inclusion guard
#ifndef _DLLTUT_DLL_H_
#define _DLLTUT_DLL_H_

// Make our life easier, if DLL_EXPORT is defined in a file
// then DECLDIR will do an export
// If it is not defined DECLDIR will do an import

#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif

// Specify "C" linkage to get rid of C++ name mangeling
extern "C"
{
// Declare 4 functions
DECLDIR void InitStrategy();
DECLDIR void DoneStrategy();
DECLDIR void ResetStrategy();
DECLDIR void GetSingleTick();

}

// End the inclusion guard
#endif

+++++++++++++++++++++++++++++++++++++++++++++++++++++
StrategyInterfaceUnit.h
TechnicalFunctions.h

are the same as in "C:\ForexTester2\Examples\Strategies\C++"


++++++++++++++++++++++++++++++++++++++++++++++++++++++
Thanks

javierp
Posts: 8
Joined: Thu Apr 16, 2015 6:04 am

Re: Lesson 2. "No option avaible" problem

#4 Postby javierp » Thu Apr 16, 2015 1:44 pm

Hi,

I try to attach the DLLs files in a compressed .rar format

Cheers
Attachments
FF2_Lesson2.rar
(12.21 KiB) Downloaded 245 times

javierp
Posts: 8
Joined: Thu Apr 16, 2015 6:04 am

Re: Lesson 2. "No option avaible" problem

#5 Postby javierp » Sat Apr 18, 2015 2:59 am

Hi FX HELPER

I am silly. I was using an old version of my own "Demostrategy.dll"

The code is working fine.

While trying solving the mistake, I´ve found these links that I think are of interest for the users of "MINGW compilers"

http://www.transmissionzero.co.uk/compu ... ith-mingw/
http://www.transmissionzero.co.uk/compu ... ll-topics/

Thanks for all

FX Helper
Posts: 957
Joined: Mon Apr 01, 2013 3:55 am

Re: Lesson 2. "No option avaible" problem

#6 Postby FX Helper » Tue Apr 21, 2015 8:37 am

Hello,

Yes, it seems that this strategy works properly. Thanks for the update.


Return to “Programming lessons”

Who is online

Users browsing this forum: No registered users and 3 guests