Support Board
Date/Time: Fri, 14 Mar 2025 14:20:26 +0000
Post From: Simple... coding?
[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. |