Getting Profit Target to analyze Data2 and Data3

Questions about MultiCharts and user contributed studies.
M747
Posts: 25
Joined: 05 Feb 2016
Has thanked: 12 times
Been thanked: 2 times

Getting Profit Target to analyze Data2 and Data3

Postby M747 » 10 Feb 2016

Hello,

Can someone please show me what I'd add to MC's "Profit Target" signal's code (shown below) in order to get it to analyze Data2 and Data3 instead of Data1?

I tried doing it via the "Multi-Data Analysis" instructions on page 15 of this link http://bit.ly/1ShIdRK but could not get it to work.

(Note: on my chart Data1 displays Last prices, Data2 displays Bid prices and Data3 displays Ask prices)

The reason I want to do this is because I've ran into scenarios were the according Bid or Ask price reached my "Profit Target", but the Last price did not and therefore my "Profit Target" exit did not happen. I figure I can fix this issue by having the "profit Target" set to analyze Data2 and Data3.

Thanks!

Code: Select all

[IntrabarOrderGeneration = false]
inputs: PositionBasis( false ), Amount( 5 ) ;

if PositionBasis then
SetStopPosition
else
SetStopShare ;

SetProfitTarget( Amount ) ;
Last edited by M747 on 10 Feb 2016, edited 1 time in total.

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

Re: Getting Profit Target to analyze Data2 and Data3

Postby TJ » 10 Feb 2016

Hello,

Can someone please show me what I'd add to MC's "Profit Target" signal's code (shown below) in order to get it to analyze Data2 and Data3 instead of Data1?

I tried doing it via the "Multi-Data Analysis" instructions on page 15 of this link http://bit.ly/1ShIdRK but could not get it to work.

(Note: on my chart Data1 displays Last prices, Data2 displays Bid prices and Data3 displays Ask prices)

The reason I want to do this is because I've ran into scenarios were the according Bid or Ask price reached my "Profit Target", but the Last price did not and therefore my "Profit Target" exit did not happen. I figure I can fix this issue by having the "profit Target" set to analyze Data2 and Data3.

Thanks!

[IntrabarOrderGeneration = false]
inputs: PositionBasis( false ), Amount( 5 ) ;

if PositionBasis then
SetStopPosition
else
SetStopShare ;

SetProfitTarget( Amount ) ;
You cannot use global exits based on data2; you have to program the profit/stop exits yourself.

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

Re: Getting Profit Target to analyze Data2 and Data3

Postby TJ » 10 Feb 2016

ps. see post #1 and #2
[FAQ] How to Post Codes (... so that people can read)
viewtopic.php?f=16&t=11713

M747
Posts: 25
Joined: 05 Feb 2016
Has thanked: 12 times
Been thanked: 2 times

Re: Getting Profit Target to analyze Data2 and Data3

Postby M747 » 10 Feb 2016

Thanks for the tip TJ. I just edited my original post so that the code is easier to read.

M747
Posts: 25
Joined: 05 Feb 2016
Has thanked: 12 times
Been thanked: 2 times

Re: Getting Profit Target to analyze Data2 and Data3

Postby M747 » 10 Feb 2016

You cannot use global exits based on data2; you have to program the profit/stop exits yourself.
Hi Tj, I think I understand, but can you please elaborate a little more on this?

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

Re: Getting Profit Target to analyze Data2 and Data3

Postby TJ » 10 Feb 2016

You cannot use global exits based on data2; you have to program the profit/stop exits yourself.
Hi Tj, I think I understand, but can you please elaborate a little more on this?
SetStop and SetProfitTarget are call Global Exits.

They are set and forget keywords that do all the calculations for you in the background.

In your case, you have do write codes like this: (this is pseudo code only)

Code: Select all


Input: Profit.target.price(100);

If (Close data2) > Profit.target.price then SELL next bar at market;

M747
Posts: 25
Joined: 05 Feb 2016
Has thanked: 12 times
Been thanked: 2 times

Re: Getting Profit Target to analyze Data2 and Data3

Postby M747 » 11 Feb 2016

Thanks!

M747
Posts: 25
Joined: 05 Feb 2016
Has thanked: 12 times
Been thanked: 2 times

Re: Getting Profit Target to analyze Data2 and Data3

Postby M747 » 11 Feb 2016

Hello Again TJ.

Can you please show me a full code example of how I'd do this (to both the "Profit Target" and "Stop Loss") when using the following 3 signals (that come with MC) all at once? Happy to pay you for this code example if needed, please private message me your fee if so.

-"Bollinger Bands LE"
-"Profit Target"
-"Stop Loss"

Thanks again for everything!!!

P.S.
Also, are you saying that in my situation I could not send in a "Profit Target" and/or "Stop Loss" order (at the moment my position opens) that simply sits on my execution provider's server waiting to be filled?

Instead, my Algo would have to constantly monitor the changes in Bid/Ask prices and send in an exit order the moment the according Bid or Ask price has been reached?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Getting Profit Target to analyze Data2 and Data3

Postby JoshM » 13 Feb 2016

Also, are you saying that in my situation I could not send in a "Profit Target" and/or "Stop Loss" order (at the moment my position opens) that simply sits on my execution provider's server waiting to be filled?
Where the order is kept doesn't depend on the code or signal used, but on how MultiCharts communicates with the broker.

On the Wiki there's an overview that shows which order type for which broker is managed by the broker's server and which ones are emulated by MultiCharts: order types. There's also an overview on the brokers page: supported brokers.

M747
Posts: 25
Joined: 05 Feb 2016
Has thanked: 12 times
Been thanked: 2 times

Re: Getting Profit Target to analyze Data2 and Data3

Postby M747 » 17 Feb 2016

Thanks Josh!

M747
Posts: 25
Joined: 05 Feb 2016
Has thanked: 12 times
Been thanked: 2 times

Re: Getting Profit Target to analyze Data2 and Data3

Postby M747 » 17 Mar 2016

Hi TJ,

One follow up question regarding the code (shown below) you posted in post #6 of this thread.

Code: Select all

Input: Profit.target.price(100);

If (Close data2) > Profit.target.price then SELL next bar at market;
This code exits the trade if the Profit Target is >100 at the Close of the Data2 bar.

How can I change the code so that it exits the trade if the Profit Target becomes >100 antyime during the Data2 bar?

(FYI: This is assuming I have both "Bar Magnifier" and "Precise Backtesting" on during the backtest)

Thanks!


Return to “MultiCharts”