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 ;
combining false/true IntrabarOrderGeneration in a single script
- Vlada MultiCharts
- Posts: 294
- Joined: 22 Apr 2020
- Has thanked: 8 times
- Been thanked: 76 times
Re: combining false/true IntrabarOrderGeneration in a single script
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].
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].
Re: combining false/true IntrabarOrderGeneration in a single script
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;