Close() returning zeros C++

How to create strategies and indicators
Message
Author
George
Posts: 4
Joined: Mon Sep 09, 2013 9:35 am

Close() returning zeros C++

#1 Postby George » Mon Sep 09, 2013 9:40 am

I am sure I am doing something wrong here and I am hoping that the community can help correct my error. The Close function is returning zeros instead of a value. Here is my code:

#include <windows.h>
#include "StrategyInterfaceUnit.h"
#include "TechnicalFunctions.h"
#include <iostream>
using namespace std;

PChar Currency = NULL;
int Timeframe;

EXPORT void __stdcall InitStrategy()
{
StrategyShortName("Test");
StrategyDescription("Test");

RegOption("Currency", ot_Currency, &Currency);

RegOption("Timeframe", ot_TimeFrame, &Timeframe);
Timeframe = PERIOD_M15;
}

EXPORT void __stdcall DoneStrategy()
{
free(Currency);
}

EXPORT void __stdcall ResetStrategy()
{}

EXPORT void __stdcall GetSingleTick()
{
int index = 0;

// retrieve current values
double b = Bid();
double c = Close(index);

// initialize buffers
char buffer[50] = { '\0' };
char buffer1[50] = { '\0' };

// display bid
sprintf(buffer, "bid value : %.4f", b);
Print(buffer);

// display cost
sprintf(buffer, "close value : %.4f", c);
Print(buffer1);
}

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

#2 Postby FX Helper » Mon Sep 09, 2013 10:03 am

Hello,

At first you need to call SetCurrencyTimeFrame function, and call Close function only after this.

George
Posts: 4
Joined: Mon Sep 09, 2013 9:35 am

#3 Postby George » Mon Sep 09, 2013 10:41 am

Thank You :D


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 14 guests