Hi,
I have coded this simple indicator. This displays fine in the history mode however, in the testing mode the indicator is displayed correctly for the loaded days but for the replayed bars it just keeps repeating the last value (as if the index variable is not updated). What is wrong?
Thanks
//---------------------------------------------------------------------------
// Test
//---------------------------------------------------------------------------
#include <windows.h>
#include "IndicatorInterfaceUnit.h"
#include "TechnicalFunctions.h"
#include <stdio.h>
#include <string>
#include <iostream>
#include <fstream>
// External variables
int iOption;
// Buffers
TIndexBuffer iAmirNTest;
//---------------------------------------------------------------------------
// Initialize indicator
//---------------------------------------------------------------------------
EXPORT void __stdcall Init()
{
// define properties
IndicatorShortName("Test");
SetOutputWindow(ow_SeparateWindow );
// register options
AddSeparator("Common");
RegOption("No Option", ot_Integer, &iOption);
SetOptionRange("No Range", 1, MaxInt);
iOption = 0;
// create buffers
iAmirNTest = CreateIndexBuffer();
IndicatorBuffers(1);
SetIndexBuffer(0, iAmirNTest);
SetIndexStyle(0, ds_Line, psSolid, 2, clRed);
SetIndexLabel(0, "Test");
}
//---------------------------------------------------------------------------
EXPORT void __stdcall OnParamsChange()
{
}
//---------------------------------------------------------------------------
// Calculate requested bar
//---------------------------------------------------------------------------
EXPORT void __stdcall Calculate(int index)
{
if (index%10)
iAmirNTest[index] = 100;
else
iAmirNTest[index] = 50;
}
indicator not replaying correctly
-
- Posts: 7
- Joined: Tue Feb 24, 2015 4:56 am
Re: indicator not replaying correctly
Any response?
I need to get this one working ASAP. As I am a new user I need to make sure if this software is for me.
Thanks
I need to get this one working ASAP. As I am a new user I need to make sure if this software is for me.
Thanks
-
- Posts: 7
- Joined: Tue Feb 24, 2015 4:56 am
Re: indicator not replaying correctly
I have done it in Delphi as well and I am getting the same problem:
library test1;
uses
SysUtils, classes, graphics, windows, IndicatorInterfaceUnit;
var
// Buffers
iAmirNTest: TIndexBuffer;
//---------------------------------------------------------------------------
// Initialize indicator
//---------------------------------------------------------------------------
procedure Init; stdcall;
begin
// define properties
IndicatorShortName('Test');
SetOutputWindow(ow_SeparateWindow);
// create buffers
iAmirNTest := CreateIndexBuffer;
IndicatorBuffers(1);
SetIndexBuffer(0, iAmirNTest);
SetIndexStyle(0, ds_line, psSolid, 2, RGB($1E, $90, $FF));
SetIndexLabel(0, 'Test');
end;
//---------------------------------------------------------------------------
// Deinitialize indicator
//---------------------------------------------------------------------------
procedure Done; stdcall;
begin
end;
//---------------------------------------------------------------------------
// Calculate requested bar
//---------------------------------------------------------------------------
procedure Calculate(index: integer); stdcall;
begin
if (index mod 10) = 0 then
iAmirNTest[index] := 100
else
iAmirNTest[index] := 50;
end;
exports
Init, Done, Calculate;
end.
library test1;
uses
SysUtils, classes, graphics, windows, IndicatorInterfaceUnit;
var
// Buffers
iAmirNTest: TIndexBuffer;
//---------------------------------------------------------------------------
// Initialize indicator
//---------------------------------------------------------------------------
procedure Init; stdcall;
begin
// define properties
IndicatorShortName('Test');
SetOutputWindow(ow_SeparateWindow);
// create buffers
iAmirNTest := CreateIndexBuffer;
IndicatorBuffers(1);
SetIndexBuffer(0, iAmirNTest);
SetIndexStyle(0, ds_line, psSolid, 2, RGB($1E, $90, $FF));
SetIndexLabel(0, 'Test');
end;
//---------------------------------------------------------------------------
// Deinitialize indicator
//---------------------------------------------------------------------------
procedure Done; stdcall;
begin
end;
//---------------------------------------------------------------------------
// Calculate requested bar
//---------------------------------------------------------------------------
procedure Calculate(index: integer); stdcall;
begin
if (index mod 10) = 0 then
iAmirNTest[index] := 100
else
iAmirNTest[index] := 50;
end;
exports
Init, Done, Calculate;
end.
-
- Posts: 1479
- Joined: Mon Apr 01, 2013 3:55 am
Re: indicator not replaying correctly
Hello,
You have this issue because during testing current bar always has index 0.
So your "if (index mod 10) = 0" will always be true and you will always see value=100 in testing.
Do I understand correctly that you want to show value=100 for every tenth bar? In this case you need to use another verification for tenth bar.
You have this issue because during testing current bar always has index 0.
So your "if (index mod 10) = 0" will always be true and you will always see value=100 in testing.
Do I understand correctly that you want to show value=100 for every tenth bar? In this case you need to use another verification for tenth bar.
-
- Posts: 7
- Joined: Tue Feb 24, 2015 4:56 am
Re: indicator not replaying correctly
Hi,
I have sent you an email, in essence what I require is how to found out the bar number currently printing in the testing mode.
Regard
I have sent you an email, in essence what I require is how to found out the bar number currently printing in the testing mode.
Regard
-
- Posts: 1479
- Joined: Mon Apr 01, 2013 3:55 am
Re: indicator not replaying correctly
Hello,
Currently printing bar number has index 0. Previous bar has index 1, and so on.
Currently printing bar number has index 0. Previous bar has index 1, and so on.
-
- Posts: 7
- Joined: Tue Feb 24, 2015 4:56 am
Re: indicator not replaying correctly
So how could I use this information to find out what is the current bar number printing from the beginning of data file.
In the history mode the current bar number is (Bars() -1 - index) what is it in the testing mode?
Regards
In the history mode the current bar number is (Bars() -1 - index) what is it in the testing mode?
Regards
-
- Posts: 1479
- Joined: Mon Apr 01, 2013 3:55 am
Re: indicator not replaying correctly
Hello,
In Testing Mode current bar has index 0. When new bar appears, this bar will have index 1 and so on.
In Testing Mode current bar has index 0. When new bar appears, this bar will have index 1 and so on.
Who is online
Users browsing this forum: No registered users and 13 guests