[FAQ] Autotrade / Backtest / Optimization

Read before posting.
User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

[FAQ] Autotrade / Backtest / Optimization

Postby TJ » 21 Aug 2012

1) Autotrade / Backtest / Optimization FAQ

START HERE:
The Wiki is a very useful resource
click this first>>> https://www.multicharts.com/trading-sof ... acktesting
click this next>>> https://www.multicharts.com/trading-sof ... tegory:FAQ


Relevant articles in Wiki: General/Overview
- Getting Started with AutoTrading
- How Scripts Work
-->How Signals are Calculated
- Order Execution Priority
- Auto Trading
- Understanding Automated Trade Execution
- Comparison of Synchronous and Asynchronous Mode

Relevant articles in Wiki: Fundamentals
- Backtesting vs Live Trading
- Understanding Backtesting
- Why is Data Playback strategy performance different from Backtesting results?
- Intra-bar Price Movement Assumptions
- MaxBarsBack

Relevant articles in Wiki: Intermediate level readings
- Precise Backtesting
- Understanding Precise Backtesting
- Using Precise Backtesting
- Bar Magnifier
- Intra-Bar Order Generation, Bar Magnifier on Non-Standard Chart Types

Relevant articles in Wiki: Additional readings
- How to make indicator and signal calculation results the same
- Trades vs Orders With PosTrade Keywords
- Trading from Multiple Charts on One Instrument
- Manual Trading and Automated Trading on the Same Instrument at a Time
- Realtime-History Matching

Relevant articles in Wiki: Portfolio
- Understanding Portfolio Backtesting
- Backtesting a Portfolio
- Portfolio Optimization
- Additional info on Portfolio: FAQ - Portfolio Trader / Portfolio Backtester





-------------------------------------------------------
Has this post been helpful to you?

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

2) Autotrade -- Before You Start

Postby TJ » 21 Aug 2012

[FAQ] Before You Start


Before you jump head first into coding a strategy...

1. Understand that Autotrading is NOT Unattended Trading. NO amount of automation can prepare you for the unknown and/or the unexpected.

2. Build intelligence into your code -- your strategy should always check for your positions at the broker; that's where your money is.

3. Start with an indicator;
especially if you are new to programming,
Instead of jumping head first into coding a Strategy/Signal, start by coding an indicator first:
Wherever you think you have a BUY or SELL signal, make a PLOT on the chart to indicate your trigger point.
Can you see the plot?
Ask yourself this question: is my logic triggering the right signal at the right place? at the right time?
If not, why not? (See next post for debugging)

eg. If your logic is

Code: Select all


If close cross above SMAvalue then BUY...

You can begin your coding process by plotting a large dot at the SMAvalue,
so that you can see that this event can actually take place,
and that C was able to cross above this value to trigger a BUY order.

eg.

Code: Select all


If close cross above SMAvalue then PLOT1( SMAvalue, "Buy.Signal" ); // set PLOT as a point



When you have verified all the variables are valid,
and your logic works (as shown by the plots on the chart),
you may then convert the indicator into a strategy.
If you skip this step, you will invariably find yourself starting again, back here, where you should have started your coding process in the first place.







.

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

3) Autotrade FAQ

Postby TJ » 21 Aug 2012

[FAQ] Learn to Debug


1. Know Your Data -- GIGO -- Before you start your debug, make sure you have clean data.


2. Know Your Variables -- Get rid of your generic variable names. ie. value1, var1, condition1, etc., and replace them with meaningful names.

Who can tell what this is about??? Who wants to debug this mess???

Code: Select all

value5 = ((value1+value4)/(value2*value3));
Variable names are free. You should use names that reflect the operation of your logic.
Otherwise you will be wasting time going back and forth trying to figure out what the variables are used for.

eg. Which variable name makes more sense?

value4 = Average( Close, 20 );

Avg20 = Average( Close, 20 );



3. Know Your Logic -- Add lots of comments to your code.
You will appreciate them 3 months later when you try to revise your code.


4. Know Your Values -- Pepper your code with PRINT when debugging

You should add PRINT statements at all the pertinent junctions of your logic.

Every time you have an operation that changes the value of a variable,
you should splice a PRINT statement in there, so that you can verify the results of the operation is as expected.


5. Know Your BEGIN/END

Code: Select all


If Up.Trend = true then
BEGIN
     //
     // your code
     //
END;  <-- Indent your codes so that you can visually match an END for each BEGIN



6. Know Your Limitations -- See post #1 of this thread.





------------------------------------------
Has this post been helpful to you?

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

4) IntrabarOrderGeneration (IOG) in Backtesting

Postby TJ » 21 Aug 2012

[FAQ] IntrabarOrderGeneration (IOG) in Backtesting


Hi Henry
I enabled [IntrabarOrderGeneration = true]; but back test still shows exit at close of 3 min bar even i put in tick data.

Henry Multicharts wrote:
Enabling IOG does not make your strategy to be calculated on the tick data in backtesting. Enabling IOG makes the script to be calculated four times on OHLC (of main data series bar).
If you want your strategy to be calculated on 1 tick data you need to enable Bar Magnifier.

Here is how the calculation will be performed for MC 8.0 beta 3 and higher:

Scenario A: Calculation on historical data. Regular mode. No IOG. No Bar Magnifier.
The script is calculated on the bar close. It is considered that all prices were within the bar (Price movement assumption is used). Order filled on any price within the NEXT bar.

Scenario B: Calculation on historical data. IOG enabled. No Bar Magnifier.
The script is calculated four times on OHLC. MultiCharts considers that there were only OHLC values->order is filled only on OHLC prices.

Scenario C: Calculation on historical data. IOG and Bar Magnifier enabled.
The script is calculated on the Open value of the main data series, then OHLC of each bar of the detailed data series selected in bar magnifier (Price movement assumption is used), then on the Close of the main data series. Order is filled only on these O-OHLC-C values.

Scenario D: Calculation on historical data. No IOG. Bar Magnifier enabled.
The script is calculated 1 time on main data series close. MultiCharts considers that there were only OHLC values of the detailed data series->order is filled only on OHLC prices.


Source:
viewtopic.php?f=1&t=10352&p=50828&hilit=intrabarordergeneration#p50828


more readings:
How Signals are Calculated

Non-Standard Chart Types
Intra-Bar Order Generation, Bar Magnifier on Non-Standard Chart Types



---------------------------------------
Has this post been helpful to you?

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

5) Built-In Stops / Profit Targets / OCO Orders

Postby TJ » 24 Aug 2012

[FAQ] Built-In Stops / Profit Targets / OCO Orders


New Traders wrote:Questions:
-- Why is my SetStopLoss not executed?

-- How to code an OCO order?
-- 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 Marketposition <> 0 and 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
SetExitonClose


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

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

* automatic means you do not need to code a logic to withdraw the orders,
they will be cancelled by MultiCharts' Strategy Engine automatically 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 ;

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.

(NEW) [Q&A] Understanding Complex OCO scenario
viewtopic.php?f=1&t=48001

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

EasyLanguage Reference Guide
Understanding Built-in Stops.......... pg. 132


Order types supported by various brokers:
https://www.multicharts.com/brokers/
https://www.multicharts.com/trading-sof ... rder_Types
https://www.multicharts.com/trading-sof ... r_Profiles
.


---------------------------------------
Has this post been helpful to you?

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

6) SetExitOnClose

Postby TJ » 24 Aug 2012

[FAQ] SetExitOnClose


Question:
Why doesn't my SetExitOnClose work?



Answer: from EasyLanguage® Functions & Reserved Words Reference

EasyLanguage® Functions & Reserved Words Reference wrote:
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.


ie. SetExitOnClose is for backtest only, not for real trades.

ps. Most brokers require the last order be submitted 3 minutes before closing time. Please check with your broker and make sure you are giving your order sufficient time to reach the exchange floor.


If you want to exit all positions before end of day, you have to code the exit manually.
eg. For a 5 min bar chart, and the closing time is 1600, you can try something like this:

Code: Select all

input:
Last.Order.Time(1555);

if Time >= Last.Order.Time then
begin
    SELL ...
    BUYTOCOVER ...
end;


or, use your computer clock (note: this will not work in backtest)

Code: Select all

input:
Last.Order.Time(1555);

if CurrentTime >= Last.Order.Time then
begin
    SELL ...
    BUYTOCOVER ...
end;



.

ps. Look up the keywords:
LastBarOnChart
IntraBarOrderGeneration




---------------------------------------
Has this post been helpful to you?

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Autotrade FAQ

Postby TJ » 28 Aug 2012

[FAQ] This Bar on Close

New Trader wrote:Hi,
I have some problems with the order „sell this bar on close“ on a DayChart.
It tries to close the position after the market is close and it varies from 9 sec to 4 min after the market closed. Of course all the Market orders to sell are rejected.


BUY/SELL this bar on close ...is for backtest only.

Please read the explanation in:

EasyLanguage Essentials Programmers Guide
Strategy Order Syntax.... pg 80

EasyLanguage Essentials Programmers Guide wrote:
Order Actions

This Bar on Close: Market order on the close of this bar, generally used for historical backtesting purposes only. This will not generate a market on close order.



you can google for a free copy of this ebook.



---------------------------------------
Has this post been helpful to you?

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Autotrade FAQ

Postby TJ » 04 Sep 2012

[FAQ] Multiple Broker Accounts

Question:
I have 3 futures broker accounts. Can MC send orders to each broker for the same strategy or do I have to have 3 different workspaces?

Andrew MultiCharts wrote:
In MultiCharts a strategy on chart can place orders only for 1 account a time. Other words, 1 chart = 1 account.

If you have 3 accounts under 1 login (1 broker profile, 3 accounts) you will need 3 separate chart windows trading individually on each of the accounts (specified in broker plug-in configuration).

If this is Financial Advisor (FA) or Family and Friends account from IB or PAMM account from FXCM, all orders can be sent from 1 chart to master account and then they are allocated to subaccounts on broker end.




Additional information:
Multiple IB Accounts
viewtopic.php?f=16&t=9858

The Wiki is a useful resource:
How To Connect Multiple Interactive Brokers Profiles
https://www.multicharts.com/trading-sof ... s_Profiles



---------------------------------------
Has this post been helpful to you?

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Autotrade FAQ

Postby TJ » 18 Sep 2012

[FAQ] Autotrade Lost Connection

Question:
We use some simple strategy - it opened position and some times later connection was lost and autotrading off - we turn it on manually.

Strategy after turning on don't show position (it has it - it was still open at account) and don't manage it . Strategy was open on daily bars - bar doesn't end (that was same bar it opened position).

What should we do in order to strategy manage position (opened before) after turning on again (after connection lost) ?

Henry MultiСharts wrote:Hello,

When auto trading is turned off - the strategy position becomes zero.
You need to specify the position manually for each strategy next time you turn on the auto trading if you have a position at the broker. Please do the following:

Format-> Strategy properties-> Auto trading-> Assign the initial market position at the broker setting->Show the assign the initial market position at the broker dialogue-> Show always-> Ok.

When you start the auto trading - a dialogue window will appear where you can set the position for the strategy. This is how you can synchronize it (continue the trading from the position where you have left it).

You can also synchronize your strategy and broker position automatically with the help of the synchronizer script (!From Broker To Strategy MP Synchronizer!). But position at the broker cannot be divided between multiple strategies automatically by means of the "synchronizer" script. If you are trading with multiple strategies on one instrument - you need to assign the position manually for each strategy.

!From Broker To Strategy MP Synchronizer! - Synchronizes the market position inside MultiCharts with the market position at broker by sending a dummy order in charting.

viewtopic.php?f=1&t=10456&p=50934#p50934


[new]
How to make a No Realtime Data Alert
viewtopic.php?f=16&t=11715


[FAQ] Setting Up Email Alert
post #13
viewtopic.php?f=16&t=6845

[FAQ] SMS Alert (Text message)
viewtopic.php?f=16&t=11738&p=54077




------------------------------------
Was this information helpful?

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Autotrade FAQ

Postby TJ » 26 Sep 2012

[FAQ] Backtest results different from Live Trading

Question:
Is there a wiki for 'IntrabarOrderGeneration' strategy coding development/execution and debug?
I have a 1min strategy with IntrabarOrderGeneration=true and I have noticed quite a big difference between live results and back tested results
I noticed that I had not the bar magnifier set to tick data so I am trying that now.
Rather than 'guessing' this I would like to know if there is something like a 'wiki' available based on this development and testing available?
Please advise. Thanks

Henry Multicharts wrote:It is expected that real-time strategy calculation and trading results (live broker account, demo broker account, playback etc...) are different from the performance results generated during backtesting.

• In real-time trading the order is filled according to market dynamics on Bid and Ask prices taking Volume into account. The order may not be filled in real-time trading because of insufficient volume at the broker. In backtesting and real-time strategy calculation the order is filled on the main data series price without taking Volume into account.

• In real-time trading, a strategy will monitor and respond to a data feed on tick-by-tick basis. However, the historical data available for backtesting will, in most cases, be in the form of bars based on a group of ticks, with only Open, High, Low, and Close prices available. While it is not possible from these four values to infer the actual price movement within each bar, the Backtesting Engine improves the backtesting accuracy by incorporating intra-bar price movement assumption logic

• Different detalization and strategy calculation methods can be selected which will produce different results.

    • [edited] Back Testing

    IOG

    Bar Magnifier

      1. If you are not using IOG mode for your signal then the signal is calculated on the close of the bar.

      2. In realtime with IOG enabled the script is calculated tick by tick.

      3. Without IOG on history-the script is calculated on the bar close.

      4. With IOG enabled on history-the script is calculated four times on OHLC of the bar.

      5. Bar magnifier is a separate feature for backtesting. Bar magnifier does not affect realtime calculation. Please find more information at the Bar Magnifier wiki page.

• There are differences in real-time data and historical data that affect the strategy calculation results. You should understand how chart bars are built. A single tick difference between real-time and historical backfilled data can generate completely different looking charts. This in turn would impact the calculations of your strategy.

• The difference in strategy calculation is especially seen on certain chart types (e.g. Point and Figure) than others due to their inherent nature in bar formation. Please refer to this page for more details.
This is why you may see orders not fill in real-time strategy calculation or real-time strategy trading compared to your backtesting results.

viewtopic.php?f=1&t=10228&p=49397&hilit=intrabarordergeneration+time+based#p49397

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Autotrade FAQ

Postby TJ » 06 Nov 2012

[FAQ] A good discussion on Optimization

Custom Criteria – creating your own optimization criteria
viewtopic.php?f=5&t=8838



Image

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: [FAQ] Autotrade / Backtest / Optimization

Postby TJ » 08 Nov 2012

[FAQ] How Stop Order Works

NewTrader wrote:An IB stop order in TWS will change into a marketorder if the stoporder price is hit.

When you use a stop order in a strategy like this:

Code: Select all

if marketposition = 1 then begin
Sell ("StopLossLong") next bar "your stop price" stop;
end;


And you have for example 2000 stocks which are not filled immediately but for example 200, ten seconds later 500 and thirty seconds later the rest. The strategy (I use IOG) will keep sending the stop again till every stock is sold. Resulting in IB thinking it is a new stop order which is hit immediately but giving extra transaction costs.

Is the stoporder that is sendout by MC also converted to market order at IB? and how to stop the strategy from sending the stoporder over and over again when the stoporder is already hit but not all stock are sold yet?



Andrew MultiCharts wrote:Hello,

If an order is sent to broker and the parameters of the order are not changed, MultiCharts will not send the same order to broker to "maintain" it. In your particular case, if from the moment the initial stop order is sent, your script doesn't generate a different stop (it can happen only if the order gets new parameters or the OCO group of the order is cancelled to be replaced by a new OCO group of orders, so the initial partially filled order has to be cancelled), no new order will be sent. MultiCharts will wait till the initial stop order is filled.

As for handling the stop orders when IB is the broker, they support stop orders, so the orders are sent directly to them and are filled on their end.


More discussion and explanations here:
viewtopic.php?f=1&t=11270&view=unread#p55667

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: [FAQ] Autotrade / Backtest / Optimization

Postby TJ » 14 Nov 2012

[FAQ] Backtesting vs Optimization CPU Usage -- Single Core vs Multi-Core


Stan Bokov MultiCharts wrote:
Strategy recalculation (backtesting) and strategy optimization are two very different things.

During backtesting only one core can be used, because the process is sequential, i.e. it depends on previous results to obtain a result at a later date. It cannot be split up into multiple cores.

Optimization on the other hand can be split up into multiple cores because it consists of many iterations of the same thing, but with different inputs.

viewtopic.php?f=1&t=8739&p=41127&hilit=single+core#p41116




On **optimizing** Optimization -- Multi-Core, Multi-Thread, Multi-CPU
Yves BENOIT wrote:For information,

2 years ago, I did several tests with a 4 CPU x 16 cores from HP.
with same results: very low cpu usage.

We had to perform the last test in an HP certified lab.
An AMD high tech specialist finally brought the explanation:
every RAM slot has to be populated. If not, CPU usage is bounded, for some (stupid) unknown technical reason.

So instead of putting 4 x 8 GB (1 per CPU), we put 16 x 2GB (4slots/cpu x4cpu), and it worked: we obtained 100% CPU usage. It was not the global quantity of Ram, which matters, but the physical presence of any Ram in each slot. Actually, probably 8GB total RAM would have been enough.

So Multicharts ( 8 beta3) was not in cause.

Please note that the speed gain between another computer with 1 CPU x 16 cores and this one 4 CPU x 16 cores was less than 3 times… :(
It means that, probably, a 1 CPU with 64 cores would do much better.




For Portfolio Trader, please study how Portfolio Calculation is done:
Portfolio_Trader#Script_Calculation_and_Raw_Order_Generation
Portfolio_Script_Calculation_Diagram
Sequence diagram for portfolio keywords calculation example

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: [FAQ] Autotrade / Backtest / Optimization

Postby TJ » 24 Nov 2012

[FAQ] Multi-data strategy, Realtime-history matching

Question:
I have a quick question. Signals are evaluated at the end of the bar unless IOG is selected. But how does it work for multi-series signal scripts ?
lets say my base chart is on a 3-tick Renko and I add another series which is 5-tick Renko. For most bars the 'End of Bar' for 3-tick Renko and 5-tick Renko would be different.
So are the signals evaluated for end of bars for 3-tick and 5-tick Renko ? or just end of bar for 3-tick (base series) ?
Hope I'm clear in what I'm asking. Thanks in advance for your help

Roman MultiCharts wrote:
Hello,

Calculation of a study based on several data series can be done in two ways. Realtime-History Matching option allows selection of calculation type:

1. When Realtime-history matching option is enabled the signal/indicator is calculated on the latest bar of the main data series and on the currently completed bar of the auxiliary data series. If the auxiliary data series stops updating, the final calculation will be made on the main data series bar that was received immediately after the latest bar of the auxiliary data series. In this case no further calculation will be performed.

2. When Realtime-history matching option is disabled the signal/indicator is calculated on the basis of the main data series latest bar and current (completed or not) bar of the auxiliary data series. If the auxiliary data series stops updating, the calculation will continue on the basis of the latest bar of the main data series and the open bar of the auxiliary data series.

For more information, please visit this article of our MC Wiki.



viewtopic.php?f=16&t=10553

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: [FAQ] Autotrade / Backtest / Optimization

Postby TJ » 10 Jan 2013

[FAQ] Limit the Time of Autotrade

Question:
How do I limit a strategy to trade only a specific period of time.
eg. from 10 am to 2 pm only?


Answer: see sample code below:

Code: Select all

input:
start.time(1000),
end.time(1400);

if time >= start.time
and time <= end.time then
BEGIN
     //
     // put your autotrade code here:
     //
END;

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: [FAQ] Autotrade / Backtest / Optimization

Postby TJ » 18 Jan 2013

[FAQ] How to Optimize a Strategy by Linear Equity Curve

viewtopic.php?f=5&t=11769

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: [FAQ] Autotrade / Backtest / Optimization

Postby TJ » 13 May 2013

[FAQ] Results difference for Backtest in Portfolio Backtester and MultiCharts

viewtopic.php?f=1&t=9794

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: [FAQ] Autotrade / Backtest / Optimization

Postby TJ » 19 Jun 2013

[FAQ] Multiple Time Frame, Multi-Data Analysis

Question:
I was wondering if someone knew a way to run multiple time frames of multiple instruments 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 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


Getting Started with TS EasyLanguage
Multi-data strategy... pg. 43




Note: you can google for a free copy of the above 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, do a search for:
Globalvariable v2.2,
ELCollections,
ADE (All Data Everywhere).


[NEW Keywords]
i_getplotvalue
i_setplotvalue



---------------------------------------
Has this post been helpful to you?

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: [FAQ] Autotrade / Backtest / Optimization

Postby TJ » 23 Dec 2014

[FAQ] Trading Multiple Instruments

Henry MultiСharts wrote:Hello,

By default from one chart you can trade only the instrument that is the main data series. You cannot send orders to any additional data series of the same chart. You need to have an individual chart for each instrument you want to trade.

That is possible to use the Portfolio Trader introduced in MC 9.0 to automate order execution for multiple instruments. You can find more details regarding the new portfolio trading here:

Portfolio Trader Manual:
https://dl.dropboxusercontent.com/u/951 ... Manual.pdf

Portfolio Trader Strategy Examples:
https://dl.dropboxusercontent.com/u/951 ... amples.pdf



More readings and discussions here:

[FAQ] Portfolio Trader / Portfolio Backtester
viewtopic.php?f=16&t=47045

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Autotrade FAQ

Postby TJ » 18 Feb 2016

[FAQ] Backtest, Playback, IOG and Bar Magnifier


Question:

Regarding the IOG, i've got a problem, if i turn on IOG in the strategy, when i do the backtesting, will the system simulate in a way that it read every tick to see whether the buy signal trigger in the middle of the bar, or it only runs at the close of the bar?

the reason i have this question is that when i use the playback function of multicharts, it will only playback one bar each time, but not simulating the real situation and playback every tick, so i wonder if the IOG function can work in the backtesting procedure.

thanks


Henry Multicharts wrote:In realtime with IOG enabled the script is calculated tick by tick.
Without IOG on history-the script is calculated on the bar close.
With IOG enabled on history-the script is calculated four times on OHLC.

In Backtesting you can use Bar magnifier
(Strategy Properties -> the Backtesting tab -> Backtesting Precision section -> select Use Bar Magnifier).

The Bar Magnifier backtest feature is important for precise backtesting.
Bar magnifier can be considered as a replay of the way a bar was formed.
The user can choose a replay frequency that is based on number of ticks or
number of minutes.

With IOG and Bar Magnifier enabled the script will be calculated on the close of each bar of detailed data series selected in bar magnifier + high/low of the main data series.

Also you can read about this feature in the Help section of Multicharts.
viewtopic.php?f=1&t=9343&p=44626#p44626

More Readings:
How Signals are Calculated

Additional Explanation:
Backtest and IOG, Bar Magnifier
viewtopic.php?f=16&t=10811&p=119777#p53292



-----------------------------------------
Has this post been helpful to you?

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Autotrade FAQ

Postby TJ » 18 Mar 2016

[FAQ] Slippage

Henry MultiСharts wrote:
In backtesting:
By default the slippage is not calculated for stop limit and limit orders as there is no slippage when such type of order is filled at broker. Limit order can be filled at the specified price or better price.

Slippage is calculated for market and stop orders. It is deducted from profit.

If you still want to have slippage calculated for stop limit and limit orders – you can enable an option in the registry editor:
HKEY_CURRENT_USER\Software\TS Support\%your version of MultiCharts%\StrategyProp
Change the value of "UseSlippageForAllTypes" key to 1.
1 = slippage for all orders
0 = slippage for market and stop orders only

In auto trading:
By default commission and slippage are not applied to any orders. But since MultiCharts 9.0 we
have added a registry key to disable/enable counting commission and slippage for special orders (SetStopLoss, SetProfitTarget, etc). One can configure UseCommissionForSpecOrders in:
HKEY_CURRENT_USER\Software\TS Support\%your version of MultiCharts%\StrategyProp.
0 - default value (commission and slippage are not applied).
1 - special orders correct the price upwards (for Long orders) and downwards (Short) to compensate the potential loss.

You will need to restart all MultiCharts processes to have these changes applied.


viewtopic.php?f=1&t=49579&view=unread#p120370

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Autotrade FAQ

Postby TJ » 15 Apr 2016

[FAQ] Code to Cancel Orders at Session End before after hours

viewtopic.php?f=1&t=46449&p=104194




Tags:
RecalcLastBarAfter
AllowSendOrdersAlways
IntrabarOrderGeneration

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Autotrade FAQ

Postby TJ » 15 Apr 2016

[FAQ] Closing Status of a Bar

viewtopic.php?f=1&t=10642&p=110364

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Autotrade FAQ

Postby TJ » 28 Apr 2016

[FAQ] [Advanced Topic] Semi-Discretionary Trading
[FAQ] [Advanced Topic] Semi-Automated Trading


Semi-Discretionary or Semi-Automated Trading
viewtopic.php?f=1&t=10817

Automated Exit Strategy with Manual Trading
viewtopic.php?f=16&t=8499



Tags:
!From Broker To Chart Strategy!
!From Broker To Strategy MP Synchronizer!
AvgEntryPrice_at_Broker




---------------------------------------
Has this post been helpful to you?


Return to “MultiCharts FAQ”