closing a trade and then immediately open a trade

Section for all discussions related to development using Indicore API/SDK.

Moderator: admin

closing a trade and then immediately open a trade

Postby nixlike » Wed Aug 10, 2016 10:29 am

In my live account, I recently encountered a scenario where my code closed a trade successfully and then was supposed to enter a trade. The code that selects which side to enter does not appear to be executing, so the trade did not open. I suspect that this is the culprit for the live environment not opening the trade.

Code: Select all
if (not haveTrades(nil)) then

function haveTrades(BuySell)
   local enum, row;
   local found = false;
   enum = core.host:findTable("trades"):enumerator();
   row = enum:next();
   while (not found) and (row ~= nil) do
      if row.AccountID == account and
      row.OfferID == offer and
      row.QTXT == "perry" and
      (row.BS == BuySell or BuySell == nil) then
         found = true;
      end
      row = enum:next();
   end

   return found;
end


I suspect the trade tables have not been updated when the trade is closed. This code works in the strategy tester.

I would like to understand what I can do to implement some code that will work in the strategy tester and also live.

Thank you.

Jim Barker
nixlike
 
Posts: 3
Joined: Wed Aug 10, 2016 10:05 am

Re: closing a trade and then immediately open a trade

Postby Julia CJ » Thu Aug 11, 2016 9:18 am

Hi Jim,

It is true. The table is updated a little bit later after closing. There is not the universal decision of your problem.
It is necessary to develop an algorithm specifically for the strategy. Usually, in this situation it would be better to create the flag “ to open the position at the first opportunity” and when such chance appears, you are able to open it.
Julia CJ
 

Re: closing a trade and then immediately open a trade

Postby nixlike » Thu Aug 11, 2016 10:12 am

Thank you Julia for the confirmation. I also found corresponding documentation here regarding that.

http://www.fxcodebase.com/bin/beta/IndicoreSDK-3.0/help/web-content.html#terminal.execute.html

I will implement what you suggested.

Regards,
Jim Barker
nixlike
 
Posts: 3
Joined: Wed Aug 10, 2016 10:05 am


Return to Discussions

Who is online

Users browsing this forum: No registered users and 2 guests

cron