problem order next bar

Questions about MultiCharts and user contributed studies.
turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

problem order next bar

Postby turbofib » 26 Oct 2014

hi,
i've signal in multiframe

i want to enter long next candle if price >high

i write this instruction:

Code: Select all

if open next bar>high(of this candle) and marketposition=0 then Buy ("buy") next bar at x stop;
I See the following error (see pics )
Attachments
Error.png
(16.98 KiB) Downloaded 1005 times

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

Re: problem order next bar

Postby TJ » 26 Oct 2014

hi,
i've signal in multiframe
i want to enter long next candle if price >high
i write this instruction:

Code: Select all

if open next bar>high(of this candle) and marketposition=0 then Buy ("buy") next bar at x stop;
I See the following error (see pics )
Strategies are calculated at the END OF BAR.

ie. At the split second that is EOB, everything is "stopped"... At that moment, MultiCharts would assemble all the pertinent information, eg. O, H, L, C, V, plus the value of the variables... THEN the logics are evaluated. If a BUY/SELL condition is met, an order will be fired off in the next tick.

If you want the value of something from the next bar to be included in your calculation, you will have to wait until the next bar to make the BUY/SELL calculation.

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: problem order next bar

Postby turbofib » 26 Oct 2014

I can do it..if i set order intrabar=true?

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

Re: problem order next bar

Postby TJ » 26 Oct 2014

I can do it..if i set order intrabar=true?
If you want to use the OPEN price of the current bar in your logic, and want to trade immediately,
you can use IOG to trigger an order in the same bar.

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: problem order next bar

Postby turbofib » 27 Oct 2014

if i have signal multiframe is possibile use IOG ?

Which instruction I have to write to go long on the break of the current candle?
(with IOG)
thanks

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

Re: problem order next bar

Postby TJ » 27 Oct 2014

if i have signal multiframe is possibile use IOG ?
Your order timing is always based on data1.
Which instruction I have to write to go long on the break of the current candle?
(with IOG)
thanks
Don't understand your question.

Please see post #4
Multi-data strategy... pg. 34
viewtopic.php?f=16&t=6929

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: problem order next bar

Postby turbofib » 27 Oct 2014

i see you link ..but i not found it


i want to enter long next candle if price >high

Code: Select all

if open next bar>high(of this candle) and marketposition=0 then Buy ("buy") next bar at x stop;
is not corret..it give me an error..

Can you help me to code this instruction? thanks

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

Re: problem order next bar

Postby JoshM » 28 Oct 2014

i want to enter long next candle if price >high

Code: Select all

if open next bar>high(of this candle) and marketposition=0 then Buy ("buy") next bar at x stop;
is not corret..it give me an error..

Can you help me to code this instruction? thanks
I think you can try something like the following, although I'm not sure if I fully understand you:

Code: Select all

[IntrabarOrderGeneration = true];

Variables:
buyStopPrice(0);

if (BarStatus(1) = 2) then
buyStopPrice = x;

if (MarketPosition(0) = 0) then begin

if (Open > High[1]) then
Buy ("Buy") next bar at buyStopPrice stop;

end;
In the code, you likely want to calculate `buyStopPrice` on the bar close (hence the `BarStatus` check) so that this variable is not updated intrabar. Otherwise, the buy stop price can change with every price update, leading to a stop price that is never hit.

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: problem order next bar

Postby turbofib » 28 Oct 2014

Thanks you....i try it..

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: problem order next bar

Postby turbofib » 28 Oct 2014

i write this code :

Code: Select all


Inputs: Strength(2);

value1=swinghigh(1,h,Strength,80);
value2=swinglow(1,l,Strength,80);

if currentbar>200 then begin

[IntrabarOrderGeneration = true];

if (BarStatus(1) = 2) then begin

if high>value1 then buy("buy") next bar at value2 stop;


end;
end;
But i see it don't entry to break fractaline,but in the candle next

I want signal entry to break fractal
Attachments
Immagine.png
(8.74 KiB) Downloaded 995 times

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: problem order next bar

Postby Henry MultiСharts » 29 Oct 2014

turbofib, please validate your order generation conditions and follow these instructions to make indicator and signal calculation results the same.
You can also use i_setplotvalue and i_getplotvalue (introduced in MultiCharts 9.0 Beta 1). It allows sending info from signal to indicator in order to see which values it actually uses, help to avoid excessive programming and eliminate discrepancies between indicator and signal.

faraz
Posts: 144
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 57 times

Re: problem order next bar

Postby faraz » 29 Oct 2014

hi,
i've signal in multiframe

i want to enter long next candle if price >high

i write this instruction:

Code: Select all

if open next bar>high(of this candle) and marketposition=0 then Buy ("buy") next bar at x stop;
I See the following error (see pics )

you don't need IOG for this. Try this below code.

Code: Select all

if open tomorrow>high and marketposition=0 then buy next bar at 1 Stop;

Note: "Open Tomorrow" included strategies got limitations for example like;
a) it will not allow you to use "This bar on close" in the strategy
b) You can not use bar magnifier
c) you can not use IOG

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: problem order next bar

Postby turbofib » 29 Oct 2014

you write :

Code: Select all

if open tomorrow>high and marketposition=0 then buy next bar at 1 Stop;


the trading system is not daily but intraday...

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: problem order next bar

Postby turbofib » 29 Oct 2014

turbofib, please validate your order generation conditions and follow these instructions to make indicator and signal calculation results the same.
You can also use i_setplotvalue and i_getplotvalue (introduced in MultiCharts 9.0 Beta 1). It allows sending info from signal to indicator in order to see which values it actually uses, help to avoid excessive programming and eliminate discrepancies between indicator and signal.

i read in your link : "On the historical data indicator, only values on bar close are calculated"


how to see if a proper backtesting does not come at the right time?

faraz
Posts: 144
Joined: 25 Feb 2011
Has thanked: 26 times
Been thanked: 57 times

Re: problem order next bar

Postby faraz » 29 Oct 2014

you write :

Code: Select all

if open tomorrow>high and marketposition=0 then buy next bar at 1 Stop;


the trading system is not daily but intraday...

turbofib

Code: Select all

if open tomorrow>high and marketposition=0 then buy next bar at (c+1) Stop;
Why you did not tested it? It works on both daily and intraday bars.

Run this print command on your intraday bars to get the figures printed for your satisfaction.

Code: Select all

if open tomorrow <> c then Print(D," ",T," ",O," ",H," ",L," ",C," ",open tomorrow);
Thanks

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: problem order next bar

Postby Henry MultiСharts » 31 Oct 2014

i read in your link : "On the historical data indicator, only values on bar close are calculated". how to see if a proper backtesting does not come at the right time?
You need to output the values your code is using to understand what goes wrong. Here is a sample code that you can adjust to your needs.


Return to “MultiCharts”