READ-ONLY

The forum is now a read-only archive.

For bug reports & platform questions → [email protected]

Our community lives on Discord and YouTube — come join us!

Trade Context is busy , i know the reason but i need a solution

8 replies

Tarwada

Subscriber, bbp_participant, community, course_strategyquant-x-course, 92 replies.

Visit profile

10 years ago #115012

ok first let me explain what im trying to do so you all know what im missing 

 

my expert will open a trade based on my strategy at 9.00AM everyday

 

and since it only open 1 trade a day , i decided to run the expert on 15 charts

 

when it is 9.00am , some of the trades get open and some get “Trade Context is busy” error

 

i know this is happening because im sending too much orders to the server

 

how can i avoid that ?

 

i have 8 Trading Rules

 

qWNkyGX.png

 

any ideas ?

0

Tomas Matejka

Administrator, sq-ultimate, 2 replies.

Visit profile

10 years ago #136460

Hello,

 

you could edit the final code and place the following code just before an order is placed / closed to prevent this error, while still executing the trade / exit.

while(IsTradeContextBusy()) Sleep(100);
RefreshRates();

0

Tarwada

Subscriber, bbp_participant, community, course_strategyquant-x-course, 92 replies.

Visit profile

10 years ago #136464

Hello,

you could edit the final code and place the following code just before an order is placed / closed to prevent this error, while still executing the trade / exit.

while(IsTradeContextBusy()) Sleep(100);
RefreshRates();

thank you for your reply.

shall i put the code before the order execution only or before & after ?

0

Tomas Matejka

Administrator, sq-ultimate, 2 replies.

Visit profile

10 years ago #136465

it should be fine place only before

0

Tarwada

Subscriber, bbp_participant, community, course_strategyquant-x-course, 92 replies.

Visit profile

10 years ago #136468

here is an example , is that the right place to put the code in ?  😆

   // test 
   while(IsTradeContextBusy()) Sleep(100);
   RefreshRates();
   if(sqIsBarOpen == true) {
      if ((Close[1] > iSAR(NULL, 0 , 0.02 , 0.2 , 1)))
      {
      sqOpenOrder("NULL", OP_BUY, getOrderSize(1000, OP_BUY ), getOrderPrice(1000), "", 1000, "test");
      }
   }

   return(0);
}

0

Tomas Matejka

Administrator, sq-ultimate, 2 replies.

Visit profile

10 years ago #136486

yes, this should work. It can be also placed into the body of bool sqOpenOrder() function which is bit lower right behind

bool sqOpenOrder(string symbol, int orderType, double orderLots, double price......

because you always call this function to create an order from multiple conditions

0

Tarwada

Subscriber, bbp_participant, community, course_strategyquant-x-course, 92 replies.

Visit profile

10 years ago #136495

yes, this should work. It can be also placed into the body of bool sqOpenOrder() function which is bit lower right behind

bool sqOpenOrder(string symbol, int orderType, double orderLots, double price......

because you always call this function to create an order from multiple conditions

still having the same problem
im thinking of adding time delay after each order (lets say 2 seconds) , the problem is that the ea will use the same 2 seconds on each chart. so I’ll get the same problem again because im using 15 charts

any ideas to implement random delay after each order ? (from 1 up to 15 seconds , its ok)

0

Tarwada

Subscriber, bbp_participant, community, course_strategyquant-x-course, 92 replies.

Visit profile

10 years ago #136502

hello ……. it’s me

0

Tomas Matejka

Administrator, sq-ultimate, 2 replies.

Visit profile

10 years ago #136522

Hello,

 

you can try to play with Sleep value or try another method and wrap the code like this (using if (IsTradeAllowed())

if(IsTradeAllowed())
   if(sqIsBarOpen == true) {
      if ((Close[1] > iSAR(NULL, 0 , 0.02 , 0.2 , 1))) {
          sqOpenOrder("NULL", OP_BUY, getOrderSize(1000, OP_BUY ), getOrderPrice(1000), "", 1000, "test");
      }
   }
}

0

Viewing 8 replies - 1 through 8 (of 8 total)