s_VolumeAtPriceV2* p_VolumeAtPriceAtIndex = 0; ??? - Sierra Chart Programming | futures io social day trading
futures io futures trading


s_VolumeAtPriceV2* p_VolumeAtPriceAtIndex = 0; ???
Updated: Views / Replies:1,236 / 9
Created: by yonatan Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you dont need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

s_VolumeAtPriceV2* p_VolumeAtPriceAtIndex = 0; ???

  #1 (permalink)
Elite Member
Haifa Israel
 
Futures Experience: Beginner
Platform: sierra chart
Broker/Data: Optimus Trading Group/Rithmic
Favorite Futures: es
 
Posts: 90 since Apr 2012
Thanks: 49 given, 65 received

s_VolumeAtPriceV2* p_VolumeAtPriceAtIndex = 0; ???

The following line is taken from a code that was kindly sent to me by @Ymmv.

s_VolumeAtPriceV2* p_VolumeAtPriceAtIndex = 0;


I an breaking my teeth trying to understand this line and will be grateful for any help understanding it ( I am just beginning with ACSIL and C++ and am not a programming expert in general).



Here is the full code and it is working just fine (identifying the price with the max volume within a bar).


/* Date: 2012-05-21
Version: 1.0
Author: Ymmv
https://futures.io/sierra-chart-programming/20255-acsil-function-returns-price-highest-volume-within-bar.html
*/

#include "sierrachart.h"
#include "scstudyfunctions.h"
#include <math.h>
SCDLLName("High Volume At Price")

SCSFExport scsf_HighVAP(SCStudyInterfaceRef sc)
{
SCSubgraphRef MaxVAP = sc.Subgraph[0];

if (sc.SetDefaults)
{
// During development set this flag to 1, so the DLL can be modified. When development is done, set it to 0 to improve performance.
sc.FreeDLL = 0;

sc.GraphName = "High Volume At Price";
sc.StudyDescription = "Display high volume at price for each bar.";
sc.AutoLoop = 1;
sc.GraphRegion = 0;
sc.ScaleRangeType = SCALE_SAMEASREGION;
sc.MaintainVolumeAtPriceData = 1;

MaxVAP.Name = "MaxVAP";
MaxVAP.DrawStyle = DRAWSTYLE_DASH;
MaxVAP.LineWidth = 2;
MaxVAP.PrimaryColor = COLOR_YELLOW;

return;
}

if ((int)sc.VolumeAtPriceForBars->GetNumberOfBars() < sc.ArraySize)
return;

unsigned int MaxVolume = 0;
float MaxVolumePrice = 0;

int Count = sc.VolumeAtPriceForBars->GetSizeAtBarIndex(sc.Index);

for (int ElementIndex = 0; ElementIndex < Count; ElementIndex++)
{
s_VolumeAtPriceV2* p_VolumeAtPriceAtIndex = 0;
sc.VolumeAtPriceForBars->GetVAPElementAtIndex(sc.Index, ElementIndex, &p_VolumeAtPriceAtIndex);

if (p_VolumeAtPriceAtIndex &&
p_VolumeAtPriceAtIndex->Volume > MaxVolume)
{
MaxVolume = p_VolumeAtPriceAtIndex->Volume;
MaxVolumePrice = p_VolumeAtPriceAtIndex->PriceInTicks * sc.TickSize;
}
}

MaxVAP[sc.Index] = MaxVolumePrice;
}

Reply With Quote
The following user says Thank You to yonatan for this post:
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Naperville IL
 
Futures Experience: Intermediate
Platform: ninjatrader
Broker/Data: NT broker
Favorite Futures: NQ ES 6E GC CL
 
Posts: 954 since Feb 2010
Thanks: 1,184 given, 650 received


any change we can get zip file?

Reply With Quote
 
  #4 (permalink)
Elite Member
Haifa Israel
 
Futures Experience: Beginner
Platform: sierra chart
Broker/Data: Optimus Trading Group/Rithmic
Favorite Futures: es
 
Posts: 90 since Apr 2012
Thanks: 49 given, 65 received


supermht View Post
any change we can get zip file?

The code can be downloaded here:

https://futures.io/download/sierra_chart/1195-download.html?view

Reply With Quote
The following user says Thank You to yonatan for this post:
 
  #5 (permalink)
Elite Member
Haifa Israel
 
Futures Experience: Beginner
Platform: sierra chart
Broker/Data: Optimus Trading Group/Rithmic
Favorite Futures: es
 
Posts: 90 since Apr 2012
Thanks: 49 given, 65 received

Ok, after reading about pointers here :Pointers - C++ Documentation I think that I am beginning to understand this line.

The "*" symbol is not used here for multiplication but it is used to signify that we are talking about a pointer.
* p_VolumeAtPriceAtIndex refers not to the value of p_VolumeAtPriceAtIndex but to the value pointed by p_VolumeAtPriceAtIndex.

This line is the declaration of this pointer and my wild guess is that s_VolumeAtPriceV2 is the variable type.

I still have to fully understand this but it seems like I have clue.

Am I walking in the right direction ?

Reply With Quote
 
  #6 (permalink)
Elite Member
Madison, WI
 
Futures Experience: Advanced
Platform: Sierra Charts, ALT
Favorite Futures: ES
 
aslan's Avatar
 
Posts: 614 since Jan 2010
Thanks: 342 given, 1,077 received


yonatan View Post
The following line is taken from a code that was kindly sent to me by @Ymmv.

s_VolumeAtPriceV2* p_VolumeAtPriceAtIndex = 0;

I an breaking my teeth trying to understand this line and will be grateful for any help understanding it ( I am just beginning with ACSIL and C++ and am not a programming expert in general).

This line is just initializing the ptr to a null value before it gets filled in the subsequent call. It would have been clearer to say

 
Code

 s_VolumeAtPriceV2* p_VolumeAtPriceAtIndex = NULL;

Reply With Quote
 
  #7 (permalink)
Elite Member
Haifa Israel
 
Futures Experience: Beginner
Platform: sierra chart
Broker/Data: Optimus Trading Group/Rithmic
Favorite Futures: es
 
Posts: 90 since Apr 2012
Thanks: 49 given, 65 received


aslan View Post
This line is just initializing the ptr to a null value before it gets filled in the subsequent call. It would have been clearer to say

 
Code

 s_VolumeAtPriceV2* p_VolumeAtPriceAtIndex = NULL;

Yep thanks @aslan i think I just realized this :-)

Reply With Quote
 
  #8 (permalink)
Programmer
Poquoson VA USA
 
Futures Experience: Advanced
Platform: Proprietary
Favorite Futures: Futures
 
Posts: 13 since Jun 2010
Thanks: 3 given, 8 received


aslan View Post
This line is just initializing the ptr to a null value before it gets filled in the subsequent call. It would have been clearer to say

 
Code

 s_VolumeAtPriceV2* p_VolumeAtPriceAtIndex = NULL;

Note that technically C++ does not have a "NULL" type, that's more of a C thing. NULL is not always typesafe therefore the "official" recommendation in C++ is to use 0.

Not that it really matters in practice as it's a bit of a pedantic exercise.

Edit to clarify and add more information (sorry was in an unnecessary rush before):
Stroustrup himself (inventor of C++) plus a few other well known people is where I got the "official" recommendation from (technically there is nothing actually official about it which is why I quote it). See here: Stroustrup: C++ Style and Technique FAQ

The new C++11 has a "nullptr" keyword which serves the purpose of the old NULL in a typesafe way. Right now support for that is highly dependent on your compiler which is why I personally still use 0.


Last edited by Ymmv; June 29th, 2012 at 07:44 PM.
Reply With Quote
The following user says Thank You to Ymmv for this post:
 
  #9 (permalink)
Elite Member
Madison, WI
 
Futures Experience: Advanced
Platform: Sierra Charts, ALT
Favorite Futures: ES
 
aslan's Avatar
 
Posts: 614 since Jan 2010
Thanks: 342 given, 1,077 received

We will have to agree to disagree on the use of NULL. Obviously, using zero can be confusing or questions like this don't come up. If it had been NULL, then the new user can at least figure it out and look it up. It also makes scanning code easier, as searching for zero is going to have a few hits, while NULL is what it is.

If you read the ref, you will see it is talking about type safety (which NULL obviously isn't), but zero is not either. The other point they make is about dealing with pre-standard code (aka really old crap), and while that can be an issue in the really big picture, it is a non-issue for an indicator or anything that people are doing at this level.

Defining another macro for nullptr is a good tradeoff if you want future compatibility.

Reply With Quote
The following user says Thank You to aslan for this post:
 
  #10 (permalink)
Programmer
Poquoson VA USA
 
Futures Experience: Advanced
Platform: Proprietary
Favorite Futures: Futures
 
Posts: 13 since Jun 2010
Thanks: 3 given, 8 received


I don't think we're disagreeing per se because I wasn't trying to make an argument, only to explain the rational behind my personal choice. As I said, it's a bit of a pedantic exercise. I base my choices on what I have learned from other professionals and my own experience but that doesn't mean the other option is wrong. Especially in this case where NULL is very often the exact same thing as 0. Just be consistent.

Reply With Quote

Reply



futures io > > > > > s_VolumeAtPriceV2* p_VolumeAtPriceAtIndex = 0; ???

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     


All times are GMT -4. The time now is 05:04 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-13 in 0.12 seconds with 18 queries on phoenix via your IP 54.90.92.204