Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 16:52:20 +0000



Post From: Multiple limit orders to open

[2024-02-17 17:52:36]
User509533 - Posts: 57
I maintain open limit orders for ES, NQ, YM, and RTY. Whenever one of these orders is filled, I aim to cancel all remaining open orders for the other symbols.

The following study is applied to every trading chart. It tries to ensure that as soon as an order fills, all other orders on other chart's symbol are canceled.

Given that studies are executed at every bar, this frequency may be insufficient to promptly detect filled orders. Therefore, I'm considering whether
it would be more effective to subscribe to a filled position alert (if there is any) and activate this study across each trading chart book accordingly.

In any case, attached code is not even getting executed once (I have print statements that are not producing any output in the log). I would appreciate any help.

******************************


// The top of every source code file must include this line
#include "sierrachart.h"

SCDLLName("CloseOpenOrders DLL")

/* I maintain open limit orders for ES, NQ, YM, and RTY. Whenever one of these orders is filled, I aim to cancel all remaining open orders for the other symbols.

This strategy is applied to every trading chart. It ensures that as soon as an order fills, all other orders for that specific chart's symbol are canceled.

Given that studies are executed at every bar, this frequency may be insufficient to promptly detect filled orders. Therefore, I'm considering whether it would be more effective to subscribe to a filled position alert and activate this strategy across each trading chart book accordingly.
*/

SCSFExport scsf_CheckPositionAndCloseOrders(SCStudyInterfaceRef sc)
{


if (sc.SetDefaults)
{
// Set default settings
sc.GraphName = "Check Filled Position and Close Open Orders for Other Symbols";

sc.AutoLoop = 1; // NOT Manual looping

sc.FreeDLL = 1;
// This is false by default. Orders will go to the simulation system always.
sc.SendOrdersToTradeService = false;
return;
}


// Get the Trade Position data
s_SCPositionData PositionData;
sc.GetTradePosition(PositionData) ;

SCString PositionSymbol;
PositionSymbol = PositionData.Symbol;

std::cout << "pq is equal to " << PositionData.PositionQuantity;
std::cout << "psym is equal to " << PositionData.Symbol ;
std::cout << "psym is equal to " << PositionSymbol ;
std::cout << "csym is equal to " << sc.Symbol ;

if (PositionData.PositionQuantity == 0)
{
// No open position, no action required
return;
}



if (sc.Symbol != PositionSymbol)
{
// Close all orders for the other symbols
sc.CancelAllOrders;

}


}


attachmentCloseOpenOrders5.cpp - Attached On 2024-02-17 17:48:16 UTC - Size: 1.94 KB - 159 views
Attachment Deleted.