Torch framework

All posts which do not fit into any other sections of the forum.

Moderator: admin

Torch framework

Postby daniel.alzate » Thu Feb 01, 2018 12:49 pm

Hey Guys,

I don't know if this is the right place to post this, but I'm trying to math torch (https://github.com/torch/torch7) with indicoreSDK with no luck. A simple test (just adding
Code: Select all
require 'torch'
in one of the standard indicators show error when loading DLL files from the torch library.

Have any of you guys tried to do this before?

Thanks in advance for comments.
daniel.alzate
 
Posts: 8
Joined: Thu Feb 01, 2018 12:42 pm

Re: Torch framework

Postby Apprentice » Sun Feb 04, 2018 11:26 am

The query was forwarded to the development team.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Torch framework

Postby daniel.alzate » Mon Feb 12, 2018 11:20 am

Hi, any updates on this?

As an alternative, I also tried to link Octave https://www.gnu.org/software/octave/ using indicoreDev. I was able to make a simple dll file and call the function in it from a Lua file, but when I added libraríes and includes from octave, the indicoreSDK debug simply didn't find the dll suitable showing an error like
error loading module "xxxxxx" from file


waiting for comments

thanks again.
daniel.alzate
 
Posts: 8
Joined: Thu Feb 01, 2018 12:42 pm

Re: Torch framework

Postby Konstantin.Toporov » Tue Feb 13, 2018 3:49 pm

Torch is not provided officially for Windows.
What Torch binaries do you have?
I am not sure they are compatible with FXTS.
Konstantin.Toporov
FXCodeBase: Initiate
 
Posts: 113
Joined: Mon Aug 31, 2015 10:16 am

Re: Torch framework

Postby daniel.alzate » Wed Feb 14, 2018 11:56 am

Hi Konstantin ...

I'm using this: https://github.com/hiili/WindowsTorch I've tested in my windows 10 and is working good.
daniel.alzate
 
Posts: 8
Joined: Thu Feb 01, 2018 12:42 pm

Re: Torch framework

Postby Konstantin.Toporov » Wed Feb 28, 2018 4:01 pm

We ll investigate what is the problem
Konstantin.Toporov
FXCodeBase: Initiate
 
Posts: 113
Joined: Mon Aug 31, 2015 10:16 am

Re: Torch framework

Postby PetroIV » Tue Mar 06, 2018 1:24 am

Hello daniel.alzate,

Actually, Torch works only with Lua JIT.
You will be able to use Torch for indicators/strategies if you do the following steps:
1. Download the x86 branch from https://github.com/hiili/WindowsTorch.
2. Copy all .dll files except libluajit.dll from WindowsTorch\bin\ to the root folder where FXTS is installed.
3. Copy the file FXTS\Lua5.1.jit.dll to FXTS\libluajit.dll.
4. Copy the WindowsTorch\lua folder to FXTS\lua.
5. In FXTS, select FXTS Options-> Marketscope 2.0 -> Lua Virtual Machine Type -> Lua Just-In-Time.
6. Restart FXTS.

For testing, you can use the attached indicator test_torch.lua.
Attachments
test_torch.lua
Test indicator
(591 Bytes) Downloaded 1125 times
PetroIV
 
Posts: 24
Joined: Tue Aug 15, 2017 9:45 am

Re: Torch framework

Postby daniel.alzate » Thu Mar 15, 2018 12:33 pm

Good work guys, it worked great.

I'll try to play with that framework and see what I get. If I run into problems I'll post it.

Thank you
daniel.alzate
 
Posts: 8
Joined: Thu Feb 01, 2018 12:42 pm

Re: Torch framework

Postby daniel.alzate » Mon Jun 11, 2018 12:40 am

Hello Guys, Does anyone want to help me with this?.

Ive already done some torch basics using example you guys gave me. I have done some simple candle recognition working good on FXTS and IndicoreSDK.
Got issues when i tried to do a simple nn like this (example gotten from this https://github.com/torch/nn/blob/master/doc/training.md#nn.StochasticGradient):

Code: Select all
function Init()
    indicator:name("Torch Test");
    indicator:description("Torch Test indicator");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Indicator);
end

require 'torch'
require "nn"
   
function Prepare(onlyName)

    instance:name(profile:id());
    if onlyName then
        return ;
    end
       
    local z = torch.Tensor(4,5,6,2)
    local s = torch.LongStorage(6);
    s[1] = 4; s[2] = 5; s[3] = 6; s[4] = 2; s[5] = 7; s[6] = 3;   
    local x = torch.Tensor(s);
   
    core.host:trace(x:nDimension());
   
   --NN test
   dataset={};
   function dataset:size() return 100 end -- 100 examples
   for i=1,dataset:size() do
     local input = torch.randn(2);     -- normally distributed example in 2d
     local output = torch.Tensor(1);
     if input[1]*input[2]>0 then     -- calculate label for XOR function
      output[1] = -1;
     else
      output[1] = 1
     end
     dataset[i] = {input, output}
   end                        

   mlp = nn.Sequential();  -- make a multi-layer perceptron
   inputs = 2; outputs = 1; HUs = 20; -- parameters
   mlp:add(nn.Linear(inputs, HUs))
   mlp:add(nn.Tanh())
   mlp:add(nn.Linear(HUs, outputs))   
   
   criterion = nn.MSECriterion() 
   trainer = nn.StochasticGradient(mlp, criterion)
   trainer.learningRate = 0.01
   trainer:train(dataset)
end

function Update(period)

end


When testing this code in IndicoreSDK 3.0 works fine:

IndicoreImage.png


But when trying to import and run the exact same indicator in FXTS i got this:

FXTSImage.png


Im blocked here :cry: Any help will be appreciated.
daniel.alzate
 
Posts: 8
Joined: Thu Feb 01, 2018 12:42 pm

Re: Torch framework

Postby Apprentice » Fri Jun 29, 2018 5:27 am

Forwarded to the development team.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 9 guests