Plz Help:Indicator plot nothing - TradeStation | futures io social day trading
futures io futures trading


Plz Help:Indicator plot nothing
Updated: Views / Replies:212 / 22
Created: by jiaqiangmit Attachments:2

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 2  
 
Thread Tools Search this Thread
 

Plz Help:Indicator plot nothing

  #1 (permalink)
Elite Member
Mianyang China
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Data: MCTrader, broker: Hongyuan Futures(Chinese brokers are all the same)
Favorite Futures: Rebar(RB, Shanghai Future Exange)
 
Posts: 42 since Aug 2017
Thanks: 7 given, 3 received

Plz Help:Indicator plot nothing

HI guys,
I borrowed the MRA zigzag volume for MC, and deleted some codes which cannot be used in TS and there function not a must right now. The codes now is verified but dose not plot wave leg(zigzag line) or volume text. So please help to check, I cannot figure out why it plots nothing. Thanks!
-----------below is the codes-----------------------

Inputs:
HiPrice( close ), // price field for high swings
LoPrice( close ), // price field for low swings
RetraceMethod( 1 ), // 1=Pnt, 2=%, 3=ATR, 4=UTC
Period( 2 ), // number of bars over which ATR or UTC is calculated
Retrace( 0 ), // retracement in Pnt, % or ATR multiple
PlotVolume( true ), // plots swing volume histogram
PlotSwings( true ), // plots ZigZag lines
PlotVolumeText( true ), // plots swing volume text of up/down swing at swing high/low
AvgVolume( false ), // shows average swing volume text in stead of cumulative swing volume text
ScaleVolumeBy( 1 ), // divides cumulative volume text by the number of this input
PlotPriceText( false ), // plots price change of up/down swing at swing high/low
PlotTimeText( false ), // plots duration of up/down swing at swing high/low
LineWidth( 0 ), // line width of ZigZag lines: 0,1,2,3,4,5,6
LineStyle( tool_solid), // line style of ZigZag lines: tool_solid, tool_dotted, tool_dashed, tool_dashed2, tool_dashed3
UpColor( red ), // line color of upswings: PowerLanguage colors
DnColor( red ), // line color of downswings: PowerLanguage colors
TextColor( white ), // text color: PowerLanguage colors
dis(3); //distance of text frome the high/low, added by Qin H Jia 20171213

Vars:
dailyTF( false ),
dir( 0 ),
hi( HiPrice ),
lo( LoPrice ),
lastLoBar( 1 ),
lastHiBar( 1 ),
lastHi( HiPrice ),
lastLo( LoPrice ),
swingHiCondition( false ),
swingLoCondition( false ),
vol( 0 ),
volUp( 0 ),
volDn( 0 ),
barsBack( 0 ),
x( 0 ),
tl( 0 ),
plotText( "" ),var1(-99),var2(-99),
waveTxt( 0 );

// Initialize variables
dailyTF = BarType >= 2 and BarType < 5;
hi = iff( RetraceMethod = 4, Highest( HiPrice, Period ), HiPrice );
lo = iff( RetraceMethod = 4, Lowest( LoPrice, Period ), LoPrice );
vol = iff( dailyTF, Volume, Ticks );

// set initial trend direction (dir will become non-zero after the first couple of bars)
if dir = 0 then
begin
if hi[0] > lastHi then // higher high
begin
lastHi = hi[0];
lastHiBar = CurrentBar;
if lo[0] > lo[1] then // higher low
dir = 1; // initial trend direction is up
end;
if lo[0] < lastLo then // lower low
begin
lastLo = lo[0];
lastLoBar = CurrentBar;
if hi[0] < hi[1] then // lower high
dir = -1; // initial trend direction is down
end;
end;

// look for swing points and draw lines

if dir > 0 then // trend is up, look for new swing high
begin
if RetraceMethod = 1 then swingHiCondition = lo[0] < lastHi - Retrace; // condition for swing high pnt
if RetraceMethod = 2 then swingHiCondition = lo[0] < lastHi * (1 - Retrace * 0.01 ); // condition for swing high %
if RetraceMethod = 3 then swingHiCondition = lo[0] < lastHi - ( Retrace * AvgTrueRange( Period ) ); // condition for swing high ATR
if RetraceMethod = 4 then swingHiCondition = hi[0] < lastHi and lo[0] < lo[1]; // condition for swing high UTC

if not swingHiCondition then
begin
if hi[0] >= lastHi then // found an equal high or higher high
begin
lastHi = hi[0];
lastHiBar = CurrentBar;
end;
// update cumulative volume of upswing
volUp = 0;
barsBack = ( CurrentBar - lastLoBar - 1 );
for x = barsBack downto 0
begin
volUp = volUp + vol[x];
{if PlotVolume then
begin
NoPlot[x]( 2 );
Plot1[x]( VolUp, "Volume Up" );
end;}
end;
// update current upswing line and text from lastLoBar
if PlotSwings then
begin
{if AvgVolume and ( lastHiBar - lastLoBar ) <> 0 then volUp = volUp / ( lastHiBar - lastLoBar );}
TL_SetEnd( tl, date[0],time[0], lastHi );
end;
plotText = NumToSTr( volUp / ScaleVolumeBy, 0 );
Text_SetLocation( waveTxt, date[0],time[0], High[0]+dis);
Text_SetString( waveTxt, plotText );
end
else if swingHiCondition then // found a swing high
begin
// update cumulative volume of upswing
volUp = 0;
barsBack = ( CurrentBar - lastLoBar - 1 );
for x = barsBack downto ( CurrentBar - lastHiBar )
begin
volUp = volUp + vol[x];
{if PlotVolume thena
begin
NoPlot[x]( 2 );
Plot1[x]( VolUp, "Volume Up" );
end;}
end;
// update current upswing line from lastLoBar
if PlotSwings then
begin
{if AvgVolume and ( lastHiBar - lastLoBar ) <> 0 then volUp = volUp / ( lastHiBar - lastLoBar );}
TL_SetEnd( tl, date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], lastHi );
end;
plotText = NumToSTr( volUp / ScaleVolumeBy,0){NumToSTr( volUp / ScaleVolumeBy, 0 )} ;

Text_SetLocation( waveTxt, date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], High[CurrentBar - lastHiBar]+dis );
Text_SetString( waveTxt, plotText );

dir = -1; // trend direction is now down
lastLo = lo[0];
lastLoBar = CurrentBar; // now seeking new lows
volDn = 0;
barsBack = ( CurrentBar - lastHiBar - 1 );
for x = barsBack downto 0
begin
volDn = volDn + vol[x];
{if PlotVolume then
begin
NoPlot[x]( 1 );
Plot2[x]( VolDn, "Volume Down" );
end;}
end;

if PlotSwings then // start new trendline from new swing high to most recent low
begin
{if AvgVolume and ( lastLoBar - lastHiBar ) <> 0 then volDn = volDn / ( lastLoBar - lastHiBar );}
tl = TL_New( date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], lastHi, date[CurrentBar - lastloBar],time[CurrentBar - lastLoBar], lastLo );
TL_SetExtLeft( tl, false );
TL_SetExtRight( tl, false );
TL_SetSize( tl, LineWidth );
TL_SetStyle( tl, LineStyle );
TL_SetColor( tl, DnColor );
end;
plotText =
iffString( PlotVolumeText, NumToSTr( volDn / ScaleVolumeBy, 0 ), "" ) ;
waveTxt = Text_New( date[CurrentBar - lastloBar],time[CurrentBar - lastLoBar], Low[CurrentBar - lastLoBar], plotText );
Text_SetStyle( waveTxt, 2, 0 );
{Text_SetSize( waveTxt, 8 );}
Text_SetColor( waveTxt, TextColor );
end;
end
else
begin // dir < 0, trend is down, look for new swing low
if RetraceMethod = 1 then swingLoCondition = hi[0] > lastLo + Retrace; // condition for swing low pnt
if RetraceMethod = 2 then swingLoCondition = hi[0] > lastLo * (1 + Retrace * 0.01 ); // condition for swing low %
if RetraceMethod = 3 then swingLoCondition = hi[0] > lastLo + ( Retrace * AvgTrueRange( Period ) ); // condition for swing low ATR
if RetraceMethod = 4 then swingLoCondition = lo[0] > lastLo and hi[0] > hi[1]; // condition for swing low UTC

if not swingLoCondition then
begin
if lo[0] <= lastLo then // found an equal low or lower low
begin
lastLo = lo[0];
lastLoBar = CurrentBar;
end;
// update cumulative volume of downswing
volDn = 0;
barsBack = ( CurrentBar - lastHiBar - 1 );
for x = barsBack downto 0
begin
volDn = volDn + vol[x];
{if PlotVolume then
begin
NoPlot[x]( 1 );
Plot2[x]( VolDn, "Volume Down" );
end;}
end;
// update current downswing line and text from lastHiBar
if PlotSwings then
begin
{if AvgVolume and ( lastLoBar - lastHiBar ) <> 0 then volDn = volDn / ( lastLoBar - lastHiBar );}
TL_SetEnd( tl, date[0],time[0], lastLo );
end;
plotText =

iffString( PlotVolumeText, NumToSTr( volDn / ScaleVolumeBy, 0 ) + NewLine, "" ) ;

Text_SetLocation( waveTxt, date[0],time[0], Low[0]-dis );
Text_SetString( waveTxt, plotText );
end
else if swingLoCondition then // found a swing low
begin
// update cumulative volume of downswing
volDn = 0;
barsBack = ( CurrentBar - lastHiBar - 1 );
for x = barsBack downto ( CurrentBar - lastLoBar )
begin
volDn = volDn + vol[x];
{if PlotVolume then
begin
NoPlot[x]( 1 );
Plot2[x]( VolDn, "Volume Down" );
end;}
end;
// update current downswing line from lastHiBar
if PlotSwings then
begin
{if AvgVolume and ( lastLoBar - lastHiBar ) <> 0 then volDn = volDn / ( lastLoBar - lastHiBar );}
TL_SetEnd( tl, date[CurrentBar - lastloBar],time[CurrentBar - lastLoBar], lastLo);
end;
plotText =

iffString( PlotVolumeText, NumToSTr( volDn / ScaleVolumeBy, 0 ) + NewLine, "" ) ;

Text_SetLocation( waveTxt, date[CurrentBar - lastloBar],time[CurrentBar - lastLoBar], Low[CurrentBar - lastLoBar]-dis);
Text_SetString( waveTxt, plotText );

dir = 1; // trend direction is now up
lastHi = hi[0];
lastHiBar = CurrentBar; // now seeking new highs
volUp = 0;
barsBack = ( CurrentBar - lastLoBar - 1 );
for x = barsBack downto 0
begin
volUp = volUp + vol[x];
{if PlotVolume then
begin
Plot1[x]( VolUp, "Volume Up" );
NoPlot[x]( 2 );
end;}
end;

if PlotSwings then // start new trendline from new swing low to most recent high
begin
if AvgVolume and ( lastHiBar - lastLoBar ) <> 0 then volUp = volUp / ( lastHiBar - lastLoBar );
tl = TL_New( date[CurrentBar - lastloBar],time[CurrentBar - lastLoBar], lastLo, date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], lastHi );
TL_SetExtLeft( tl, false );
TL_SetExtRight( tl, false );
TL_SetSize( tl, LineWidth );
TL_SetStyle( tl, LineStyle );
TL_SetColor( tl, UpColor );
end;
plotText =

NumToSTr( volUp / ScaleVolumeBy, 0 );

waveTxt = Text_New( date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], High[CurrentBar - lastHiBar], plotText );
Text_SetStyle( waveTxt, 2, 1 );
{Text_SetSize( waveTxt, 8 );}
Text_SetColor( waveTxt, TextColor );
end;
end;

Reply With Quote
 
  #2 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,569 since Apr 2013
Thanks: 240 given, 889 received
Forum Reputation: Legendary

jiaqiangmit,

is this the original code or the one with your changes? If it's the latter, I'd suggest to also post the original code as this might help tracking the issue down. I would also suggest to post the code within a code box, via the "Wrap [Code] tags around selected text" button.

Regards,

ABCTG

Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #3 (permalink)
Elite Member
Mianyang China
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Data: MCTrader, broker: Hongyuan Futures(Chinese brokers are all the same)
Favorite Futures: Rebar(RB, Shanghai Future Exange)
 
Posts: 42 since Aug 2017
Thanks: 7 given, 3 received



ABCTG View Post
jiaqiangmit,

is this the original code or the one with your changes? If it's the latter, I'd suggest to also post the original code as this might help tracking the issue down. I would also suggest to post the code within a code box, via the "Wrap [Code] tags around selected text" button.

Regards,

ABCTG

It's codes I changed.
These are the original code
Quoting 
Inputs:
HiPrice( close ), // price field for high swings
LoPrice( close ), // price field for low swings
RetraceMethod( 1 ), // 1=Pnt, 2=%, 3=ATR, 4=UTC
Period( 2 ), // number of bars over which ATR or UTC is calculated
Retrace( 0 ), // retracement in Pnt, % or ATR multiple
PlotVolume( true ), // plots swing volume histogram
PlotSwings( true ), // plots ZigZag lines
PlotVolumeText( true ), // plots swing volume text of up/down swing at swing high/low
AvgVolume( false ), // shows average swing volume text in stead of cumulative swing volume text
ScaleVolumeBy( 1 ), // divides cumulative volume text by the number of this input
PlotPriceText( false ), // plots price change of up/down swing at swing high/low
PlotTimeText( false ), // plots duration of up/down swing at swing high/low
LineWidth( 0 ), // line width of ZigZag lines: 0,1,2,3,4,5,6
LineStyle( tool_solid), // line style of ZigZag lines: tool_solid, tool_dotted, tool_dashed, tool_dashed2, tool_dashed3
UpColor( red ), // line color of upswings: PowerLanguage colors
DnColor( red ), // line color of downswings: PowerLanguage colors
TextColor( black ), // text color: PowerLanguage colors
dis(3); //distance of text frome the high/low, added by Qin H Jia 20171213

Vars:
dailyTF( false ),
dir( 0 ),
hi( HiPrice ),
lo( LoPrice ),
lastLoBar( 1 ),
lastHiBar( 1 ),
lastHi( HiPrice ),
lastLo( LoPrice ),
swingHiCondition( false ),
swingLoCondition( false ),
vol( 0 ),
volUp( 0 ),
volDn( 0 ),
barsBack( 0 ),
x( 0 ),
tl( 0 ),
plotText( "" ),
waveTxt( 0 );

// Initialize variables
dailyTF = BarType >= 2 and BarType < 5;
hi = iff( RetraceMethod = 4, Highest( HiPrice, Period ), HiPrice );
lo = iff( RetraceMethod = 4, Lowest( LoPrice, Period ), LoPrice );
vol = iff( dailyTF, Volume, Ticks );

// set initial trend direction (dir will become non-zero after the first couple of bars)
if dir = 0 then
begin
if hi[0] > lastHi then // higher high
begin
lastHi = hi[0];
lastHiBar = CurrentBar;
if lo[0] > lo[1] then // higher low
dir = 1; // initial trend direction is up
end;
if lo[0] < lastLo then // lower low
begin
lastLo = lo[0];
lastLoBar = CurrentBar;
if hi[0] < hi[1] then // lower high
dir = -1; // initial trend direction is down
end;
end;

// look for swing points and draw lines

if dir > 0 then // trend is up, look for new swing high
begin
if RetraceMethod = 1 then swingHiCondition = lo[0] < lastHi - Retrace; // condition for swing high pnt
if RetraceMethod = 2 then swingHiCondition = lo[0] < lastHi * (1 - Retrace * 0.01 ); // condition for swing high %
if RetraceMethod = 3 then swingHiCondition = lo[0] < lastHi - ( Retrace * AvgTrueRange( Period ) ); // condition for swing high ATR
if RetraceMethod = 4 then swingHiCondition = hi[0] < lastHi and lo[0] < lo[1]; // condition for swing high UTC

if not swingHiCondition then
begin
if hi[0] >= lastHi then // found an equal high or higher high
begin
lastHi = hi[0];
lastHiBar = CurrentBar;
end;
// update cumulative volume of upswing
volUp = 0;
barsBack = ( CurrentBar - lastLoBar - 1 );
for x = barsBack downto 0
begin
volUp = volUp + vol[x];
if PlotVolume then
begin
NoPlot[x]( 2 );
Plot1[x]( VolUp, "Volume Up" );
end;
end;
// update current upswing line and text from lastLoBar
if PlotSwings then
begin
if AvgVolume and ( lastHiBar - lastLoBar ) <> 0 then volUp = volUp / ( lastHiBar - lastLoBar );
TL_SetEnd_Dt( tl, datetime[0], lastHi );
end;
plotText =
iffString( PlotTimeText, iffString( dailyTF, NumToStr( CurrentBar - lastLoBar, 0 ) + " bar(s)",
DateTimeToHMS( ( ELDateToDateTime( Date[0] ) - ELDateToDateTime( Date[CurrentBar - lastLoBar] ) ) +
ELTimeToDateTime_s( Time_s[0] ) - ELTimeToDateTime_s( Time_s[CurrentBar - lastLoBar] ) ) ), "" ) +
iffString( PlotVolumeText, NewLine + NumToSTr( volUp / ScaleVolumeBy, 0 ), "" ) +
iffString( PlotPriceText, NewLine + "+" + NumToSTr( ( lastHi - lastLo ) * PriceScale, 0 ), "" );
Text_SetLocation_Dt( waveTxt, datetime[0], High[0]+dis);
Text_SetString( waveTxt, plotText );
end
else if swingHiCondition then // found a swing high
begin
// update cumulative volume of upswing
volUp = 0;
barsBack = ( CurrentBar - lastLoBar - 1 );
for x = barsBack downto ( CurrentBar - lastHiBar )
begin
volUp = volUp + vol[x];
if PlotVolume then
begin
NoPlot[x]( 2 );
Plot1[x]( VolUp, "Volume Up" );
end;
end;
// update current upswing line from lastLoBar
if PlotSwings then
begin
if AvgVolume and ( lastHiBar - lastLoBar ) <> 0 then volUp = volUp / ( lastHiBar - lastLoBar );
TL_SetEnd_Dt( tl, datetime[CurrentBar - lastHiBar], lastHi );
end;
plotText =
iffString( PlotTimeText, iffString( dailyTF, NumToStr( lastHiBar - lastLoBar, 0 ) + " bar(s)",
DateTimeToHMS( ( ELDateToDateTime( Date[CurrentBar - lastHiBar] ) - ELDateToDateTime( Date[CurrentBar - lastLoBar] ) ) +
ELTimeToDateTime_s( Time_s[CurrentBar - lastHiBar] ) - ELTimeToDateTime_s( Time_s[CurrentBar - lastLoBar] ) ) ), "" ) +
iffString( PlotVolumeText, NewLine + NumToSTr( volUp / ScaleVolumeBy, 0 ), "" ) +
iffString( PlotPriceText, NewLine + "+" + NumToSTr( ( lastHi - lastLo ) * PriceScale, 0 ), "" );
Text_SetLocation_Dt( waveTxt, datetime[CurrentBar - lastHiBar], High[CurrentBar - lastHiBar]+dis );
Text_SetString( waveTxt, plotText );

dir = -1; // trend direction is now down
lastLo = lo[0];
lastLoBar = CurrentBar; // now seeking new lows
volDn = 0;
barsBack = ( CurrentBar - lastHiBar - 1 );
for x = barsBack downto 0
begin
volDn = volDn + vol[x];
if PlotVolume then
begin
NoPlot[x]( 1 );
Plot2[x]( VolDn, "Volume Down" );
end;
end;

if PlotSwings then // start new trendline from new swing high to most recent low
begin
if AvgVolume and ( lastLoBar - lastHiBar ) <> 0 then volDn = volDn / ( lastLoBar - lastHiBar );
tl = TL_New_Dt( datetime[CurrentBar - lastHiBar], lastHi, datetime[CurrentBar - lastLoBar], lastLo );
TL_SetExtLeft( tl, false );
TL_SetExtRight( tl, false );
TL_SetSize( tl, LineWidth );
TL_SetStyle( tl, LineStyle );
TL_SetColor( tl, DnColor );
end;
plotText =
iffString( PlotPriceText, NumToSTr( ( lastLo - lastHi ) * PriceScale, 0 ), "" ) +
iffString( PlotVolumeText, NewLine + NumToSTr( volDn / ScaleVolumeBy, 0 ), "" ) +
iffString( PlotTimeText, NewLine + iffString( dailyTF, NumToStr( lastLoBar - lastHiBar, 0 ) + " bar(s)",
DateTimeToHMS( ( ELDateToDateTime( Date[CurrentBar - lastLoBar] ) - ELDateToDateTime( Date[CurrentBar - lastHiBar] ) ) +
ELTimeToDateTime_s( Time_s[CurrentBar - lastLoBar] ) - ELTimeToDateTime_s( Time_s[CurrentBar - lastHiBar] ) ) ), "" );
waveTxt = Text_New_Dt( datetime[CurrentBar - lastLoBar], Low[CurrentBar - lastLoBar], plotText );
Text_SetStyle( waveTxt, 2, 0 );
Text_SetSize( waveTxt, 8 );
Text_SetColor( waveTxt, TextColor );
end;
end
else
begin // dir < 0, trend is down, look for new swing low
if RetraceMethod = 1 then swingLoCondition = hi[0] > lastLo + Retrace; // condition for swing low pnt
if RetraceMethod = 2 then swingLoCondition = hi[0] > lastLo * (1 + Retrace * 0.01 ); // condition for swing low %
if RetraceMethod = 3 then swingLoCondition = hi[0] > lastLo + ( Retrace * AvgTrueRange( Period ) ); // condition for swing low ATR
if RetraceMethod = 4 then swingLoCondition = lo[0] > lastLo and hi[0] > hi[1]; // condition for swing low UTC

if not swingLoCondition then
begin
if lo[0] <= lastLo then // found an equal low or lower low
begin
lastLo = lo[0];
lastLoBar = CurrentBar;
end;
// update cumulative volume of downswing
volDn = 0;
barsBack = ( CurrentBar - lastHiBar - 1 );
for x = barsBack downto 0
begin
volDn = volDn + vol[x];
if PlotVolume then
begin
NoPlot[x]( 1 );
Plot2[x]( VolDn, "Volume Down" );
end;
end;
// update current downswing line and text from lastHiBar
if PlotSwings then
begin
if AvgVolume and ( lastLoBar - lastHiBar ) <> 0 then volDn = volDn / ( lastLoBar - lastHiBar );
TL_SetEnd_Dt( tl, datetime[0], lastLo );
end;
plotText =
iffString( PlotPriceText, NumToSTr( ( lastLo - lastHi ) * PriceScale, 0 ) + NewLine, "" ) +
iffString( PlotVolumeText, NumToSTr( volDn / ScaleVolumeBy, 0 ) + NewLine, "" ) +
iffString( PlotTimeText, iffString( dailyTF, NumToStr( CurrentBar - lastHiBar, 0 ) + " bar(s)",
DateTimeToHMS( ( ELDateToDateTime( Date[0] ) - ELDateToDateTime( Date[CurrentBar - lastHiBar] ) ) +
ELTimeToDateTime_s( Time_s[0] ) - ELTimeToDateTime_s( Time_s[CurrentBar - lastHiBar] ) ) ), "" );
Text_SetLocation_Dt( waveTxt, datetime[0], Low[0]-dis );
Text_SetString( waveTxt, plotText );
end
else if swingLoCondition then // found a swing low
begin
// update cumulative volume of downswing
volDn = 0;
barsBack = ( CurrentBar - lastHiBar - 1 );
for x = barsBack downto ( CurrentBar - lastLoBar )
begin
volDn = volDn + vol[x];
if PlotVolume then
begin
NoPlot[x]( 1 );
Plot2[x]( VolDn, "Volume Down" );
end;
end;
// update current downswing line from lastHiBar
if PlotSwings then
begin
if AvgVolume and ( lastLoBar - lastHiBar ) <> 0 then volDn = volDn / ( lastLoBar - lastHiBar );
TL_SetEnd_Dt( tl, datetime[CurrentBar - lastLoBar], lastLo);
end;
plotText =
iffString( PlotPriceText, NumToSTr( ( lastLo - lastHi ) * PriceScale, 0 ) + NewLine, "" ) +
iffString( PlotVolumeText, NumToSTr( volDn / ScaleVolumeBy, 0 ) + NewLine, "" ) +
iffString( PlotTimeText, iffString( dailyTF, NumToStr( lastLoBar - lastHiBar, 0 ) + " bar(s)",
DateTimeToHMS( ( ELDateToDateTime( Date[CurrentBar - lastLoBar] ) - ELDateToDateTime( Date[CurrentBar - lastHiBar] ) ) +
ELTimeToDateTime_s( Time_s[CurrentBar - lastLoBar] ) - ELTimeToDateTime_s( Time_s[CurrentBar - lastHiBar] ) ) ), "" );
Text_SetLocation_Dt( waveTxt, datetime[CurrentBar - lastLoBar], Low[CurrentBar - lastLoBar]-dis);
Text_SetString( waveTxt, plotText );

dir = 1; // trend direction is now up
lastHi = hi[0];
lastHiBar = CurrentBar; // now seeking new highs
volUp = 0;
barsBack = ( CurrentBar - lastLoBar - 1 );
for x = barsBack downto 0
begin
volUp = volUp + vol[x];
if PlotVolume then
begin
Plot1[x]( VolUp, "Volume Up" );
NoPlot[x]( 2 );
end;
end;

if PlotSwings then // start new trendline from new swing low to most recent high
begin
if AvgVolume and ( lastHiBar - lastLoBar ) <> 0 then volUp = volUp / ( lastHiBar - lastLoBar );
tl = TL_New_Dt( datetime[CurrentBar - lastLoBar], lastLo, datetime[CurrentBar - lastHiBar], lastHi );
TL_SetExtLeft( tl, false );
TL_SetExtRight( tl, false );
TL_SetSize( tl, LineWidth );
TL_SetStyle( tl, LineStyle );
TL_SetColor( tl, UpColor );
end;
plotText =
iffString( PlotTimeText, iffString( dailyTF, NumToStr( lastHiBar - lastLoBar, 0 ) + " bar(s)",
DateTimeToHMS( ( ELDateToDateTime( Date[CurrentBar - lastHiBar] ) - ELDateToDateTime( Date[CurrentBar - lastLoBar] ) ) +
ELTimeToDateTime_s( Time_s[CurrentBar - lastHiBar] ) - ELTimeToDateTime_s( Time_s[CurrentBar - lastLoBar] ) ) ), "" ) +
iffString( PlotVolumeText, NewLine + NumToSTr( volUp / ScaleVolumeBy, 0 ), "" ) +
iffString( PlotPriceText, NewLine + "+" + NumToSTr( ( lastHi - lastLo ) * PriceScale, 0 ), "" );
waveTxt = Text_New_Dt( datetime[CurrentBar - lastHiBar], High[CurrentBar - lastHiBar], plotText );
Text_SetStyle( waveTxt, 2, 1 );
Text_SetSize( waveTxt, 8 );
Text_SetColor( waveTxt, TextColor );
end;
end;


Reply With Quote
 
  #4 (permalink)
Elite Member
Mianyang China
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Data: MCTrader, broker: Hongyuan Futures(Chinese brokers are all the same)
Favorite Futures: Rebar(RB, Shanghai Future Exange)
 
Posts: 42 since Aug 2017
Thanks: 7 given, 3 received

Most of my changes are below
--------------------------------------
if PlotSwings then
begin
if AvgVolume and ( lastLoBar - lastHiBar ) <> 0 then volDn = volDn / ( lastLoBar - lastHiBar );//I use {} to nullify this line,for I don't need it to average the accumulative volume, and this line works in Tradestation if not nullified.
TL_SetEnd_Dt( tl, datetime[0], lastLo );//Ts dose not have _Dt reserve words, I changed to
Quoting 
TL_SetEnd( tl, date[0],time[0], lastLo );


end;
plotText =
iffString( PlotPriceText, NumToSTr( ( lastLo - lastHi ) * PriceScale, 0 ) + NewLine, "" ) +
iffString( PlotVolumeText, NumToSTr( volDn / ScaleVolumeBy, 0 ) + NewLine, "" ) +
iffString( PlotTimeText, iffString( dailyTF, NumToStr( CurrentBar - lastHiBar, 0 ) + " bar(s)",
DateTimeToHMS( ( ELDateToDateTime( Date[0] ) - ELDateToDateTime( Date[CurrentBar - lastHiBar] ) ) +
ELTimeToDateTime_s( Time_s[0] ) - ELTimeToDateTime_s( Time_s[CurrentBar - lastHiBar] ) ) ), "" );//the function DateTimeToHMS the author wrote does not work in TS, and I don't need it to plot time difference, so I changed this sentence to
Quoting 
plotText =iffString( PlotVolumeText, NumToSTr( volDn / ScaleVolumeBy, 0 ) + NewLine, "" );

for I just need it to plot the volume in text to simplify it

Text_SetLocation_Dt( waveTxt, datetime[0], Low[0]-dis );//same change in the _Dt
Text_SetString( waveTxt, plotText );
end


--------------------------------------------------------------
if PlotSwings then // start new trendline from new swing low to most recent high
begin
if AvgVolume and ( lastHiBar - lastLoBar ) <> 0 then volUp = volUp / ( lastHiBar - lastLoBar );
tl = TL_New_Dt( datetime[CurrentBar - lastLoBar], lastLo, datetime[CurrentBar - lastHiBar], lastHi );//
Quoting 
tl = TL_New( date[Currentbar-lastLoBar],time[CurrentBar - lastLoBar], lastLo, date[CurrentBar - lastHiBar],time[CurrentBar - lastHiBar], lastHi );

TL_SetExtLeft( tl, false );
TL_SetExtRight( tl, false );
TL_SetSize( tl, LineWidth );//Ts has no TL_setsize, so I use {} to nullify it.
TL_SetStyle( tl, LineStyle );
TL_SetColor( tl, UpColor );
end;
-----------------------------------------------------
if PlotVolume then
begin
Plot1[x]( VolUp, "Volume Up" );
NoPlot[x]( 2 );
end; //the NoPlot reserve word works different, I use {} to nullify it, for it's ok for me to not plot histogram accumulative volume in a sub-graph. If it can plot, it's better.
------------------------------------------------------------------------

Please check which was changed or deleted in the wrong way, thanks very much.


Last edited by jiaqiangmit; January 10th, 2018 at 09:33 AM.
Reply With Quote
 
  #5 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,569 since Apr 2013
Thanks: 240 given, 889 received
Forum Reputation: Legendary

jiaqiangmit,

your best approach might be to start over with the translation and do it block by block while you compare the internal code computations with additional print statements or blocks between MC and TS. This will help you in tracking down where the problem is coming from.
You can also do this with the code changes you made i.e. check with using prints or plots to see if they return a meaningful result.

Regards,

ABCTG

Reply With Quote
 
  #6 (permalink)
Elite Member
Mianyang China
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Data: MCTrader, broker: Hongyuan Futures(Chinese brokers are all the same)
Favorite Futures: Rebar(RB, Shanghai Future Exange)
 
Posts: 42 since Aug 2017
Thanks: 7 given, 3 received


ABCTG View Post
jiaqiangmit,

your best approach might be to start over with the translation and do it block by block while you compare the internal code computations with additional print statements or blocks between MC and TS. This will help you in tracking down where the problem is coming from.
You can also do this with the code changes you made i.e. check with using prints or plots to see if they return a meaningful result.

Regards,

ABCTG

I checked the blocks, and I thinks they are all right. I'm not professional in coding, I think it's the best changes I can made. Could you check them when you are free? I have highlighted my changes .
Thanks very much.

Reply With Quote
 
  #7 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,569 since Apr 2013
Thanks: 240 given, 889 received
Forum Reputation: Legendary

jiaqiangmit,

it's not necessarily your code modification, as your modified code plots in MC. I would suggest looking into the parts that draw the text and lines and update their location and I will gladly point you in the right direction when I can.

Regards,

ABCTG

Reply With Quote
 
  #8 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,569 since Apr 2013
Thanks: 240 given, 889 received
Forum Reputation: Legendary

jiaqiangmit,

TS is a bit more sensitive when it comes to drawing/updating text and trendlines. This is an excerpt from the help file for the Text_SetLocation reserved word:

Quoting 
It is important to remember that if an invalid ID number is used, the reserved word will return a value of -2 and no additional operations will be performed on any text objects by the trading strategy, analysis technique, or function that generated the error.

This is most likely what is happening here i.e. your code tries (even if it's just once) to update a text or trendline with an ID that doesn't exist. This is turn, as the quote above clarifies, will not perform any additional text operations.

Adding code to check that the ID you want to update exists (or is greater than the value you used initialized this variable with at least) before you update a trendline or text id might already be the cure.

Regards,

ABCTG

Reply With Quote
 
  #9 (permalink)
Elite Member
Mianyang China
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Data: MCTrader, broker: Hongyuan Futures(Chinese brokers are all the same)
Favorite Futures: Rebar(RB, Shanghai Future Exange)
 
Posts: 42 since Aug 2017
Thanks: 7 given, 3 received

Thanks. These are those part I changed to adapt Tradestation:

Quoting 
if PlotSwings then
begin
{if AvgVolume and ( lastHiBar - lastLoBar ) <> 0 then volUp = volUp / ( lastHiBar - lastLoBar );}
TL_SetEnd( tl, date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], lastHi );
end;
plotText = NumToSTr( volUp / ScaleVolumeBy,0){NumToSTr( volUp / ScaleVolumeBy, 0 )} ;

Text_SetLocation( waveTxt, date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], High[CurrentBar - lastHiBar]+dis );
Text_SetString( waveTxt, plotText );

the TL_SetEnd line updates the zigzag line.
the rest plot accumutative volume(volUP) scaled by the var:ScaleVolumeBy.

----------below are those plot new zigzag line and volume text.

Quoting 
if PlotSwings then // start new trendline from new swing high to most recent low
begin
{if AvgVolume and ( lastLoBar - lastHiBar ) <> 0 then volDn = volDn / ( lastLoBar - lastHiBar );}
tl = TL_New( date[CurrentBar - lastloBar],time[CurrentBar - lastHiBar], lastHi, date[CurrentBar - lastloBar],time[CurrentBar - lastLoBar], lastLo );
TL_SetExtLeft( tl, false );
TL_SetExtRight( tl, false );
TL_SetSize( tl, LineWidth );
TL_SetStyle( tl, LineStyle );
TL_SetColor( tl, DnColor );
end;
plotText =
iffString( PlotVolumeText, NumToSTr( volDn / ScaleVolumeBy, 0 ), "" ) ;
waveTxt = Text_New( date[CurrentBar - lastloBar],time[CurrentBar - lastLoBar], Low[CurrentBar - lastLoBar], plotText );
Text_SetStyle( waveTxt, 2, 0 );
{Text_SetSize( waveTxt, 8 );}
Text_SetColor( waveTxt, TextColor );


Reply With Quote
 
  #10 (permalink)
Elite Member
Mianyang China
 
Futures Experience: Beginner
Platform: Multicharts
Broker/Data: Data: MCTrader, broker: Hongyuan Futures(Chinese brokers are all the same)
Favorite Futures: Rebar(RB, Shanghai Future Exange)
 
Posts: 42 since Aug 2017
Thanks: 7 given, 3 received



ABCTG View Post
jiaqiangmit,

TS is a bit more sensitive when it comes to drawing/updating text and trendlines. This is an excerpt from the help file for the Text_SetLocation reserved word:


This is most likely what is happening here i.e. your code tries (even if it's just once) to update a text or trendline with an ID that doesn't exist. This is turn, as the quote above clarifies, will not perform any additional text operations.

Adding code to check that the ID you want to update exists (or is greater than the value you used initialized this variable with at least) before you update a trendline or text id might already be the cure.

Regards,

ABCTG

The original zigzag volume indicator for MC first update the zigzag line, then draw new line if new top or bottom is formed. Is this the problem? the original codes for MC have been posted.

Also, I checked in MC, Text_SetLocation and Text_Setlocation in the help file does not have the
Quoting 
It is important to remember that if an invalid ID number is used, the reserved word will return a value of -2 and no additional operations will be performed on any text objects by the trading strategy, analysis technique, or function that generated the error.

Maybe in TS I should first use Text_new to draw new text then use Text_setLocation ?


Last edited by jiaqiangmit; January 10th, 2018 at 11:33 AM.
Reply With Quote

Reply



futures io > > > > Plz Help:Indicator plot nothing

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

Trading Computer Generated Info w/RandBots

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Indicator: How to plot in two different panels with one indicator? vantojo NinjaTrader Programming 4 September 25th, 2016 11:39 PM
Plz help me to find Walfe Wave Indicator for ThinkorSwim Dost ThinkOrSwim 1 May 24th, 2016 03:27 PM
indicator will not plot MilfordT NinjaTrader 5 October 6th, 2014 07:46 PM
Help plz with Gom setup :( Warlock186 NinjaTrader 1 September 9th, 2014 01:27 PM
A little programming help plz mpe66 NinjaTrader Programming 31 July 27th, 2011 10:16 AM


All times are GMT -4. The time now is 12:36 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2018-01-22 in 0.09 seconds with 19 queries on phoenix via your IP 54.234.45.10