Code question

Questions about MultiCharts and user contributed studies.
jsramek
Posts: 7
Joined: 03 Jan 2012
Has thanked: 2 times

Code question

Postby jsramek » 03 Apr 2012

So this a simple code for a event trader creating a bracket order right before an event on a 1 second chart for the ES , the question I have is that I seem to run into an issue with the range, it seems to be calculated as ticks sometimes and as full points others. Please let me know if you have any suggestions

Code: Select all

[IntrabarOrderGeneration = TRUE]
inputs: thetimea(180530),thetimeb(180540),rangevalue(6),profit(150),stoploss(250);

if time_s>thetimea and time_s<thetimeb then buy next bar at H[1]+rangevalue stop ;
if time_s>thetimea and time_s<thetimeb then sellshort next bar at L[1]-rangevalue stop;   
 
if marketposition =-1 then
setprofittarget(profit);
setstoploss(stoploss);

if marketposition =1 then
setprofittarget(profit);
setstoploss(stoploss);

escamillo
Posts: 197
Joined: 25 Mar 2011
Has thanked: 22 times
Been thanked: 55 times

Re: Code question

Postby escamillo » 03 Apr 2012

the way you have it written now is in points (e.g. one ES point). if you want your code standardized to ticks across instruments, then you need use something like:

Code: Select all

Var: OneTick(MinMove/PriceScale),RangeCalc(0) ;

RangeCalc = rangevalue * OneTick ;
These users thanked the author escamillo for the post (total 2):
jsramekJoshM

jsramek
Posts: 7
Joined: 03 Jan 2012
Has thanked: 2 times

Re: Code question

Postby jsramek » 03 Apr 2012

escamillo thats what I thought but looking at the orders from the demo to real trades one uses 6 ticks and one used 6 points , if this is setup for points for the es for example could I use 1.5 for 6 ticks in the es?

escamillo
Posts: 197
Joined: 25 Mar 2011
Has thanked: 22 times
Been thanked: 55 times

Re: Code question

Postby escamillo » 03 Apr 2012

jsramek wrote:escamillo thats what I thought but looking at the orders from the demo to real trades one uses 6 ticks and one used 6 points , if this is setup for points for the es for example could I use 1.5 for 6 ticks in the es?

1.5 ES points = 6 ES ticks.

And by the way, since you are using IntraBarOrderGeneration = True, your code will/should work the same on a 5 minute chart as it would on a one second chart.


Return to “MultiCharts”