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.

write bar data to csv only when taking positions
 Post subject: write bar data to csv only when taking positions Post rating: 0   New post Posted: Wed 08 May, 2019, 14:18 

User rating: 0
Joined: Mon 14 Nov, 2011, 05:16
Posts: 33
Location: PhilippinesPhilippines
[moved from incorrect forum group]

Dear Support,

I am trying to write various technical indicators to csv file, when I take a trade (to analyse correlation)

I use this code in the onBar Function

            if (bidPrice < prevWeekLow) {
               sell(instrument, engine, profitLimit, lossLimit, 0.1);
               try {       
           out.append( sdf2.format(bidBar.getTime()) + ";" + bidPrice )
           .append(";" + openPrice)
           .append(";" + sma14).append(";" + ema12).append(";" +sma50).append(";" + ema26).append(";" + sma200)
           .append("\n");   
           
         } catch (IOException e) {
            writeMessage("File write error " );
            e.printStackTrace();



found on this strategy-api page:
https://www.dukascopy.com/wiki/en/devel ... ars-in-csv

This, however, prints the indicators to CSV file for each bar, and not - as intended - only when a trade is taken.

Can you guide me to a functional solution? It would be helpful if the code also prints the result of the trade (open, close, profit in Pips) at the close of that trade


 
 Post subject: Re: write bar data to csv only when taking positions Post rating: 0   New post Posted: Thu 09 May, 2019, 14:12 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hello,

By this code sample it looks like your strategy will write in csv file indicator values for every bar which will satisfy conditions
Quote:
bidPrice < prevWeekLow

If you have some additional validation logic in sell() method - it's result also need to be passed in your code block, which is responsible for data writing.


 

Jump to:  

cron
  © 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