Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

IMessage method strategy
 Post subject: IMessage method strategy Post rating: 0   New post Posted: Thu 25 Oct, 2012, 15:13 

User rating: 0
Joined: Tue 16 Oct, 2012, 12:23
Posts: 40
I have coded a strategy in which the opening of a trade is dependent on the whether it crosses the opening price of the previous trade or not. I have used the IMessage method. But what should I do about the first trade to be taken by the strategy? It will not have any previous trade. I want to open it normally and then the rest of the trades should be dependent on the previous trades.

I have put the IMessage method before the onTick method in the code. But the historical testing results of the strategy are the same as the one without the IMessage code. I am attaching the strategy. Kindly help.


Attachments:
SMASimpleStrategymodify3.java [6.02 KiB]
Downloaded 331 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: IMessage method strategy Post rating: 0   New post Posted: Tue 30 Oct, 2012, 15:16 

User rating: 0
Joined: Tue 16 Oct, 2012, 12:23
Posts: 40
I have corrected a mistake that I had made in the above strategy by submitting order opening in IMessage method when it should have been in the onBar method. But even after submitting order opening in onBar method, there is an error regarding the fetching of the opening price of the last order closed.

I have fetched the opening price of the last order closed in the IMessage method but I don't know how to fetch it in the onBar method while submitting a new order opening. The following error is shown in compilation.

2012-10-30 14:10:00 ----------
2012-10-30 14:10:00 lastorderclosed cannot be resolved
2012-10-30 14:10:00 ^^^^^^^^^^^^^^^
2012-10-30 14:10:00 if (tick1.getBid() < lastorderclosed.getOpenPrice() && prevBar.getOpen() > sma && prevBar.getClose() < sma && order == null)
2012-10-30 14:10:00 2. ERROR in C:\Users\Mankind\AppData\Local\Temp\jfxide\tmp\compile\SMASimpleStrategymodify3.java (at line 105)
2012-10-30 14:10:00 ----------
2012-10-30 14:10:00 lastorderclosed cannot be resolved
2012-10-30 14:10:00 ^^^^^^^^^^^^^^^
2012-10-30 14:10:00 if (tick1.getBid() > lastorderclosed.getOpenPrice() && prevBar.getOpen() < sma && prevBar.getClose() > sma && order == null)
2012-10-30 14:10:00 1. ERROR in C:\Users\Mankind\AppData\Local\Temp\jfxide\tmp\compile\SMASimpleStrategymodify3.java (at line 100)
2012-10-30 14:10:00 ----------

Plz tell me how to do it. I am attaching the corrected strategy.


Attachments:
SMASimpleStrategymodify3.java [5.55 KiB]
Downloaded 327 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: IMessage method strategy Post rating: 0   New post Posted: Wed 31 Oct, 2012, 08:18 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
In order to avoid such errors before compilation and receive correction advice consider using an IDE for writing your strategies e.g. Eclipse or NetBeans.


 

Jump to:  

  © 1998-2025 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