combining false/true IntrabarOrderGeneration in a single script

Questions about MultiCharts and user contributed studies.
traderaaa
Posts: 8
Joined: 23 Nov 2020
Has thanked: 17 times

combining false/true IntrabarOrderGeneration in a single script

Postby traderaaa » 30 Nov 2020

hello, every bro,

can I combine false/true IOG in a single script? other than operating two scripts
for example:

[intrabarordergeneration=true]

if close> averagefc(close,20) then buy 1 contract next bar market;

[IntrabarOrderGeneration = false]
inputs: ATRLength( 10 ), NumATRs( 3 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;

var0 = AvgTrueRange( ATRLength ) * NumATRs ;
var1 = MarketPosition ;

if var1 = 1 then
begin
condition1 = var1[1] <> 1 or High > var2 ;
if condition1 then
var2 = High ;
Sell ( "AtrLX" ) next bar at var2 - var0 stop ;
end
else
Sell ( "AtrLX-eb" ) next bar at High - var0 stop ;

User avatar
Vlada MultiCharts
Posts: 293
Joined: 22 Apr 2020
Has thanked: 8 times
Been thanked: 76 times

Re: combining false/true IntrabarOrderGeneration in a single script

Postby Vlada MultiCharts » 26 Feb 2021

Hi traderaaa,

If there are several commands [intrabarordergeneration=true / false], the script will be calculated based on the latest one.

The possible solution is to apply two signals on the chart which have different calculation modes.
The first has [intrabarordergeneration=false], and the second one has [intrabarordergeneration=true].

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

Re: combining false/true IntrabarOrderGeneration in a single script

Postby SUPER » 26 Feb 2021

Use BarStatus(1)=2 in your code will help achieve what you are looking for in same code.

Code: Select all

[intrabarordergeneration=true] if close> averagefc(close,20) then buy 1 contract next bar market; inputs: ATRLength( 10 ), NumATRs( 3 ) ; variables: var0( 0 ), var1( 0 ), var2( 0 ) ; if BarStatus(1)=2 then begin // will calculate end of the bar var0 = AvgTrueRange( ATRLength ) * NumATRs ; var1 = MarketPosition ; if var1 = 1 then begin condition1 = var1[1] <> 1 or High > var2 ; if condition1 then var2 = High ; Sell ( "AtrLX" ) next bar at var2 - var0 stop ; end else Sell ( "AtrLX-eb" ) next bar at High - var0 stop end;


Return to “MultiCharts”