Here is my hello world test with ForexTester 2.
Two problems found:
1) Stochastic K always returns 105.0000
2) Terminal output does not update correctly (need to physically move mouse over row output for it to change).
Please help ... code below.
Thanks
Code: Select all
#include <windows.h>
#include "StrategyInterfaceUnit.h"
#include "TechnicalFunctions.h"
#include <string.h>
PChar Currency = NULL;
int Timeframe;
EXPORT void __stdcall InitStrategy()
{
StrategyShortName("DemoStrategy Stochastic 1");
StrategyDescription("Demo Strategy Stochastic 1");
}
EXPORT void __stdcall DoneStrategy()
{
//free(Currency);
}
int IndStochastic;
EXPORT void __stdcall ResetStrategy()
{
IndStochastic = CreateIndicator("EURUSD",PERIOD_M15,"Stochastic","5;3;3;High/Low");
}
EXPORT void __stdcall GetSingleTick()
{
double StoK,StoKSlow,StoD;
double StoKPrev,StoKSlowPrev,StoDPrev;
int OrderHandle=0;
char WorkText[100];
if (strcmp("EURUSD", Symbol()) != 0) return;
sprintf(WorkText, "Running Symbol=%s", Symbol());
Print(WorkText);
//Current Values
StoK = GetIndicatorValue(IndStochastic, 1, 0);
StoKSlow = GetIndicatorValue(IndStochastic, 1, 1);
StoD = GetIndicatorValue(IndStochastic, 1, 2);
//Previous Values
StoKPrev = GetIndicatorValue(IndStochastic, 2, 0);
StoKSlowPrev = GetIndicatorValue(IndStochastic, 2, 1);
StoDPrev = GetIndicatorValue(IndStochastic, 2, 2);
sprintf(WorkText, "StoK=%f StoD=%f StoKPrev=%f StoDPrev=%f", StoK,StoD,StoKPrev,StoDPrev);
Print(WorkText);
if(StoK>StoD && StoKPrev<StoDPrev)
{
if(OrdersTotal()==0)
SendInstantOrder("EURUSD", op_Buy, 0.1,Bid()- 0.0015, Bid()+0.003, "Howdy BUY", 0, OrderHandle);
}
}