Support Board
Date/Time: Sat, 23 Nov 2024 23:59:57 +0000
Post From: Offering To The Community: Custom Stock Index Creator
[2016-12-15 07:23:00] |
Neo - Posts: 198 |
No need to apologize, Brett, thanks for looking into this further and explaining in more detail. The idea of automatically loading a study onto a newly open chart sounds great, however, it's over my head in terms of programming skills. Sorry to hear about your health issues, I had some minor issues with sleep Apnea and ended up resolving them by losing a whole lot of weight. Has your doctor ever suggested Modafinil to combat daytime sleepiness? The Biofeedback stuff looks really interesting, good luck with it. Re % of stocks in a chart book above VWAP- What do you think about this? It won't give historical values but will give values based on the last price. #include "sierrachart.h"
#include <string> #define MAX_ITERATIONS 10000 //This is a tentative solution to the problem of determining //the proportion of charts in a chartbook trading above their //respective VWAPs. using namespace std; SCDLLName("Proportion Trading Above/Below VWAP DLL") SCSFExport scsf_ProportionTradingAboveVWAP(SCStudyGraphRef sc){ SCInputRef ChartStudy = sc.Input[0]; if (sc.SetDefaults){ sc.GraphName = "Proportion Trading Above VWAP"; sc.AutoLoop = 1; sc.FreeDLL = 1; sc.Subgraph[0].Name = "Proportion Trading Above VWAP"; sc.Subgraph[0].PrimaryColor = RGB(255,0,0); return; } int num_of_charts; int num_trading_above_vwap = 0; for(num_of_charts = 1; num_of_charts < MAX_ITERATIONS; ++num_of_charts){ SCGraphData BaseGraphData; ChartStudy.SetChartStudyValues(num_of_charts, 1); sc.GetChartBaseData(ChartStudy.GetChartNumber(), BaseGraphData); if(BaseGraphData[SC_HIGH].GetArraySize() == 0){ //No more charts. break; } //Get the most recent trading price. int last_bar = BaseGraphData[SC_LAST].GetArraySize() - 1; float last_price = BaseGraphData[SC_LAST][last_bar]; //Get the VWAP for the specified period of time. float cumulative_price_volume = 0.0; float cumulative_volume = 0.0; int num_of_trades = last_bar + 1; for(int j = 0; j < num_of_trades; ++j){ cumulative_price_volume += BaseGraphData[SC_HLC][j] * BaseGraphData[SC_VOLUME][j]; cumulative_volume += BaseGraphData[SC_VOLUME][j]; } float VWAP = cumulative_price_volume / cumulative_volume; if(last_price > VWAP){ ++num_trading_above_vwap; } } --num_of_charts; float proportion_above_vwap = (float)num_trading_above_vwap / (float)num_of_charts; sc.Subgraph[0][sc.Index] = proportion_above_vwap; } |