Forex Tester Forum (Professional Training Software for Traders) Forum Index Forex Tester Forum (Professional Training Software for Traders)

Back to main site   Risk disclosure
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to change color? (CreateIndicator / GetIndicator)

 
Post new topic   Reply to topic    Forex Tester Forum (Professional Training Software for Traders) Forum Index -> FT API
View previous topic :: View next topic  
Author Message
Gen



Joined: 21 Sep 2010
Posts: 14

PostPosted: Wed Sep 29, 2010 7:19 am    Post subject: How to change color? (CreateIndicator / GetIndicator) Reply with quote

Hi,

Is there any way that I can change the indicator line color in the strategy I create, especially when I use CreateIndicator / GetIndicator?
Back to top
View user's profile Send private message
FT Support



Joined: 11 Jul 2009
Posts: 902

PostPosted: Wed Sep 29, 2010 9:55 am    Post subject: Reply with quote

Hello,

Please use "SetIndicatorBuffStyle" procedure from Strategies API, see more information in Help -> Strategies API

_________________
Check our other products here:
www.fx-metropolis.com
www.forexcopier.com
Back to top
View user's profile Send private message Visit poster's website
Gen



Joined: 21 Sep 2010
Posts: 14

PostPosted: Thu Sep 30, 2010 7:23 am    Post subject: Reply with quote

Hi,

Can you please provide me some examples how you create the SetIndicatorBuffStyle procedure?

I tried to create it as below. The error came back saying, "HolyGrail.dpr(70,59) Error: Wrong number of parameters specified for call to "SetIndicatorBuffStyle"

Can you look into it?


{-----Reset strategy--------------------------------------------------------}
procedure ResetStrategy; stdcall;
begin
OrderHandle := -1;
handle1 := CreateIndicator(Currency, TimeFrame, 'MovingAverage', format('%d;0;0;%s;Close', [period1, StrMAType(ma_EMA)]));
handle2 := CreateIndicator(Currency, TimeFrame, 'MovingAverage', format('%d;0;0;%s;Close', [period2, StrMAType(ma_EMA)]));
handle3 := CreateIndicator(Currency, TimeFrame, 'PRSAR', '0.02;0.02;0.20');
end;

{-----Set Indicator Color--------------------------------------------------------}
procedure SetIndicatorBuffStyle; stdcall;
begin
SetIndicatorBuffStyle(handle1, 0, 'psSolid', 1, 'clblue');
end;
Back to top
View user's profile Send private message
FT Support



Joined: 11 Jul 2009
Posts: 902

PostPosted: Thu Sep 30, 2010 12:23 pm    Post subject: Reply with quote

Please see an example below:

Code:
SetIndicatorBuffStyle(handle1, 0, psSolid, 1, clBlue);


note that you need to add Graphics unit to uses.

_________________
Check our other products here:
www.fx-metropolis.com
www.forexcopier.com
Back to top
View user's profile Send private message Visit poster's website
Gen



Joined: 21 Sep 2010
Posts: 14

PostPosted: Fri Oct 01, 2010 9:06 am    Post subject: Reply with quote

Thanks.
With "Graphics", the problem resolved.
Back to top
View user's profile Send private message
Gen



Joined: 21 Sep 2010
Posts: 14

PostPosted: Wed Oct 20, 2010 9:23 am    Post subject: Reply with quote

I ran into another problem on color.
I cannot see the line colors I set in the different time frame.
From the Indicator list, it looks fine. But I can not see it in the chart.

Can you please tell me what causes this problem from my script below?

I have not use TimeFrame1 yet, FYI.

____________________________________________________________

//-------------------------------------------------------------------------
// Strategy based on EMA
//-------------------------------------------------------------------------
library EMAStrategy;

uses
Graphics, Interfaces, TechnicalFunctions, SysUtils, Classes, StrategyInterfaceUnit;

var
// External parameters
Currency: PChar = nil;
TimeFrame1: integer;
TimeFrame2: integer;
TimeFrame3: integer;
LotSize: double;
period1: integer;
period2: integer;
period3: integer;
handle1: integer;
handle2: integer;
handle3: integer;
handle4: integer;
handle5: integer;
handle6: integer;

// custom variables
OrderHandle: integer;
OrderStyle: TTradePositionType;
OpenTime: TDateTime;


{-----Init strategy---------------------------------------------------------}
procedure InitStrategy; stdcall;
begin
StrategyShortName('SimpleEMA');
StrategyDescription('Strategy based on EMA');

// Register external parameters
RegOption('Currency', ot_Currency, Currency);
ReplaceStr(Currency, 'EURUSD');

RegOption('Timeframe1', ot_Timeframe, TimeFrame1);
TimeFrame1 := 5;

RegOption('Timeframe2', ot_Timeframe, TimeFrame2);
TimeFrame2 := 30;

RegOption('Timeframe3', ot_Timeframe, TimeFrame3);
TimeFrame3 := 240;

RegOption('LotSize', ot_Double, LotSize);
SetOptionDigits('LotSize', 1);
lotSize := 0.1;

RegOption('EMA1 period', ot_Integer, period1);
SetOptionRange('EMA1 period', 2, MaxInt);
period1 := 13;

RegOption('EMA2 period', ot_Integer, period2);
SetOptionRange('EMA2 period', 2, MaxInt);
period2 := 86;

RegOption('EMA3 period', ot_Integer, period3);
SetOptionRange('EMA3 period', 2, MaxInt);
period3 := 233;
end;

{-----Done strategy---------------------------------------------------------}
procedure DoneStrategy; stdcall;
begin
FreeMem(Currency);
end;

{-----Reset strategy--------------------------------------------------------}
procedure ResetStrategy; stdcall;
begin
OrderHandle := -1;
// 4H
handle1 := CreateIndicator(Currency, TimeFrame3, 'MovingAverage', format('%d;0;0;%s;Close', [period1, StrMAType(ma_EMA)]));
SetIndicatorBuffStyle(handle1, 0, psSolid, 1, clAqua);
handle2 := CreateIndicator(Currency, TimeFrame3, 'MovingAverage', format('%d;0;0;%s;Close', [period2, StrMAType(ma_EMA)]));
SetIndicatorBuffStyle(handle2, 0, psSolid, 1, clLime);
handle3 := CreateIndicator(Currency, TimeFrame3, 'MovingAverage', format('%d;0;0;%s;Close', [period3, StrMAType(ma_EMA)]));
SetIndicatorBuffStyle(handle3, 0, psSolid, 1, clYellow);
// 30M
handle4 := CreateIndicator(Currency, TimeFrame2, 'MovingAverage', format('%d;0;0;%s;Close', [period1, StrMAType(ma_EMA)]));
SetIndicatorBuffStyle(handle4, 0, psSolid, 1, clAqua);
handle5 := CreateIndicator(Currency, TimeFrame2, 'MovingAverage', format('%d;0;0;%s;Close', [period2, StrMAType(ma_EMA)]));
SetIndicatorBuffStyle(handle5, 0, psSolid, 1, clLime);
handle6 := CreateIndicator(Currency, TimeFrame2, 'MovingAverage', format('%d;0;0;%s;Close', [period3, StrMAType(ma_EMA)]));
SetIndicatorBuffStyle(handle6, 0, psSolid, 1, clYellow);


end;


{-----Process single tick---------------------------------------------------}
procedure GetSingleTick; stdcall;
var
ema3_1, ema3_2, ema3_3, ema2_1, ema2_2, ema2_3: double;
begin
// check our currency
if Symbol <> string(Currency) then exit;

// set currency and timeframe
SetCurrencyAndTimeframe(Symbol, TimeFrame3);
SetCurrencyAndTimeframe(Symbol, TimeFrame2);

// check number of bars and SMA period
if (Bars < period1) or (Bars < period2) or (Bars < period3)then exit;

// get TimeFrame3 Moving Average value
ema3_1 := GetIndicatorValue(handle1, 1, 0);
ema3_2 := GetIndicatorValue(handle2, 1, 0);
ema3_3 := GetIndicatorValue(handle3, 1, 0);

// get TimeFrame2 Moving Average value
ema2_1 := GetIndicatorValue(handle4, 1, 0);
ema2_2 := GetIndicatorValue(handle5, 1, 0);
ema2_3 := GetIndicatorValue(handle6, 1, 0);


// if BUY order exists and fast EMA crosses slow EMA from top
// then close order
if (OrderHandle <> -1) and (OrderStyle = tp_Buy) and
(OpenTime <> Time(0)) and
(ema2_1 < ema2_3) then
begin
CloseOrder(OrderHandle);
OrderHandle := -1;
end;

// if SELL order exists and fast EMA crosses slow EMA from bottom
// then close order
if (OrderHandle <> -1) and (OrderStyle = tp_Sell) and
(OpenTime <> Time(0)) and
(ema2_1 > ema2_3) then
begin
CloseOrder(OrderHandle);
OrderHandle := -1;
end;

// if there is no order and fast EMA crosses slow EMA from top
// then open SELL order
if (OrderHandle = -1) and
(ema3_1 < ema3_2) and
(ema3_2 < ema3_3) and
(ema2_1 < ema2_2) and
(ema2_2 < ema2_3)
then
begin
SendInstantOrder(Symbol, op_Sell, LotSize, 0, 0, '', 0, OrderHandle);
OrderStyle := tp_Sell;
OpenTime := Time(0);
end;

// if there is no order and fast EMA crosses slow EMA from bottom
// then open BUY order
if (OrderHandle = -1) and
(ema3_1 > ema3_2) and
(ema3_2 > ema3_3) and
(ema2_1 > ema2_2) and
(ema2_2 > ema2_3)
then
begin
SendInstantOrder(Symbol, op_Buy, LotSize, 0, 0, '', 0, OrderHandle);
OrderStyle := tp_Buy;
OpenTime := Time(0);
end;
end;

exports

InitStrategy,
DoneStrategy,
ResetStrategy,
GetSingleTick,
ReplaceStr,
IntrfProcsRec;

end.



image.GIF
 Description:
 Filesize:  23.19 KB
 Viewed:  2630 Time(s)

image.GIF


Back to top
View user's profile Send private message
Terranin
Site Admin


Joined: 21 Oct 2006
Posts: 831

PostPosted: Wed Oct 20, 2010 2:50 pm    Post subject: Reply with quote

Do you show 2 different charts together or it it the same chart after you switched timeframe? If there are 2 different chart windows then probably your indicators were added to one of them. If you change timeframe on 4H chart to 30M you will see your indicator there. Also check Journal, all problems will be commented there.
_________________
Hasta la vista
Mike
Back to top
View user's profile Send private message
Gen



Joined: 21 Sep 2010
Posts: 14

PostPosted: Wed Oct 20, 2010 6:50 pm    Post subject: Reply with quote

I am trying to use 3 different time frames to trade. So I want to have 3 different charts on the screen, 4h, 30M and 5M. When I enable to strategy, I would like to see all the lines and everything on each of the chart for debugging my strategy. Is there any way possible? I, just in case, attached the journal message.


journal.GIF
 Description:
 Filesize:  4.65 KB
 Viewed:  2620 Time(s)

journal.GIF


Back to top
View user's profile Send private message
Gen



Joined: 21 Sep 2010
Posts: 14

PostPosted: Thu Oct 21, 2010 7:01 am    Post subject: Reply with quote

It's been resolved. I do not see the problem anymore. Thanks for your support.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Forex Tester Forum (Professional Training Software for Traders) Forum Index -> FT API All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group