[FAQ] EasyLanguage / PowerLanguage

Read before posting.
User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

[FAQ] EasyLanguage / PowerLanguage

Postby TJ » 09 Dec 2009

(1) [FAQ] EasyLanguage


Start here if you want to program your own analysis.

You can Google for these free e-books:

EasyLanguage Reference Guide
also called Getting Started with EasyLanguage
This is the ebook you need if you're thinking about using EasyLanguage but don't know where to start.
I am recommending this ebook because it is short, well organized and easy to read.
You should be able to complete this book in one weekend.
P.S. This is a slightly outdated text (for TS v6). But we are dealing with the basics here, so that's perfectly OK.

You can Google for a free copy of this ebook on the internet (pdf). Because this is an old text, it is not high on the search list; you might have to scroll through a few pages of google to find it. But the effort is worth it.


The Essential EasyLanguage Programming Guide
This indispensable reference allows you to quickly look up usage and syntax concepts and examples for the most commonly used features of EasyLanguage.

You can Google for a copy of this free ebook on the internet.

EasyLanguage® Functions & Reserved Words Reference
This book discusses in detail EasyLanguage keywords and functions. These tools are used in technical analysis as well as automated electronic order placement and execution. You need to master these knowledge in order to develop, test and implement trading strategies.


For quick references,
MultiCharts Wiki
https://www.multicharts.com/trading-sof ... /Main_Page
--> https://www.multicharts.com/trading-sof ... tegory:FAQ

PowerLanguage Keyword Reference
https://www.multicharts.com/trading-sof ... _Reference

Sub-Second Keywords
viewtopic.php?f=16&t=18785&p=68665

Additional Information Sources
https://www.multicharts.com/trading-sof ... on_Sources



-------------------------------------------------------
Has this post been helpful to you?
Last edited by TJ on 24 Feb 2010, edited 5 times in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

(2) Learning Autotrade

Postby TJ » 09 Dec 2009

MultiCharts User Manual in PDF format
https://www.multicharts.com/trading-sof ... /Main_Page

MultiCharts PowerLanguage Keyword Reference in PDF format (ver 10)
download/file.php?id=9740


You can get the reference guides here:
https://www.multicharts.com/trading-sof ... on_Sources
https://www.multicharts.com/trading-sof ... /Main_Page
viewforum.php?f=16

.
Last edited by TJ on 18 May 2010, edited 1 time in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

(3) [FAQ] OCO order

Postby TJ » 12 Jan 2010

(3) [FAQ] OCO order
Questions:
-- How to code an OCO order?
-- Why are my bracket orders not executed?

-- How do I remove a stop loss order once a position is closed?

Here's my sample code. Why doesn't it work?

Code: Select all

If BuyCondition = true then
Begin
Buy ("B") next bar at Market;
SetStopLoss ( 100 ) ;
SetProfitTarget( 200 );
End ;
Answer:

The following are EasyLanguage OCO keywords.
They are also called Global Exits.
To avoid logical error, these keywords should not be placed inside a condition:

SetBreakEven
SetDollarTrailing
SetPercentTrailing
SetProfitTarget
SetStopLoss


These exit instructions are part of the Strategy Engine.
The orders are posted to broker when there is an open position.

If your position in the market is closed,
the remaining unfilled target and stop will be automatically* withdrawn.

* "Automatic" means you do not need to code a logic to withdraw the orders,
they are done automatically by the Strategy Engine as soon as the position is closed.


The bracket/OCO order should be coded this way:

Code: Select all


If BuyCondition = true then
Begin
Buy ("B") next bar at Market;
End ;

//----- Global Exits -----
SetStopLoss ( 100 ) ;
SetProfitTarget( 200 );

note:
Global Exit orders are executed intra-bar, as soon as the condition is met, regardless of whether IntrabarOrderGeneration (IOG) is enabled.



for more info, see
EasyLanguage Essentials Programmers Guide
Built-in Stops.......... pg. 90

EasyLanguage Reference Guide
Understanding Built-in Stops.......... pg. 132
.
Last edited by TJ on 27 Jun 2010, edited 3 times in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

(4) Multi-Data Analysis

Postby TJ » 17 Feb 2010

(4) [FAQ] Multiple time frame, Multi-Data Analysis
Hi,
I was wondering if someone knew a way to run multiple time frames on a chart and have an indicator synced to all 3 at the same time. By this I mean I want to run the indicator on all 3 time charts and only show an alert when the indicator condition is met on all 3 at the same time. Any thoughts would be appreciated
Thanks

The Essential EasyLanguage Programming Guide
Multi-Data Analysis... pg. 15
Multi-Data Indicators... pg.71
Multi-Data Reference... pg.72
Data(n)... pg.72


EasyLanguage Reference Guide
Multi-data strategy... pg. 43

note: you can google for a free copy of these ebooks.


Note: As a rule of thumb, when using multi-data, always put the fastest fractal as data1, and slower fractals as secondary data.
(eg. 1 min as data1, 5 min as data2).




For advanced programming of multi-data in multiple charts, search for:
Globalvariable v2.2,
ELCollections,
ADE (All Data Everywhere).

[NEW Keywords]
i_getplotvalue
i_setplotvalue

-------------------------------------------------------
Has this post been helpful?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

(5) Data2

Postby TJ » 29 Aug 2010

[FAQ] Data2

Question:
I want to plot a MACD based on data2, but it does not work.

here's my code:

Code: Select all

Macd2 = MACD( close data2, FastLength, SlowLength ) ;


Answer:
This is what you need to do:
1. Specify data2 in your Variable Declaration.
2. Add data2 to the end of the statement.


e.g.
Var: Macd2( 0, data2 );

Macd2 = MACD( close, FastLength, SlowLength ) data2 ;

Same treatment is used for moving averages and other indicators:
e.g.
Var: MA2( 0, data2 );

MA2 = Average( close, Length2 ) data2;
Same treatment for Reserved Words:
e.g.
Var: Close2( 0, data2 );
Var: Ticks2( 0, data2 );

Close2 = Close data2;
Ticks2 = Ticks data2;

Note: As a practice, you should always use the fastest resolution as data1.
eg. 1 min as data1, 5 min as data2.


-------------------------------------------------------
Has this post been helpful?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

(6) Numeric Variables

Postby TJ » 19 Sep 2010

(6) [FAQ] Numeric Variables

Trade-Station supports Int, Float and Double,

MultiCharts supports Double.

The explicit declaration of Double will ensure compatibility in both TS and MC.

viewtopic.php?t=6693&highlight=double




[NEW] Int64 data type is now supported in MultiCharts v10
Integer (-9223372036854775808 to 9223372036854775807)

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

(7) [FAQ] SetExitOnClose

Postby TJ » 17 Jan 2012

(7) [FAQ] SetExitOnClose

Question:
Why doesn't my SetExitOnClose work?


Answer:
from EasyLanguage® Functions & Reserved Words Reference ... pg. 1029

SetExitOnClose is a built-in stop reserved word used to place an order to exit all shares or contracts in all positions on the close of the last bar of the trading session on an intra-day chart.

For historical simulations, SetExitOnClose generates a market order on the bar close event of the last intra-day bar for each day in the chart.

When used in an automated strategy placing real-world orders, SetExitOnClose generates
a limit order into the post market trading session, (if one exists), otherwise a market order is generated for the open of the next regular session day.

::

Note
When automating a strategy, you will not want to use SetExitOnClose as a way to make sure that all of your positions are closed prior to the regular session end time. To do this, you will need to generate a closing order prior to the last bar in the chart.

ps. Most brokers require the last order be submitted 3 minutes before closing time. Please make sure you give your order sufficient time to reach the exchange floor.


you can try something like this (for minute chart):

Code: Select all

input: last.order.time(1545); // send last order at 3:45 pm if time >= last.order.time then begin sell... buytocover... end;


-------------------------------------------------------
Has this post been helpful?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

(8) [FAQ] MaxBarsBack

Postby TJ » 01 Sep 2012

(8) [FAQ] MaxBarsBack
So, is there a calculation mechanism or an error in the code which prevent the script to obey the Max Bars Back parameters set?
MaxBarsBack value totally depends on your script. For example, if your script references 50 bars back in its calculation, then the MaxBarsBack value should be set at least to 50. If it is set to 100, first 50 bars will be in fact ignored, next 50 bars will be considered in script calculation and its results on bar # 101. If MaxBarsBack value is set to, let's say 25, it will be automatically increased until the number is ok for the script calculation.

By the way, the step to increase the value will not always be the same. If you need 50 MaxBarsBack and it is set to 25, in the end it may become 65 (script tried 45, 45 is not enough, next variant is 65, 65 is ok, leave it 65).
If you don't reference any bars back, for example the whole script is "plot1(close);", MaxBarsBack value is 0.
viewtopic.php?f=1&t=10853&p=53671#p53601

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

(9) [FAQ] How do I make a Spread Chart?

Postby TJ » 04 Oct 2012

(9) [FAQ] How do I make a Spread Chart?

You can plot the spread between 2 instruments with
the built-in indicator Spread-Diff.

You can also plot the ratio with
the built-in indicator Spread-Ratio.


Additional readings in Wiki
Spread and Pair Trading
https://www.multicharts.com/trading-sof ... ir_Trading

Portfolio Trading
https://www.multicharts.com/trading-sof ... g_Strategy

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

(10) [FAQ] Scanner -- Multi data series ?

Postby TJ » 12 Oct 2012

(10) [FAQ] Scanner -- Multi data series ?
Hi there,
May I write indicator code to get data2 information on market scanner?
I would like to compare 5 stock, could I write indicator to get the close of data2 to data5
in order to do some calculation. Thanks!
Charles
Only data1 is available in the scanner, you can reference only it.
viewtopic.php?f=1&t=11119#p54943

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

(11) [FAQ] Volume Value Incorrect

Postby TJ » 17 Oct 2012

(11) [FAQ] Volume Value Incorrect
hi, i used the following code:

Code: Select all

Print(Volume);
I read the log file, the volume data is never the same as the volume in the Volume Avg indicator.
Please look up the definition and usage examples of the following keywords:
https://www.multicharts.com/trading-sof ... /Main_Page

VOLUME
TICKS
UPTICKS
DOWNTICKS
OPENINT


hint: Check the keyword used in the Volume Avg indicator.




This table can help you visualize all the keyword usage at a glance.

EasyLanguage Essentials Programmers Guide
Appendix A... Volume Reserved Words Usage Tables.... pg 129

https://bit.ly/3tY8CuE

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

(12) [FAQ] Date and Time

Postby TJ » 01 Nov 2012

(12) [FAQ] Date and Time

How do I add 10 minute to TIME when the time is 955?
If I add 10 to 955, I will get 965 instead of 1005.
Please read:

EasyLanguage Reference Guide
CHAPTER: 2 - The Basic EasyLanguage Elements
Manipulating Dates and Times .... pg. 15


ps. you can google for a copy of this ebook.


Return to “MultiCharts FAQ”