BarStatus, IOG question  [SOLVED]

Questions about MultiCharts and user contributed studies.
tozwp
Posts: 145
Joined: 15 Apr 2011
Has thanked: 16 times
Been thanked: 8 times

BarStatus, IOG question

Postby tozwp » 25 Mar 2014

Attempting to build a signal that will require IOG for stop management eventually. Currently stumped on what I thought would be simple. I have an entry based on an end of bar condition that works fine with IOG off. When I wrap the same code in a BarStatus check and turn IOG on, it doesn't work. Here is the code without IOG and with IOG. I'm missing something basic but can't figure out what it is.

IOG off (false)

Code: Select all

vars: Trig(0);
If H < H[1] and L > L[1] and MarketPosition <= 0 then begin //buy inside stick
Trig = High + 0.0001;
Buy("IP-L") 100 shares next bar at Trig Stop;
end;

If marketposition = 1 then begin //exit every trade for testing
sell next bar at open;
end;
IOG on (true)

Code: Select all

vars: Trig(0);
If BarStatus(1) = 2 then begin
If H < H[1] and L > L[1] and MarketPosition <= 0 then begin //buy inside stick
Trig = High + 0.0001;
Buy("IP-L") 100 shares next bar at Trig Stop;
end;

If marketposition = 1 then begin //exit every trade for testing
sell next bar at open;
end;
end;
Last edited by tozwp on 25 Mar 2014, 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

Re: BarStatus, IOG question

Postby TJ » 25 Mar 2014

[FAQ] How to Post Codes (that people can read)
viewtopic.php?f=16&t=11713

tozwp
Posts: 145
Joined: 15 Apr 2011
Has thanked: 16 times
Been thanked: 8 times

Re: BarStatus, IOG question

Postby tozwp » 25 Mar 2014

Thanks TJ, wasn't aware of how to do that. Fixed it.

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

Re: BarStatus, IOG question

Postby TJ » 25 Mar 2014

Attempting to build a signal that will require IOG for stop management eventually. Currently stumped on what I thought would be simple. I have an entry based on an end of bar condition that works fine with IOG off. When I wrap the same code in a BarStatus check and turn IOG on, it doesn't work. Here is the code without IOG and with IOG. I'm missing something basic but can't figure out what it is.
::
What do you mean by "it doesn't work"?

No orders were generated?
Wrong orders were generated?
Orders were generated late?
etc etc...

tozwp
Posts: 145
Joined: 15 Apr 2011
Has thanked: 16 times
Been thanked: 8 times

Re: BarStatus, IOG question

Postby tozwp » 25 Mar 2014

Basically, the results are very different between the two systems. The first identifies and trades on every inside bar. The second (on the 480 min AUD.CAD forex data that I am using) has one trade near the end of the data set on one inside bar. What I'm trying to understand is what is different by using the BarStatus to check and put the code inside that check. The way I understand it, that should be redundant and equal to the first code with IOG off and no BarStatus check.

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

Re: BarStatus, IOG question

Postby TJ » 25 Mar 2014

is this live trading? backtesting or forward testing?

These articles might help:
https://www.multicharts.com/trading-sof ... acktesting

tozwp
Posts: 145
Joined: 15 Apr 2011
Has thanked: 16 times
Been thanked: 8 times

Re: BarStatus, IOG question

Postby tozwp » 25 Mar 2014

It is backtesting at this point. Classic Mode, use bar magnifier, intraday 1 minute.

Just trying to build more complexity into the strategy but so far I can't get over this hurdle.

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Re: BarStatus, IOG question

Postby SUPER » 25 Mar 2014

Try and see if this works

IOG is set true in the code, I would suggest debug code using print statement.

Code: Select all


[IntrabarOrderGeneration = True]

vars: Trig(0), Flag(false);

If BarStatus(1) = 2 then begin
Flag = H < H[1] and L > L[1]; //inside stick
Trig = High + 0.0001;
end;

if MarketPosition <=0 and Flag then Buy("IP-L") 100 shares next bar at Trig Stop;

If marketposition = 1 and BarsSinceEntry >=1 then Sell next bar at Open; //exit every trade for testing



tozwp
Posts: 145
Joined: 15 Apr 2011
Has thanked: 16 times
Been thanked: 8 times

Re: BarStatus, IOG question  [SOLVED]

Postby tozwp » 25 Mar 2014

Yes! Thanks Super, that works. I think I'm getting a little better handle on what its doing.


Return to “MultiCharts”