NexusFi: Find Your Edge


Home Menu

 





Time and sales coding in ACSIL


Discussion in Sierra Chart

Updated
      Top Posters
    1. looks_one Trembling Hand with 34 posts (15 thanks)
    2. looks_two liboro with 28 posts (2 thanks)
    3. looks_3 bobwest with 2 posts (1 thanks)
    4. looks_4 trendisyourfriend with 1 posts (0 thanks)
      Best Posters
    1. looks_one Big Mike with 1 thanks per post
    2. looks_two bobwest with 0.5 thanks per post
    3. looks_3 Trembling Hand with 0.4 thanks per post
    4. looks_4 liboro with 0.1 thanks per post
    1. trending_up 10,759 views
    2. thumb_up 19 thanks given
    3. group 5 followers
    1. forum 64 posts
    2. attach_file 11 attachments




 
Search this Thread

Time and sales coding in ACSIL

  #11 (permalink)
liboro
Prague
 
Posts: 28 since Nov 2016
Thanks Given: 8
Thanks Received: 2

Ok, thank you. I will be happy if you will let me know.



Trembling Hand View Post
Yes I think it's very possible but I'm away from my computer til tomorrow I'll have another look then.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
What broker to use for trading palladium futures
Commodities
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
 
  #12 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360

So here is a Study that will save the time and sales data to a txt file to C:\SierraChart\Data (modified from something on SC forum).
You can see some of the available data types commented out in the main loop.



 
Code
SCSFExport scsf_Save_TimeNSales(SCStudyGraphRef sc) {

    SCInputRef OutputFile = sc.Input[0];


    if (sc.SetDefaults) {

        // https://www.sierrachart.com/SupportBoard.php?ThreadID=36979

        sc.GraphName = "Save_TimeNSales";
        sc.StudyDescription = "Save Time and sales to file";
        sc.GraphRegion = 0;
        //sc.AutoLoop=true; 
        sc.FreeDLL = 1;

        OutputFile.Name = "The storage link";
        SCString OutputFileDefaultName;
        OutputFileDefaultName.Format("C:\\SierraChart\\Data\\1_%s.txt", sc.Symbol.GetSubString(2, 0).GetChars());
        OutputFile.SetString(OutputFileDefaultName);

    }

    std::ofstream file(OutputFile.GetString(), std::ios_base::app);

    if (!file) {

        SCString Buffer;
        Buffer.Format("Unable to open file %s", OutputFile.GetString());
        sc.AddMessageToLog(Buffer, 1);
        //return; 

    }



    if (sc.Index == sc.ArraySize - 1)
    {

        __int64& LastProcessedSequence = sc.GetPersistentInt64(1);
        c_SCTimeAndSalesArray TimeSales;
        sc.GetTimeAndSales(TimeSales);
        if (TimeSales.Size() == 0)
            return;


        if (LastProcessedSequence != 0)
        {
            for (int TSIndex = 0; TSIndex < TimeSales.Size(); ++TSIndex)
            {
                if (TimeSales[TSIndex].Sequence < LastProcessedSequence)
                    continue;

                if (TimeSales[TSIndex].Type == SC_TS_BID || TimeSales[TSIndex].Type == SC_TS_ASK)
                {
                    //int AskVol = TimeSales[TSIndex].AskSize;
                    //int TotalAsks = TimeSales[TSIndex].TotalAskDepth;
                    //int BidVol = TimeSales[TSIndex].BidSize;
                    //int TotalBids = TimeSales[TSIndex].TotalBidDepth;
                    float Price = TimeSales[TSIndex].Price;
                    int Vol = TimeSales[TSIndex].Volume;
                    int TradeType = TimeSales[TSIndex].Type; // at bid or ask



                    int ValueFormat = sc.BaseGraphValueFormat;
                    SCString formatString = " %i/%02i/%02i  %02i:%02i:%02i: %03i , Index: %i, Price: %0.4f, Vol: %i BidAsk: %i";
                    SCDateTime TradeDateTime = TimeSales[TSIndex].DateTime;
                    TradeDateTime += sc.TimeScaleAdjustment;
                    int Year, Month, Day, Hour, Minute, Second, MilliSecond;
                    TradeDateTime.GetDateTimeYMDHMS_MS(Year, Month, Day, Hour, Minute, Second, MilliSecond);


                    SCString BarDataString;
                    BarDataString.Format(formatString, Year, Month, Day, Hour, Minute, Second, MilliSecond, TSIndex, Price, Vol, TradeType);
                    file << BarDataString << std::endl;

                }

            }

        }

        LastProcessedSequence = TimeSales[TimeSales.Size() - 1].Sequence;

    }



}
Of course this only works with a live market connection.

Follow me on Twitter Reply With Quote
  #13 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360


I probably should of asked before I took the step but do you want this to work on historical data then that is a totally different method!

From SC Docs about sc.GetTimeAndSales()

See Docs


Quoting 

Alternative Way For Obtaining Time and Sales Data

Open a chart that is set to 1 Number of Trades Per Bar for the symbol you want Time and Sales for.

Select Global Settings >> Data/Trade Service Settings and make sure the Intraday Data Storage Time Unit is set to 1 Tick.

Use the sc.GetChartArray and the sc.GetChartDateTimeArray functions to access the price, volume and DateTime arrays. Every element in these arrays is 1 trade. This may actually be a preferred way of accessing trade by trade data since there will be an abundant amount of history available.


Follow me on Twitter Reply With Quote
  #14 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360


liboro View Post
I would like to code something like Large Volume Trade Indicator.

Do you think it is possible?

LOL. I should have know being Sierra Chart they have already made a Study......

https://www.sierrachart.com/index.php?page=doc/StudiesReference.php&ID=390&Name=Large_Volume_Trade_Indicator

Follow me on Twitter Reply With Quote
  #15 (permalink)
liboro
Prague
 
Posts: 28 since Nov 2016
Thanks Given: 8
Thanks Received: 2

Thank you for the codes and other help.

I understand the basics of the TS, but the crucial thing is how to work with the TS data within price leves in the bars - how these arrays would be allocated or how these arrays should look like (subgraphs arrays?)?

I know that SC has Large Volume Trade Indicator, but there is no source code available and I want to use it in my own way. That is the reason why I am trying to solve this.



Trembling Hand View Post


Reply With Quote
  #16 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360

What? I'm not sure what else you would need. If you are not able to use the above code samples then I guess you actually need to explain exactly what you are trying to do and maybe someone can do it for you. But every thing you have said so far is actually very short of what it seems like you really want.

Follow me on Twitter Reply With Quote
  #17 (permalink)
liboro
Prague
 
Posts: 28 since Nov 2016
Thanks Given: 8
Thanks Received: 2

PRICE 69.60 AV (from TS) = XY, BV (from TS) = XY
PRICE 69.61 AV (from TS) = XY, BV (from TS) = XY
PRICE 69.62 AV (from TS) = XY, BV (from TS) = XY
PRICE 69.63 AV (from TS) = XY, BV (from TS) = XY

Is it more clear now?

Put AV and BV to the relevant prices in the current bar.



Trembling Hand View Post
What? I'm not sure what else you would need. If you are not able to use the above code samples then I guess you actually need to explain exactly what you are trying to do and maybe someone can do it for you. But every thing you have said so far is actually very short of what it seems like you really want.


Reply With Quote
  #18 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360


liboro View Post
PRICE 69.60 AV (from TS) = XY, BV (from TS) = XY
PRICE 69.61 AV (from TS) = XY, BV (from TS) = XY
PRICE 69.62 AV (from TS) = XY, BV (from TS) = XY
PRICE 69.63 AV (from TS) = XY, BV (from TS) = XY

Is it more clear now?

Put AV and BV to the relevant prices in the current bar.

That's what the first study I wrote did in post #6!

Follow me on Twitter Reply With Quote
  #19 (permalink)
liboro
Prague
 
Posts: 28 since Nov 2016
Thanks Given: 8
Thanks Received: 2

I do understand the code in post #6, but as I mentioned, these data are from VAP function,
this is not the same as data in Time Sales data structure.

I believe there is no way how to use VAP for TS data.
Maybe I am wrong.



Trembling Hand View Post
That's what the first study I wrote did in post #6!


Reply With Quote
  #20 (permalink)
 Trembling Hand 
Melbourne, Land of Oz
 
Experience: Advanced
Platform: Sierra Chart, CQG
Broker: CQG
Trading: HSI
Posts: 246 since Jun 2011
Thanks Given: 28
Thanks Received: 360



liboro View Post
I do understand the code in post #6, but as I mentioned, these data are from VAP function,
this is not the same as data in Time Sales data structure.

I believe there is no way how to use VAP for TS data.
Maybe I am wrong.

I think you have a fundamental misunderstanding of what is going on here.

TS data is not a different data set from "other" data.

Could you explain why you think it is? Where does it come from?

Follow me on Twitter Reply With Quote




Last Updated on February 21, 2021


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts