The following routine has to check if the new position is within the allowed limit.
Yet between a reversal of position, it will take about 1 minute between the cover trade (in this case the first buy trade) and the new (2nd buy) trade.
Why does it take so long if it is computed on every tick?
// Verification that total positions are within limits
if(toOpen!=0)
{
if (Math.abs(openPos+toOpen)>num_contracts)
toOpen = 0;
}
// main module
var host=dots5.call("IsHostRunning");
var conn=dots5.call("IsHostConnected");
var conn = 1;
//debugPrintln("Host :"+host+"Conn :"+conn);
if ((host == 1) && (conn == 1))
{
if (getCurrentBarIndex() == 0)
{
if (getBarState() == BARSTATE_NEWBAR)
{
if ((now >= day_open) && (now <= day_close))
{
if (toOpen!=0)
{
if (position == NONE);
{
if (toOpen==1)
{
if (use_limit_orders == true)
{
order_id = dots5.call("BuyLimit", s_name, s_type, s_exp, s_right, s_strike, s_exch, s_curr, num_contracts, ask);
log_msg("LONG limit signal triggered: " + order_id);
state += 1;
if (order_id!=0)
{
openPos+=toOpen;
if (openPos==0)
{
drawTextRelative(1, close(), "MA=X Sh ("+order_id+")", Color.black, Color.yellow, Text.FRAME | Text.BOLD | Text.ONTOP, null, null, "SxBl"+order_id);
}
else
{
position = LONG;
drawTextRelative(1, close(), "MA=+Lg ("+order_id+")", Color.black, Color.yellow, Text.FRAME | Text.BOLD | Text.ONTOP, null, null, "Bl"+order_id);
}
Thank you in advance for your help.
Cheers,
Andrei
Yet between a reversal of position, it will take about 1 minute between the cover trade (in this case the first buy trade) and the new (2nd buy) trade.
Why does it take so long if it is computed on every tick?
// Verification that total positions are within limits
if(toOpen!=0)
{
if (Math.abs(openPos+toOpen)>num_contracts)
toOpen = 0;
}
// main module
var host=dots5.call("IsHostRunning");
var conn=dots5.call("IsHostConnected");
var conn = 1;
//debugPrintln("Host :"+host+"Conn :"+conn);
if ((host == 1) && (conn == 1))
{
if (getCurrentBarIndex() == 0)
{
if (getBarState() == BARSTATE_NEWBAR)
{
if ((now >= day_open) && (now <= day_close))
{
if (toOpen!=0)
{
if (position == NONE);
{
if (toOpen==1)
{
if (use_limit_orders == true)
{
order_id = dots5.call("BuyLimit", s_name, s_type, s_exp, s_right, s_strike, s_exch, s_curr, num_contracts, ask);
log_msg("LONG limit signal triggered: " + order_id);
state += 1;
if (order_id!=0)
{
openPos+=toOpen;
if (openPos==0)
{
drawTextRelative(1, close(), "MA=X Sh ("+order_id+")", Color.black, Color.yellow, Text.FRAME | Text.BOLD | Text.ONTOP, null, null, "SxBl"+order_id);
}
else
{
position = LONG;
drawTextRelative(1, close(), "MA=+Lg ("+order_id+")", Color.black, Color.yellow, Text.FRAME | Text.BOLD | Text.ONTOP, null, null, "Bl"+order_id);
}
Thank you in advance for your help.
Cheers,
Andrei
Comment