Looking for help on my problem

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

Looking for help on my problem

Postby conjure » Fri Feb 22, 2019 2:37 pm

Hi.I have a strategy that close all trades, if Equity is bigger than desired profit.
something like this
Code: Select all
local Equity = core.host:findTable("accounts"):find("AccountID", Account).Equity;
local Balance = core.host:findTable("accounts"):find("AccountID", Account).Balance;
  profit=1000
    EL = Balance+profit
        if Equity >= EL then
             closeAllTrades();
         end

after the execution of closeAllTrades(),
I set new profit
Code: Select all
local Balance = core.host:findTable("accounts"):find("AccountID", Account).Balance;
    EL = Balance+profit


My problem is that the execution of the code happens too fast,
and sometimes it has not finish closing all trades,
with result the balance has not reached equity yet.

What i need is a way to delay setting new profit (EL) ,
until all positions has closed , or equity is equal to balance.

So i tried this , but i m getting an error that function runs fir nire than 30 seconds
Code: Select all
repeat
local Equity = core.host:findTable("accounts"):find("AccountID", Account).Equity;
local Balance = core.host:findTable("accounts"):find("AccountID", Account).Balance;
until Balance==Equity


Any ideas how to delay setting new profit?
Or why my loop is never ending?
conjure
FXCodeBase: Initiate
 
Posts: 135
Joined: Sat Jul 22, 2017 7:27 am

Re: Looking for help on my problem

Postby Apprentice » Mon Feb 25, 2019 6:10 pm

Your request is added to the development list under Id Number 4496
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36420
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Looking for help on my problem

Postby Apprentice » Tue Feb 26, 2019 5:11 am

You need to move
EL = Balance+profit
into ExtAsyncOperationFinished/AsyncOperationFinished function. ExtAsyncOperationFinished/AsyncOperationFinished will be called when FXTS2 will get confirmation of the order position close.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36420
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: No registered users and 6 guests