Support Board
Date/Time: Sat, 23 Nov 2024 18:10:26 +0000
Post From: Trading Alert based on Multiple Charts
[2024-08-10 22:47:55] |
User413206 - Posts: 26 |
The following is a snippet from one of my ACSIL studies. The study is applied to the main chart that resides in a chartbook with two Renko charts. If you study the code, you will see that it pulls Renko price data from both the main and secondary charts. After studying the code, you should be able to add code to pull data from a third Renko chart. Once you have the arrays, you can use them in your trading logic. #include "sierrachart.h"
SCDLLName("RenkoTest") SCSFExport scsf_RenkoTest(SCStudyInterfaceRef sc) { /******************************************************************** * Define references to the Subgraphs and Inputs for easy reference * ********************************************************************/ // Input references SCInputRef ChartStudy = sc.Input[0]; // Reference secondary chart + // Section 1 - Set the configuration variables and defaults if (sc.SetDefaults) { sc.GraphName = "Renko Test"; sc.AutoLoop = 1; //Automatic looping is enabled. /******************************************* * Secondary Renko Chart Defaults * *******************************************/ ChartStudy.Name = "Secondary Chart Reference"; // Chart number 2, study number is irrelevant or 0, // because no study is attached to chart. ChartStudy.SetChartStudyValues(2, 0); return; } /*********************************************************** * DO NOT PROCESS WHILE DOWNLOADING DATA OR RECALCULATING * ***********************************************************/ if (sc.IsFullRecalculation || sc.DownloadingHistoricalData) { sc.AddMessageToLog("Processing halted: Data download or recalculation in progress.", 1); return; } /******************************************** * SECONDARY RENKO CHART DATA PROCESSING * ********************************************/ // 1. Define a graph data object to get // all of the base graph data from the secondary chart SCGraphData BaseGraphData; sc.GetChartBaseData(ChartStudy.GetChartNumber(), BaseGraphData); // 2. Create arrays for open and close prices from secondary chart. // - 2a. Get the Renko Open array from the secondary chart SCFloatArrayRef RenkoSecOpenArray = BaseGraphData[SC_RENKO_OPEN]; // - 2b. Get the Renko Close array from the secondary chart SCFloatArrayRef RenkoSecCloseArray = BaseGraphData[SC_RENKO_CLOSE]; // 4. Check if secondary array has enough bars. if (RenkoSecOpenArray.GetArraySize() < 2 || RenkoSecCloseArray.GetArraySize() < 2) { sc.AddMessageToLog("Insufficient data in secondary chart arrays.", 1); return; } // 5. Get the Renko open of the last completed bar on secondary chart. float RenkoSecOpen2 = RenkoSecOpenArray[RenkoSecOpenArray.GetArraySize() - 2]; // 6. Get the Renko close of the last completed bar on secondary chart. float RenkoSecClose2 = RenkoSecCloseArray[RenkoSecCloseArray.GetArraySize() - 2]; /******************************************** * MAIN RENKO CHART DATA PROCESSING * ********************************************/ // 1. Check if there are at least 5 elements/bars. if (sc.ArraySize < 5) { // If insufficient bars, return control to Sierra Chart sc.AddMessageToLog("Not enough data points in the main chart", 1); return; } // 2. Get the open and closing prices of the currently developing bar // and the last completed bar. // - 2a. Renko open of current/developing bar on main chart. float RenkoMainOpen = sc.BaseData[SC_RENKO_OPEN][sc.ArraySize - 1]; // - 2b. Renko open of most recently completed bar on main chart. float RenkoMainOpen2 = sc.BaseData[SC_RENKO_OPEN][sc.ArraySize - 2]; // - 2f. Renko close current/developing bar on main chart. float RenkoMainClose = sc.BaseData[SC_RENKO_CLOSE][sc.ArraySize - 1]; // - 2g. Renko close of most recently completed bar on main chart. float RenkoMainClose2 = sc.BaseData[SC_RENKO_CLOSE][sc.ArraySize - 2]; Date Time Of Last Edit: 2024-08-11 15:11:25
|