Point me in the right direction (csv file read)

Section for discussions related to indicators, use of indicators, and building of trading stategies using indicators.

Moderator: admin

Point me in the right direction (csv file read)

Postby Cactus » Sun Oct 02, 2016 5:04 am

Hello friendly people, could you point me in the right direction with the code I want to create:
I will like to add it to an existing strategy.

* User to select a .csv file to read that contains many price levels for particular asset.
**** Can a strategy be specified file path like indicators?
* When my strategy gives a signal, loop through the list on the .csv file, and if the candlestick (on specified timeframe) open below any of the prices but is currently above the same price it opened below, sell. Conversely, if the candlestick (on specified timeframe) open above any price from the .csv file but is currently below that price, buy.

So in short, if my strategy gives an arrow signal to trade, check if price is crossing any of the levels in the .csv file looking at the candlestick, and only then allow to trade if there's both an arrow and the price is crossing the level. Hope this is clear and you could provide me with some code examples to achieve this. I have both the strategy providing the signals and the .csv file but missing the functionality to join them together by making the strategy read the file and loop automatically through the list of prices and trade only when both conditions are met.

The code I need help with is in bold Thanks
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere

Re: Point me in the right direction (csv file read)

Postby Georgiy » Mon Oct 10, 2016 5:36 am

Hi Cactus,

Please see recommendations below:
1. The way to add a file parameter:
Code: Select all
indicator.parameters:addFile("file", "File", "", "");


2.The way to handle all strings:
Code: Select all
local handle, error = io.open(instance.parameters.file, "r");
for line in handle:lines() do
core.host:trace(tostring(line));
end
handle:close();


3.The way to separate a string into values:
http://www.fxcodebase.com/bin/beta/IndicoreSDK-3.0/help/web-content.html#core.parseCsv.html
Georgiy
FXCodeBase: Initiate
 
Posts: 150
Joined: Tue Jul 29, 2014 4:49 am

Re: Point me in the right direction (csv file read)

Postby Cactus » Thu Oct 13, 2016 3:01 pm

That's great thank you for your time with providing this information
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere


Return to Discussions

Who is online

Users browsing this forum: No registered users and 4 guests