Stochastic K returning constant value and Terminal stuck

Bug reports and errors in the program
Message
Author
geodepe
Posts: 5
Joined: Sat Sep 22, 2012 2:22 pm
Location: United States

Stochastic K returning constant value and Terminal stuck

#1 Postby geodepe » Sun Oct 21, 2012 4:29 pm

Hello,
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);
   }   
}


FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#2 Postby FT Support » Mon Oct 22, 2012 9:49 am

Can you please send us the screenshot of the output which you see (Journal tab of the terminal window)?
Check our other product here:
http://www.forexcopier.com

geodepe
Posts: 5
Joined: Sat Sep 22, 2012 2:22 pm
Location: United States

Stochastic K returning constant value and Terminal stuck

#3 Postby geodepe » Mon Oct 22, 2012 10:05 am

Here is screenshot.
Attachments
Drawing1.jpg
Drawing1.jpg (227.1 KiB) Viewed 19537 times

geodepe
Posts: 5
Joined: Sat Sep 22, 2012 2:22 pm
Location: United States

#4 Postby geodepe » Thu Oct 25, 2012 2:14 pm

Has anybody looked at this yet?

Phil_Trade
Posts: 94
Joined: Tue Jan 31, 2012 5:14 am
Contact:

#5 Postby Phil_Trade » Fri Oct 26, 2012 1:51 pm

geodepe wrote:Has anybody looked at this yet?


there's a mistake in help. I'm using thsi buffer to have good result

Const
Stoch_Slow_Buffer = 2;
Stoch_Fast_Buffer = 1;
my live account - 8 based pairs with optimized parameters : +188%
http://www.myfxbook.com/members/Philipp ... jpg/519044
TradeSlide : http://bit.ly/14R9Nf6

to be informed about Windev/MT4 services : a04486-tradingsignal@yahoo.fr

geodepe
Posts: 5
Joined: Sat Sep 22, 2012 2:22 pm
Location: United States

#6 Postby geodepe » Fri Oct 26, 2012 2:06 pm

Thanks Philippe ... but I don't understand what you are saying about those constants or the help.

Phil_Trade
Posts: 94
Joined: Tue Jan 31, 2012 5:14 am
Contact:

#7 Postby Phil_Trade » Fri Oct 26, 2012 3:14 pm

geodepe wrote:Thanks Philippe ... but I don't understand what you are saying about those constants or the help.


just use 2 for SlowLine Buffer and 1 for FastLine Buffer for stoch indicator
my live account - 8 based pairs with optimized parameters : +188%

http://www.myfxbook.com/members/Philipp ... jpg/519044

TradeSlide : http://bit.ly/14R9Nf6



to be informed about Windev/MT4 services : a04486-tradingsignal@yahoo.fr

User avatar
alicerite
Posts: 1
Joined: Wed Jan 09, 2013 3:52 pm

#8 Postby alicerite » Wed Jan 09, 2013 3:56 pm

Has anyone looked at just this but?
Alice Write

KelvinHand
Posts: 103
Joined: Sun Jan 02, 2011 6:05 pm

#9 Postby KelvinHand » Thu Jan 10, 2013 1:02 am

alicerite wrote:Has anyone looked at just this but?


This should be workable

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;Low/High");
}

EXPORT void __stdcall GetSingleTick()
{
   double StoK, StoKPrev, StoD, 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, 0, 1);
   StoKPrev =  GetIndicatorValue(IndStochastic, 1, 1);

   StoD =      GetIndicatorValue(IndStochastic, 0, 2);
   StoDPrev =  GetIndicatorValue(IndStochastic, 1, 2);

   
     sprintf(WorkText, "StoK=%f, StoKPrev=%f, StoD=%f, StoDPrev=%f", StoK,StoKPrev,StoD,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);
   }   
}




== STRATEGY.DEF ==

Code: Select all

LIBRARY

EXPORTS
  InitStrategy
  DoneStrategy
  ResetStrategy
  GetSingleTick
  ReplaceStr
  IntrfProcsRec


It seen to be some error in the help guide of the functions for stochastic:
1. CreateIndicator() - should be "Low/High" not "High/Low";
during testing, the parameter will give "illigal value"

2. GetIndicatorValue()
- used buffer index 1 => %K slow buffer
- used buffer index 2 => D line buffer

The reason likely in the stochastic indicator coding:

Code: Select all


  SetEmptyValue(105);      //-- This 105 was to output Empty value

// create buffers
  Kfast := CreateIndexBuffer;     //----Buffer index 0
  Kslow := CreateIndexBuffer;    //----Buffer index 1
  Dline := CreateIndexBuffer;     //----Buffer index 2

  IndicatorBuffers(2);
  SetIndexBuffer(0, Kslow);       //----Buffer index 1 output to screen
  SetIndexBuffer(1, Dline);        //----Buffer index 2 output to screen

  SetIndexStyle(0, ds_line, psSolid, 1, clRed);
  SetIndexLabel(0, 'K Line');

  SetIndexStyle(1, ds_Line, psSolid, 1, RGB($1E, $90, $FF));
  SetIndexLabel(1, 'D Line');



Buffer index 0 may result to output 105 to tell you empty value

User avatar
Coretta
Posts: 10
Joined: Tue Oct 22, 2013 12:51 am
Location: China
Contact:

#10 Postby Coretta » Mon Dec 02, 2013 1:49 am

Complex things feel good, I have not encountered such a problem


Return to “Bug reports”

Who is online

Users browsing this forum: No registered users and 15 guests