Dukascopy
 
 
Wiki JStore Search Login

is there a parameter that makes the strategy to run only by OHLC? (No all tick data)
 Post subject: is there a parameter that makes the strategy to run only by OHLC? (No all tick data) Post rating: 0   New post Posted: Sat 14 Sep, 2013, 18:31 
User avatar

User rating: 0
Joined: Mon 11 Mar, 2013, 00:00
Posts: 47
Location: Colombia, manizales
Hi

I am testing a strategy, the results when I choose all tick data are different from when I choose OHLC.

is it possible to make that the strategy (when running on live account) only reads OHLC? is there a parameter or something?

Thanks in advance,


 
 Post subject: Re: is there a parameter that makes the strategy to run only by OHLC? (No all tick data) Post rating: 1   New post Posted: Sat 14 Sep, 2013, 21:43 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi juandata:

No need for any parameter...

If i understand correctly your question...
If you use onTick() to do some processing it's used tick information... On onBar() it's used OHLC for chosen instrument, period and side. Now you only need to care with the indicators processing the values at close of the bar, not during the build of the same.


Trade well

JL


 
 Post subject: Re: is there a parameter that makes the strategy to run only by OHLC? (No all tick data) Post rating: 0   New post Posted: Sat 14 Sep, 2013, 23:18 
User avatar

User rating: 0
Joined: Mon 11 Mar, 2013, 00:00
Posts: 47
Location: Colombia, manizales
Thanks for answering.

I am learning java, and I am trying to change a strategy. I understand that the strategy is using Tick data:

public void onTick(Instrument instrument, ITick tick) throws JFException
{

if (instrument.equals(selectedInstrument) == false) return;

long tickTime = getUTCTime(tick.getTime());


double spread = getSpread(tick.getBid(), tick.getAsk());
if (spread > maxSpread) return;

checkRSIBreakOutUp(selectedInstrument, tick.getBid(), tickTime, spread);
checkRSIBreakOutDown(selectedInstrument, tick.getBid(), tickTime, spread);
checkRSIBreakOutUpKon(selectedInstrument, tick.getBid(), tickTime, spread);
checkRSIBreakOutDownKon(selectedInstrument, tick.getBid(), tickTime, spread);
_________________________________________________________________________________________________________

So now, if I want it to use OHLC I supposed I have to put the above code inside OnBar:
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException
{

¿How can I place the code from onTick here?

}
I would appreciate your help.


 
 Post subject: Re: is there a parameter that makes the strategy to run only by OHLC? (No all tick data) Post rating: 1   New post Posted: Sun 15 Sep, 2013, 02:18 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi juandata:

You can declare the variable spread global and use it on onBar() when the filtered bar is completed get the last spread value and process it next... but without knowing what you are trying to do it's the only advice a can give you.

Forget to say, you can also get spread value from bar objects...

Trade well

JL


 
 Post subject: Re: is there a parameter that makes the strategy to run only by OHLC? (No all tick data) Post rating: 0   New post Posted: Sun 15 Sep, 2013, 21:42 
User avatar

User rating: 0
Joined: Mon 11 Mar, 2013, 00:00
Posts: 47
Location: Colombia, manizales
Thanks Jlongo for you answer. I have tried to get the spread on Bar(), but so far I haven´t been able to do it.

is this the way to do it? (I am a little confused :roll: )

public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException
{
if (instrument.equals(selectedInstrument) == false) return;

long BarTime = getUTCTime(bidBar.getTime());





}


 
 Post subject: Re: is there a parameter that makes the strategy to run only by OHLC? (No all tick data) Post rating: 1   New post Posted: Tue 17 Sep, 2013, 00:25 
User avatar

User rating: 98
Joined: Mon 23 Jul, 2012, 02:02
Posts: 656
Location: United States, Durham, NC
Use onTick(...) to monitor the Bid / Ask spread and maintain the lastInsideBidPrice
and lastInsideAskPrice as member variables in the IStrategy object instance.

Then, check them in onBar(...) to make your "bar" type decisions, part of
which is calculating the spread. Remember the spread (in pips) is calculated
as


double lastInsideAskPrice = 0;
double lastInsideBidPrice = 0;

void onTick(Instrument instrument, ITick tick) {
//...
      this.lastInsideAskPrice = tick.getAsk(); // member variable
      this.lastInsideBidPrice = tick.getBid();
//.....


}

// and in onBar(...) do this

double absInstantaneousSpreadInPips = Math.abs( (this.lastInsideAskPrice-this.lastInsideBidPrice) / instrument.getPipValue() );
// 'this' is being used just to emphasize that it is a member variable
//


It you want to be more sophisticated, then your onTick(...) processing can maintain
some "average inter-bar bid/ask spread" which develops while your bar is being formed. You can do
just about anything you want, with some creativity :) onBar(...) is called only at the
completion of a bar, but onTick(...) is called on every price change, so don't do
any lengthy calculations.......

If your goal is to trade only when the "average spread" is "narrow enough", then just
checking the momentary spread, at the instant when onBar completes might not
be "robust" enough for your needs. In that case, your spread monitoring needs
to be more stable and robust, but don't forget to normalize it to PIPs, as shown.

HyperScalper


 
 Post subject: Re: is there a parameter that makes the strategy to run only by OHLC? (No all tick data) Post rating: 1   New post Posted: Tue 17 Sep, 2013, 21:22 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Could you show the strategy code? It would be much easier to help...
Quote:
the results when I choose all tick data are different from when I choose OHLC.

Where do you 'choose' this?


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com