Get Indicator in 5 Minute Timeframe

Examples step by step how to make your own automated strategy or user indicator
Posts: 1
Joined: Sun Dec 20, 2015 9:24 pm

Get Indicator in 5 Minute Timeframe

#1 Postby warsam9788 » Sun Dec 20, 2015 9:33 pm

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()
  StrategyDescription("Test of moving objects");

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

  RegOption("Timeframe", ot_TimeFrame, &Timeframe);
  Timeframe = PERIOD_M5;

EXPORT void __stdcall DoneStrategy()

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);


  if(Bid() > MaCurrent)

Return to “Programming lessons”

Who is online

Users browsing this forum: No registered users and 2 guests