Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 15:50:36 +0000



Post From: Passing a sierra chart function to another function

[2024-03-03 14:46:14]
User371315 - Posts: 10
I'm trying to figure out the right syntax to pass a sc function to another function. Here's an example.

The function I'm passing another function into

void PlaceOrder(SCStudyInterfaceRef sc, BotConfig Config, int &InternalOrderID,
int32_t &Stop1OrderID, int32_t &Target1OrderID,
int &ActiveTrade, float CurrentBidAsk,
SCSubgraphRef Subgraph_BuySellEntry,
SCFloatArrayRef HighLowArray, // sc.Low/sc.High,
double (*OrderAction)(s_SCNewOrder &),
float (*HighestLowest)(SCFloatArrayRef, int, int),
const int TypeOfOrder, SCString Message)

PlaceOrder(sc, Config, InternalOrderID, Stop1OrderID, Target1OrderID,
ActiveTrade, sc.Bid, Subgraph_BuyEntry, sc.Low, &sc.BuyEntry,
&sc.GetLowest, BUY, OrderText);

The error that I get is this and I haven't been able to figure out by examples how to do this.

TradingBot.h: In function 'void tradeBot(SCStudyInterfaceRef, int, BotConfig, int&, int32_t&, int32_t&, int&, int, SCSubgraphRef, SCSubgraphRef, SCSubgraphRef, SCSubgraphRef)':
TradingBot.h:109:42: error: no matches converting function 'BuyEntry' to type 'double (*)(struct s_SCNewOrder&)'
109 | &sc.Lowest, BUY, OrderText);
| ^
In file included from TradeBotConfig.h:4,
from Trader.cpp:3:
sierrachart.h:1305:9: note: candidates are: 'double s_sc::BuyEntry(s_SCNewOrder&)'
1305 | double BuyEntry(s_SCNewOrder& NewOrder)//Automatic looping
| ^~~~~~~~

Does anyone have an example I can review or point me to the documentation? can't seem to find it!

TL;DR
Mainly these 2 function pointer definitions that I'm passing sc.BuyEntry and sc.GetLowest

double (*OrderAction)(s_SCNewOrder &),
float (*HighestLowest)(SCFloatArrayRef, int, int)

Date Time Of Last Edit: 2024-03-03 15:18:39