Support Board
Date/Time: Fri, 14 Mar 2025 15:21:11 +0000
[Programming Help] - Simple... coding?
View Count: 290
[2025-02-06 10:31:24] |
Tin43 - Posts: 139 |
I'm using Gemini to try silly things. I asked to write the code for the following: I got a one minute Candlestick chart. I want you to set a buy market order is the candle is bullish and a sell market order is the candle is bearish. I got this: SCDLLName("CandleColorTrader"); #include "sierrachart.h" SCSFExport scsf_CandleColorTrader(SCStudyInterfaceRef sc) { SCInputRef Input_TradeQuantity = sc->AddStudyInput("Trade Quantity", ST_NUMBER); Input_TradeQuantity->SetDescription("Trade Quantity for Orders"); Input_TradeQuantity->SetInt(1); if (sc->SetDefaults) { sc->GraphName = "Candle Color Trader"; sc->StudyDescription = "Buys on Bullish candles, Sells on Bearish candles on 1-minute chart."; sc->Subgraph[0].Name = "Trades"; // Optional: you can have a subgraph to visualize trades if needed sc->Subgraph[0].DrawStyle = DRAWSTYLE_INVISIBLE; // Make the subgraph invisible as it's just for trading Input_TradeQuantity->SetInt(1); // Default trade quantity sc->GraphRegion = 0; return; } if (!sc->IsFullRecalculation) return; int tradeQuantity = Input_TradeQuantity->GetInt(); if (tradeQuantity <= 0) tradeQuantity = 1; static bool buyOrderPlacedForBar = false; static bool sellOrderPlacedForBar = false; if (sc->IsFullRecalculation) // Reset order flags on full recalculation (new bar or chart reload) { buyOrderPlacedForBar = false; sellOrderPlacedForBar = false; } float openPrice = sc->Open[sc->Index]; float closePrice = sc->Close[sc->Index]; if (closePrice > openPrice) // Bullish candle: Close higher than Open { if (!buyOrderPlacedForBar) { SCString orderMessage; orderMessage.Format("Buy Market Order, Bullish Candle, Price: %f", closePrice); sc->AddMessageToLog(orderMessage, 1); s_SCPositionData PositionData; sc->GetPositionData(PositionData); // Basic logic: only place buy if not already long or short if (PositionData.PositionQuantity == 0 || PositionData.PositionQuantity < 0) { SCString submitMessage; submitMessage.Format("BUY %d", tradeQuantity); sc->SubmitMarketOrder(submitMessage); buyOrderPlacedForBar = true; sellOrderPlacedForBar = false; // Reset sell flag } else { sc->AddMessageToLog("Not placing Buy order. Already in a Long position or not flat.", 1); } } } else if (closePrice < openPrice) // Bearish candle: Close lower than Open { if (!sellOrderPlacedForBar) { SCString orderMessage; orderMessage.Format("Sell Market Order, Bearish Candle, Price: %f", closePrice); sc->AddMessageToLog(orderMessage, 1); s_SCPositionData PositionData; sc->GetPositionData(PositionData); // Basic logic: only place sell if not already short or long if (PositionData.PositionQuantity == 0 || PositionData.PositionQuantity > 0) { SCString submitMessage; submitMessage.Format("SELL %d", tradeQuantity); sc->SubmitMarketOrder(submitMessage); sellOrderPlacedForBar = true; buyOrderPlacedForBar = false; // Reset buy flag } else { sc->AddMessageToLog("Not placing Sell order. Already in a Short position or not flat.", 1); } } } else // Do nothing for Doji or neutral candles (Open == Close) { // Optionally, you can add a log message for Doji candles if you want // sc->AddMessageToLog("Doji candle - No trade.", 1); } return; } When i go to Analysis->Build Custom Study DLL->Select the file "candlebuysell.h" and hit Remote Build i got this: Allow time for the server to compile the files and build the DLL. Server: https://build.sierrachart.com The remote build is complete. The build failed. The compiler response is empty. -- End of Build -- 05:19:48 Anyone knows what is happening? If I save the file as CCP it throws tons of errors. to be honest i do not want help coding. I want to know if I have set the compiler or whatsoever correctly. I got this on Visual C++Path: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build I downloaded visual studio DEsktop C++ and the "MVSC v140 - VS 2015 C++ built tools (v14.0)" as i saw on another thread. |
[2025-02-06 10:43:16] |
User431178 - Posts: 613 |
Anyone knows what is happening? If I save the file as CCP it throws tons of errors. to be honest i do not want help coding. I want to know if I have set the compiler or whatsoever correctly. Nothing to do with compiler, Gemini has given you a load of bullshit code. |
[2025-02-06 10:55:08] |
Tin43 - Posts: 139 |
Hahahahah thank you for your answer. i previously did something and was right. But I do not know why I have to enable and disable the Automate trade chart enabled and Global. So i tried a more simplistic strategy but seems it got worst. To be honest I was using Deepseek. I will try again knowing that the compiler is good! THANKS!! Date Time Of Last Edit: 2025-02-06 10:55:48
|
[2025-02-06 11:09:25] |
User431178 - Posts: 613 |
😁 Not used Deepseek personally. You might fare better with gpt4o or claude sonnet. |
[2025-02-06 12:17:07] |
Tin43 - Posts: 139 |
Thanks again!!! I will try cloud sonnet. Didn't know about that IA.
|
[2025-02-06 14:03:31] |
cmet - Posts: 677 |
GPT just released o3-mini-high. Designed specifically for coding, reasoning and logic. Very thorough but slower. DeepSeek is garbage for anything demanding. Not sure why there's so much hype around that. AI lite. Install VisualStudio and use that compiler within SC. For example, here's the thinking/reasoning output only from o3-mini-high on basic instructions like you posted above: "a one minute Candlestick chart. I want you to set a buy market order is the candle is bullish and a sell market order is the candle is bearish. close below the low of previous bar = bearish, close above high of previous bar = bullish." Creating order logic
I’m developing SierraChart ACSIL code to place buy market orders on a bullish one-minute candlestick and sell market orders on a bearish one-minute candlestick, using ACSIL standalone functions. Focusing on ACSIL I’m ensuring the SierraChart ACSIL code, based on C++, is checked for placing buy and sell market orders on one-minute candlestick charts, with a clear focus on the specified bullish and bearish conditions. Taking a closer look I’m integrating specific headers and ACSIL macros for SierraChart, ensuring code triggers on each bar update, and considering custom study names and chart study subgraphs as part of the implementation. Evaluating order timing I’m thinking through whether to place market orders immediately after a bar closes or at the next bar's open, ensuring the code aligns with the establish bullish or bearish conditions. Confirming order timing I’m considering if market orders should be sent immediately after a bar closes or at the next bar's open, while ensuring the condition is met and exploring ACSIL order submission methods. Crafting order logic I’m working through the SierraChart ACSIL code, ensuring buy and sell market orders are placed based on bullish and bearish conditions, with a focus on safe order execution per bar. Implementing key triggers I’m detailing the SierraChart ACSIL code, emphasizing precise order execution based on validated bullish or bearish conditions, and ensuring that each bar triggers only one order. Crafting order triggers I’m refining the SierraChart ACSIL code to ensure buy orders are placed when the current bar closes above the previous bar's high, while avoiding duplicate orders per bar. Ensuring precise orders I'm confirming that buy and sell orders are placed based on bullish or bearish conditions without considering open positions, as instructions only mention order creation, not position management. Implementing market orders I'm planning to submit market orders using sc.BuyEntry and sc.SellEntry, ensuring that the study allows trading and considering logging for debugging. Ensuring order precision I’m ensuring that market orders trigger only when bars close, using strict comparisons to confirm order conditions. This approach maintains precise order execution and prevents premature triggering. Managing order triggers OK, let's tackle managing multiple calls per bar using persistent variables. This approach ensures that orders only trigger once per bar, maintaining precise execution. Guaranteeing single triggers I’m thinking through how to ensure each bar processes only once using sc.GetPersistentInt() to track the last processed bar and discard redundant triggers. Ensuring single bar execution By tracking the last processed bar with sc.GetPersistentInt(), I ensure each bar is processed only once, avoiding redundant orders. Implementing persistent tracking I’m setting up persistent tracking with sc.GetPersistentInt() to ensure each bar is processed only once. This helps in precise order management, avoiding redundant triggers. Ensuring finalization I’m finalizing the implementation to ensure orders trigger only when a bar is closed. By using sc.GetBarHasClosedStatus(), this avoids premature processing during active market updates. Ensuring precise execution I’m refining the script to trigger orders only when the latest bar closes. This ensures book entries are processed accurately, preventing premature orders. Tracking progress I’m focusing on storing the last processed bar index to ensure only new entries trigger orders, maintaining precise execution. Mapping out the script I’m refining the script to track the last processed bar index, triggering buy or sell orders based on current and previous bar conditions. This ensures precise entry points. Setting up Sierra Chart I'm organizing the setup for Sierra Chart, defining the global variable and function within SCSFExport to ensure smooth script execution. This clarity paves the way for more accurate trading signals. Setting up and managing I'm setting up a Sierra Chart script to manage buy or sell orders based on candle patterns. This involves setting defaults, checking conditions, and tracking processed bars. Assessing accuracy I’m examining the script's accuracy, ensuring it’s standalone without Canvas. It accurately handles defaults and bar closures, and it triggers buy or sell orders based on candle conditions. Ensuring accuracy I’m verifying the script's logic to handle multiple orders and confirm it correctly processes complete bars using sc.GetBarHasClosedStatus, aiming for precise execution. Finalizing the details I'm wrapping up the script, ensuring it handles multiple orders, utilizes sc.BuyEntry correctly, and compiles standalone for Sierra Chart. This concludes the efficient execution. Date Time Of Last Edit: 2025-02-06 14:32:27
|
[2025-02-06 22:15:43] |
Tin43 - Posts: 139 |
Big thanks!!!!!
|
[2025-02-07 00:23:21] |
Tin43 - Posts: 139 |
To the guy that recommended me Claude sonnet.. HUGE THANKS. I pay the monthly subscription. Totally worth it. That things works GREAT with ACSIL. I didn't have to link any documentation at all. And when there was an error I just copy the error from the Visual C++ - Debug compiler show me and that's it. I could do 50% of the job in one hour. I will continue tomorrow!!!! HUGE THANKS. P.S: Apologies for my English. Yes I know I could use the IA, but i want to practice an learn. :p Date Time Of Last Edit: 2025-02-07 00:24:23
|
To post a message in this thread, you need to log in with your Sierra Chart account: