the output from Print(buff2) is always 0. Can anyone help me, where the bug is?
I want to open a buy order, when Bid is greater than EMA 50 Close.
Code: Select all
#include "stdafx.h"
#include <stdlib.h>
#include <malloc.h>
#include "windows.h"
#include "StrategyInterfaceUnit.h"
#include "TechnicalFunctions.h"
#include <string.h>
#include <time.h>
#include <ctime>
PChar Currency = NULL;
int Timeframe;
int OrderHandle;
int IndMA;
double MaCurrent;
char buff2[200];
EXPORT void __stdcall InitStrategy()
{
StrategyShortName("ObjectsTest");
StrategyDescription("Test of moving objects");
RegOption("Currency", ot_Currency, &Currency);
RegOption("Timeframe", ot_TimeFrame, &Timeframe);
Timeframe = PERIOD_M5;
}
EXPORT void __stdcall DoneStrategy()
{
free(Currency);
}
EXPORT void __stdcall ResetStrategy()
{
char buff[1000];
sprintf(buff, "%d;0;0;%s;Close", 50, StrMAType(ma_EMA));
IndMA = CreateIndicator(Symbol(), 50, "MovingAverage", buff);
}
EXPORT void __stdcall GetSingleTick()
{
if (strcmp(Currency, Symbol()) != 0) return;
SetCurrencyAndTimeframe(Currency, Timeframe);
MaCurrent = GetIndicatorValue(IndMA, 0, 0);
sprintf(buff2, "%d",MaCurrent);
Print(buff2);
if(Bid() > MaCurrent)
{
}
}