Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 04:36:06 +0000



[User Discussion] - Keyboard Shortcuts for Send Attached Orders and Adjusting Attached Orders

View Count: 1972

[2014-04-27 11:06:57]
RMF2 - Posts: 43
Can a keyboard shortcut be enabled to Send Attached Orders by Position? Further, once those attached orders are sent, the trading keyboard shortcuts for adjusting stop orders don't work.

Maybe I'm missing something?

Thanks for your help.
[2014-04-27 11:21:38]
norvik - Posts: 22
RMF2, you can make yourself any hotkey you like.

#include<windows.h>
#include "C:\SierraChart\ACS_Source\sierrachart.h"

SCDLLName("ChartTrader Orders One Click Managment")
SCSFExport scsf_ChartTraderOrdersOneClickManagment(SCStudyInterfaceRef sc)
{
SCInputRef ToolId = sc.Input[0];
SCInputRef Enabled = sc.Input[1];

if (sc.SetDefaults)
{
sc.GraphName = "ChartTrader Orders One Click Managment";

sc.StudyDescription = "";

sc.AutoLoop = 1;
sc.GraphRegion = 0;

sc.FreeDLL = 0;

sc.CalculationPrecedence = LOW_PREC_LEVEL;

ToolId.Name = "ACS Tool # ToolBar button for Enable/Disable";
ToolId.SetInt(1);
ToolId.SetIntLimits(1,50);

Enabled.Name = "Enabled";
Enabled.SetYesNo(0);

sc.ReceiveMousePointerEvents = 1;

return;
}

int& MenuID = sc.PersistVars->i1;

double & LastModifyPrice = sc.PersistVars->d1;

if (sc.UpdateStartIndex == 0)
{
sc.SetACSToolButtonText(ToolId.GetInt(), "TMC");

sc.SetACSToolEnable(ToolId.GetInt(), Enabled.GetBoolean() != 0 );

LastModifyPrice = 0.0;
}

sc.SendOrdersToTradeService = !sc.GlobalTradeSimulationIsOn;

SHORT nKeyLeftShift= GetAsyncKeyState(VK_LSHIFT);
SHORT nKeyLeftControl = GetAsyncKeyState( VK_LCONTROL );

s_SCPositionData PositionData;
sc.GetTradePosition(PositionData);
double NewPrice;

s_SCTradeOrder Order;
int Result;


if (( 0 != nKeyLeftShift )&&( PositionData.PositionQuantity <0 ))
Result = sc.GetNearestStopOrder(Order);
else if (( 0 != nKeyLeftControl )&&( PositionData.PositionQuantity >0 ))
Result = sc.GetNearestStopOrder(Order);
else if (( 0 != nKeyLeftShift )&&( PositionData.PositionQuantity >0 ))
Result = sc.GetNearestTargetOrder(Order);
else if (( 0 != nKeyLeftControl )&&( PositionData.PositionQuantity <0 ))
Result = sc.GetNearestTargetOrder(Order);

if ((( 0 != nKeyLeftShift )||(0 != nKeyLeftControl ))&&(sc.MenuEventID != 0))
{
if (sc.MenuEventID == ToolId.GetInt())
{
if (sc.MouseEventType == SC_MOUSE_DOWN)
{
NewPrice = sc.ActiveToolYValue;
NewPrice= sc.RoundToTickSize(NewPrice);

if(NewPrice == LastModifyPrice || sc.FormattedEvaluateUsingDoubles(Order.Price1,sc.ValueFormat, EQUAL_OPERATOR,NewPrice, sc.ValueFormat ) )
return;

LastModifyPrice = NewPrice;

s_SCNewOrder ModifyOrder;
ModifyOrder.InternalOrderID = Order.InternalOrderID;
ModifyOrder.Price1 = NewPrice;

Result = sc.ModifyOrder(ModifyOrder);
}
}
}
}

[2014-08-02 15:12:08]
ejtrader - Posts: 688
norvik - Thank you for this code. Was looking for interaction using keyboard and this was just perfect.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account