Support Board
Date/Time: Sun, 06 Jul 2025 11:16:44 +0000
[Programming Help] - Help with a chatGPT built study
View Count: 142
[2025-06-21 19:03:35] |
User294249 - Posts: 1 |
Hey all I'm no coder first and foremost, so please bear with me. I wanted a study that assisted in calculating my R:R while taking into account position size and multiple targets. So naturally I used ChatGPT but of course things are never that easy, the coded is obviously not compatible and I'm unable to figure out the remedy. Any suggestion would be appreciated. #include "sierrachart.h" SCDLLName("Multi-Target R:R (Ticks Compatible Final)") SCSFExport scsf_MultiTargetRiskRewardTicks(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "Multi-Target Risk-Reward (Ticks)"; sc.AutoLoop = 0; return; } float TickSize = (float)sc.TickSize; // ✅ FIXED: Correctly use reference, not pointer s_SCPositionData PositionData; sc.GetTradePosition(PositionData); int PositionSize = (int)PositionData.PositionQuantity; float EntryPrice = (float)PositionData.AveragePrice; if (PositionSize == 0 || EntryPrice == 0.0f || TickSize <= 0.0f) { sc.DeleteACSChartDrawing(sc.ChartNumber, TOOL_DELETE_ALL); return; } float StopPrice = 0.0f; struct TargetInfo { float Price; float Weight; }; std::vector<TargetInfo> Targets; for (int i = 0; i < 100; ++i) { s_UseTool Tool; Tool.Clear(); // ✅ FIXED: correct argument count and types if (sc.GetUserDrawnChartDrawing(sc.ChartNumber, i, Tool, 0) == 0) break; const char* label = Tool.Text.GetChars(); if (strstr(label, "Stop") || strstr(label, "stop")) { StopPrice = (float)Tool.BeginValue; } else if (strstr(label, "Target") || strstr(label, "target")) { TargetInfo t; t.Price = (float)Tool.BeginValue; t.Weight = 100.0f; const char* colon = strchr(label, ':'); if (colon != NULL) { t.Weight = (float)atof(colon + 1); } Targets.push_back(t); } } if (StopPrice == 0.0f || Targets.empty()) return; float RiskTicks = fabs(EntryPrice - StopPrice) / TickSize; if (RiskTicks == 0.0f) return; float WeightedRR = 0.0f; float TotalWeight = 0.0f; SCString Output; Output.Format("Entry: %.2f | Stop: %.2f | Risk: %.1f ticks\n", EntryPrice, StopPrice, RiskTicks); for (size_t i = 0; i < Targets.size(); ++i) { float RewardTicks = fabs(Targets.Price - EntryPrice) / TickSize; float RR = RewardTicks / RiskTicks; float Weight = Targets.Weight / 100.0f; WeightedRR += RR * Weight; TotalWeight += Weight; Output += SCString().Format("Target %.2f (%.0f%%): R:R %.2f (%.1f ticks)\n", Targets.Price, Targets.Weight, RR, RewardTicks); } float AvgRR = (TotalWeight > 0) ? (WeightedRR / TotalWeight) : 0.0f; Output += SCString().Format("Weighted Avg R:R: %.2f | Pos: %d", AvgRR, PositionSize); s_UseTool Display; Display.Clear(); Display.ChartNumber = sc.ChartNumber; Display.DrawingType = DRAWING_TEXT; Display.Text = Output; Display.FontSize = 12; Display.Color = RGB(255, 215, 0); Display.Region = 0; Display.UseRelativeVerticalValues = 1; Display.BeginDateTime = sc.BaseDateTimeIn[sc.ArraySize - 1]; Display.BeginValue = sc.Close[sc.ArraySize - 1] + 4 * TickSize; Display.AddMethod = UTAM_ADD_OR_ADJUST; Display.LineNumber = 7777; sc.UseTool(Display); } |
![]() Attachment Deleted. |
[2025-06-22 02:30:56] |
D.Vicious - Posts: 20 |
Without looking at your actual code, make sure your using the right model should be o4-mini-high. You can download the whole ASCIL documentation as a zip and load that into your project, tell gpt to reference/search if need be. And the big thing is to step through your project, "let's find x and throw it's value in a debug log" "now let's find y....." So naturally I used ChatGPT but of course things are never that easy
It can be. I have used it to clean up, modify & build from scratch. Another important thing is to review the code and ask questions. If you put in some effort you will be amazed at how you can start to pick up on logic and flow.GL! Date Time Of Last Edit: 2025-06-22 02:34:26
|
To post a message in this thread, you need to log in with your Sierra Chart account: