How to plot in signals !!!

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
maxmax68
Posts: 163
Joined: 20 Nov 2012
Has thanked: 55 times
Been thanked: 48 times

How to plot in signals !!!

Postby maxmax68 » 26 Dec 2013

Hi,
as you know you can not use the "plot" keyword in signals.
I have found that it is possible to simulate the plot via the keyword TL_NEW.
Surely for users of older date is a trivial suggestion,
but for novices to MC like me might not be so obvious,
and it is for this reason that I wanted to highlight it with this post and a sample code.
Regards
Massimo

Code: Select all

[IntrabarOrderGeneration = false]
inputs:
AveFastLen( 9 ), AveSlowLen( 20 ), Qty(1);

variables:
MP( 0 ), vAveFast1(0), vAveSlow1(0);

once cleardebug;

MP = MarketPosition() ;
vAveFast1 = XAverage(Close,AveFastLen);
vAveSlow1 = XAverage(Close,AveSlowLen);

// -------------------------------------------------------------------
// With TL_NEW is possible to plot in Signals !!!
// -------------------------------------------------------------------

value1 = tl_new(date[1],Time[1],vAveFast1[1],date,time,vAveFast1);
tl_setsize(value1,3);
tl_setcolor(value1,green);
value1 = tl_new(date[1],Time[1],vAveSlow1[1],date,time,vAveSlow1);
tl_setsize(value1,3);
tl_setcolor(value1,red);

// --------------------------------------------------------------------
//
if time_s > 172300 AND MP = 1 then
begin
Sell Qty Shares Next Bar AT Market ;
end
else if time_s > 172300 AND MP = -1 then
begin
buytocover Qty Shares Next Bar AT Market;
end
else if time_s > 90000 AND time_s <172300 then
begin
if MP = 0 AND vAveFast1 > vAveSlow1 then
begin
buy Qty Shares Next Bar AT Market;
end
else if MP = 0 AND vAveFast1 < vAveSlow1 then
begin
sellshort Qty Shares Next Bar AT Market ;
end
else if MP = -1 AND vAveFast1 > vAveSlow1 then
begin
buy Qty Shares Next Bar AT Market;
//buy Qty Shares Next Bar AT Market;
end
else if MP = 1 AND vAveFast1 < vAveSlow1 then
begin
sellshort Qty Shares Next Bar AT Market;
//sell Qty Shares Next Bar AT Market ;
end;
end;
print (MP);

Return to “User Contributed Studies and Indicator Library”