Jump to content
Medved Trader Forums

Doug Hayman

Members
  • Posts

    293
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by Doug Hayman

  1. Hi Mike, I am running latest Beta version that was put out yesterday, and the notes say that some Pivot issues were addressed. Just want to confirm with you that this thread's issues have not been addressed yet; the problems noted above still exist. Thanks, Doug
  2. I have a standard indicator and a Paintbar that I display for both on my chart as either "Band on Top" or "Band on Bottom" - I periodically toggle between the 2 for both, depending on whether the price action is at the top or bottom of my chart screen. At any given time, I either want them both displayed at top of bottom of chart. When I switch to "Band of Top" vs. "Band of Bottom", the display ordering of these 2 visual indicators changes depend on whether they are on top or bottom of chart screen, and is not controllable by the ordering imposed in the "Selected Indicator" screen. Is there any way to make these consistent, so that the display ordering remains the same whether they're at the top or bottom of the chart screen?
  3. Running latest Beta from this morning, but I've seen this problem before. I have a layout that has a chart that makes use of Paintbars. Within a given paintbar, I have 4 user-defined audio alerts (TriggerAlerts()), where the sound files are stored in a dedicated folder outside of the MT file tree structure. When I toggle to a different paintbar on this chart that similarly has 3 user-defined audio alerts, and then go back to the original paintbar, the audio files associated with the 4 alerts become jumbled - that is the the wrong audio files are now associated with each of the Triggers, and I need to manually map them back to their desired mapping.
  4. Similar to above, I'm also getting "NaN" for Current Bar values for Intraday Pivot Points for both Camarilla Pivots and Woodies CCI Pivots as well, during real-time trading. Values during non-real-time backtest do yield values however, similar to behavior noted above. Quite unrelated (but I'm putting it here), I'm also getting "NaN" for "Woodies ChopZone" and "Woodies Sidewinder" variables for ALL bars. Advanced Paintbar mode is allowing me to expose variables of these type as Double, but perhaps they shouldn't haven't been exposed as variables??? Again, proving all via LogString() calls.
  5. Here's a corollary bug that I found today, which makes Pivot point values for the Current Bar unattainable with real-time Paintbars. In an Advanced Paintbar, I declare variables for pivot points (R4,R3,R2,R1,Pivot,S1,S2,S3,S4). They are declared as Pivot Point (Intraday), and the period is "Daily". When I access the variable values in code, during a Paintbar backtest, these values are set correctly. I verified with LogString(). I use the SetDaysNeeded(x) call noted above, to force these values to correctness. However, when I run the Paintbar in real-time during trading hours, the current values of all of the aforementioned PivotPoints for the Current Bar return "NaN" (not a #). I tried commenting out the call to SetDaysNeeded(x) in my code, but this made no difference at all; in real-time these values are still coming back as "NaN". Thanks in advance for looking into this further. P.S. For Horizontal Line values like Today's High, Yesterday's Low, etc., variables of Horizontal Line (intraday) were fine in real-time. Also, not that I think it should matter, but I was using Instrument @MESU20, with 1 point Range Bars. P.P.S. I'm running V1.1.9150.8 that Jerry sent me last week.
  6. Mike, Before I sign up, can your "trading" API calls be made from within Advanced Paintbars in MT? I realize your API is geared for external program access, but I would be interested in automated trading from within your Advanced Paintbar environment, using IB broker. If this can be accomplished, then I'm very interested. Back in the early 2000's, I used the Wealthlab environment to have back-tested algos trade for me - I still remember the day I had a logic error in my code, and trades were firing off and I screamed bloody hell......my wife thought that someone was killing me! Doug
  7. No, I am looking at Pivots and Horizontal line values throughout my data set. All seem to be working now, but specifically, Pivot accuracy aided by the SetDaysNeeded(x) call.
  8. OK, resolved the "Today's High" and "Today's Low" issue above. I had the "Show Last Day Only" checkbox flag inadvertently checked. So, only issue remaining is why the Pivots values are only calculated properly in Advanced Mode when SetDaysNeeded(x) call is made.
  9. OK guys, here's the deal: I loaded Jerry's fix this morning (thanks for the quick turnaround), but values are still quite skewed, so the fix didn't seem to work. However, I read Mike's first Email last night before I went to bed, which he subsequently overwrote, that told me to use: SetDaysNeeded(3); at the top of my main procedure. That, in fact, worked. As a matter of fact, it fixed the issue for my entire data set (several months' worth), not just 3 days. So, with this fix, all Pivot points seem to work fine now. Given that fix, a corollary issue is that variables I create for both "Today's High" and "Today's Low" are not providing me with values, and are displaying in log as "NaN" (not a number). For example, Variable: PivotTH (today's high) Indicator: Horizontal Line (Intraday) Param: H-High, Value=High Value Name: Line "Previous High" and "Previous Low" are calculated and displayed fine.
  10. Hi guys, I generated an Advanced Paintbar, which is trying to access various Pivot point values in my Intraday chart, where I added a Pivot Point Daily Indicator. In C# code, I created variables to represent the various Pivot Points. As an example, Var Name: PivotR1 Indicator: Pivot Point (Intraday) Param: D (Daily) Value Name: R1 When I access the values of this variable, PivotR1 in this case, the value I get doesn't come close to the R1 value displayed on my intraday chart. I used the LogFile() print function to display the values in my DBGVIEW.EXE output window at particular time junctures. My desired result is to obtain various Pivot point values in a given trading day, where these values generated will equate specifically to the those Pivot point values for that trading day, as indicated on my Intraday chart. Am I assuming something wrong here, or is this a bug????
  11. OK, I figured out a solution (sort of): I used the following logic: Timestamp >= session.SessionEnd.Addminutes(-C), where -C is an arbitrary negative constant prior to end of session.
  12. I'm looking for the purposes of back-testing, to close an open position if the current timestamp >= the End of Session. However, I'm using Range Bars, where its timestamp completes at close of bar, and no bars are started, if not completed, prior to end of session. Hence, the logic Timestamp >= session.SessionEnd doesn't achieve the desired results. Can you offer any solutions here? Thanks in advance.
  13. OVERVIEW: This is a first cut at a crude MT-based back-testing system I came up with using Mike's idea (above) of using the LogString() function and the Microsoft tool DBGVIEW.EXE to capture Paintbar output. QUESTION FOR MEDVED TEAM: Not sure what the policy is for uploading files on this forum, but which of these can I upload and attach to this post? Parse.Bat (source code displayed below) ParseToCSV.exe (source code display below) BackTest.xlsx (spreadsheet to load and post-process back-testing CSV data). Created using the lowest common denominator version I could find - Excel 2010, and contains no macros. This is a key element for displaying backtest results. NOTE: If I'm unable to attach these in forum, anyone can Email me to send these. LIMITATIONS: Can only test 1 intraday symbol chart at once; although I didn't test it, this system should work on historical data as well; Only 1 trade for symbol (long or short) can be active at once; # of Shares/Contracts being tested (all or nothing) should be assigned in variable "NumSharesContracts" in code; Commission per Share/Contract should be estimated and assigned to variable "Commission". For fixed commissions, divide the commission by # Shares traded; Enter the value for ShareContractValue variable. Should be '1.00' for stocks, or point value for contracts; All dates/times of generated CSV records are in UTC, so if you want to synch up your trades with your Intraday chart, you will have to do the necessary date math (for example, as of this posting, UTC times are 4 hours ahead of EST times). Of course, you can change your chart's timeframe to UTC too; Best to run this backtesting facility when market isn't active; otherwise you may get repetitive signals for current Bar; INITIAL ONE-TIME SETUP: Create a Back-testing folder on your computer; Download DBGVIEW.EXE from Microsoft website to this folder (see Mike's post above for link); Create a DOS .CMD or .BAT file (I call it Parse.BAT) in folder, using Code for BAT file below. NOTE: I couldn't figure out how to Parse through a file in DOS and grab data from a certain line position, so I wrote a small VB program (ParseToCSV.exe) to accomplish this, which is called from the .BAT file. The source code is below, which can be compiled on your end, or you can replace the ParseToCSV.exe line in the .BAT file with your own parser. CODE FOR PARSE.BAT: ======================================================================= @echo off rem The following DEL command will generate error if run for first time del/q dbgview.csv findstr " PAINTBAR:" dbgview.log > dbgview.txt ParseToCsv.exe ======================================================================= CODE FOR PARSETOCSV.BAS (used to generate ParseToCSV.exe, called in PARSE.BAT): The generated .EXE was compiled using VB6.0 32-bit, which should run on all MT machines: =================================================== Attribute VB_Name = "ParseToCSV" Option Explicit Sub Main() Dim InputFile, OutputFile, Line, NewLine As String Dim Length, PaintbarPosition As Integer InputFile = "dbgview.txt" OutputFile = "dbgview.csv" Open InputFile For Input As #1 Open OutputFile For Output As #2 Do While Not EOF(1) Line Input #1, Line Length = Len(Line) PaintbarPosition = InStr(1, Line, "PAINTBAR") NewLine = Mid$(Line, PaintbarPosition + 25, Length - (PaintbarPosition + 25)) Print #2, NewLine Loop Close #1 Close #2 End Sub =================================================== ADVANCED PAINTBAR CODE FOR BACK-TESTING (need to create an Advanced Paintbar): 1) You will need to add your Buy/Short criteria logic yourself; 2) There are some paintbar/audio options in the code, that you can choose to add or not; 3) You will need to add your Sell/Cover exit criteria logic yourself; 4) You will need to add MT "State" Logic templates to your code (see the STATE tab in Advanced mode), and you will need to add my logic to the: a) PaintbarInitialize() (see below) b) PaintbarState structure (see below) Here's the full Back-testing Paintbar Code: private void PaintbarInitialize() { string TradeCSVHeader; TradeCSVHeader = "SYMBOL,START DATE/TIME,START ORDER TYPE,SHARES/CONTRACTS,START PRICE,END DATE/TIME,END ORDER TYPE,END PRICE,PROFIT"; LogString(TradeCSVHeader); // writes to the DBGVIEW.EXE output window } /// <summary> /// Holds paintbar state - fill with variables needed to be preserved for next paintbar calc /// </summary> private struct PaintbarState { public bool InTrade, LongTrade; public string StartOrderType, EndOrderType; public string StartDateTime; public double StartPrice; } public void MainCalculation() { string TradeSymbol = "@MESU20"; // Enter symbol you are back-testing here int NumSharesContracts = 1; // Enter # of Shares/Contracts traded in back-test double Commission = 0.94; // Round-Trip, per-share/contract commission double ShareContractValue = 5.00; // Value of each point. Enter 1.00 for stocks; point value for contracts double Profit; string EndDateTime; double EndPrice; string TradeCSVString; // Condition for Long Trade if (ENTER YOUR LONG TRADE LOGIC HERE, ALONG WITH FOLLOWING CONDITION) & (!CurrentState.InTrade) { CurrentState.InTrade = true; CurrentState.LongTrade = true; CurrentState.StartOrderType = "Buy"; CurrentState.EndOrderType = "Sell"; CurrentState.StartPrice = Close; // This will be depend on your strategy CurrentState.StartDateTime = Timestamp.ToString(); SetColor(SysColor.MainIndicator2); // OPTIONAL: paints chart for Buy if PB used in real-time TriggerAlert ("Buy Stop"); // OPTONAL: provides audio alert if PB used in real-time } // Condition for Short Trade if (ENTER YOUR SHORT TRADE LOGIC HERE, ALONG WITH FOLLOWING CONDITION) & (!CurrentState.InTrade)) { CurrentState.InTrade = true; CurrentState.LongTrade = false; CurrentState.StartOrderType = "Short"; CurrentState.EndOrderType = "Cover"; CurrentState.StartDateTime = Timestamp.ToString(); CurrentState.StartPrice = Close; // This will be depend on your strategy SetColor(SysColor.MainIndicator3); // OPTIONAL: paints chart for Short if PB used in real-time TriggerAlert ("Sell Stop"); // OPTIONAL: provides audio alert if PB used in real-time } // If currently in a trade, Check to see if current trade should be exited // Check for Long position exit if ((CurrentState.InTrade) & (CurrentState.LongTrade)) { if (ENTER YOU LONG TRADE EXIT LOGIC HERE) { CurrentState.InTrade = false; EndPrice = Close; // This will be depend on your strategy EndDateTime = Timestamp.ToString(); Profit = ((EndPrice - CurrentState.StartPrice) * NumSharesContracts * ShareContractValue) - (Commission * NumSharesContracts); TradeCSVString = TradeSymbol + "," + CurrentState.StartDateTime + "," + CurrentState.StartOrderType + "," + NumSharesContracts.ToString() + "," + CurrentState.StartPrice.ToString() + "," + EndDateTime + "," + CurrentState.EndOrderType + "," + EndPrice.ToString() + "," + Profit.ToString(); LogString(TradeCSVString); // writes to the DBGVIEW.EXE output window SetColor(SysColor.MainIndicator4); // OPTIONAL: paints chart for Flatten Position if PB used in real-time TriggerAlert ("Flatten Position"); // OPTIONAL: provides audio alert to flatten position if PB used in real-time } } // Check for Short position exit if ((CurrentState.InTrade) & (!CurrentState.LongTrade)) { if (ENTER YOUR SHORT TRADE EXIT LOGIC HERE) { CurrentState.InTrade = false; EndPrice = Close; // This will be depend on your strategy EndDateTime = Timestamp.ToString(); Profit = ((CurrentState.StartPrice - EndPrice) * NumSharesContracts * ShareContractValue) - (Commission * NumSharesContracts); TradeCSVString = TradeSymbol + "," + CurrentState.StartDateTime + "," + CurrentState.StartOrderType + "," + NumSharesContracts.ToString() + "," + CurrentState.StartPrice.ToString() + "," + EndDateTime + "," + CurrentState.EndOrderType + "," + EndPrice.ToString() + "," + Profit.ToString(); LogString(TradeCSVString); // writes to the DBGVIEW.EXE output window SetColor(SysColor.MainIndicator4); // OPTIONAL: paints chart for Flatten Position if PB used in real-time TriggerAlert ("Flatten Position"); // OPTIONAL: provides audio alert to flatten position if PB used in real-time } } } ============================================================================= SAMPLE .CSV OUTPUT FILE GENERATED Here's a small excerpt of a .CSV file created from one of my Intraday strategies, for @MESU20: SYMBOL,START DATE/TIME,START ORDER TYPE,SHARES/CONTRACTS,START PRICE,END DATE/TIME,END ORDER TYPE,END PRICE,PROFIT @MESU20,6/2/2020 1:31:07 PM,Short,1,3046.25,6/2/2020 1:37:37 PM,Cover,3045.5,2.81 @MESU20,6/12/2020 7:12:22 AM,Buy,1,3040.25,6/12/2020 7:19:22 AM,Sell,3041.75,6.56 TO EXECUTE BACK-TESTING SYSTEM END-TO-END: Invoke DBGVIEW.EXE; if it's already running, kill the process and re-invoke. Execute Back-Testing Paintbar Code. You will have to reload your layout containing the Back-Testing Intraday Paintbar. This will generate trade log file entries in the DBGVIEW.EXE window; Save the output generated in the DBGVIEW.EXE windows to your back-testing folder and name file DBGVIEW.LOG; From a DOS session, Run Parse.bat. It will generate DBGVIEW.CSV, which are a sequence of CSV records that include all information associated with all simulated trades that met your criteria (one line per trade); Load DBGVIEW.CSV into either my spreadsheet (the "dbgview" sheet of BackTest.xlsx) or into your own spreadsheet, if I'm not allowed to upload it, for analysis. In my spreadsheet, load/overwrite contents of the "dbgview" sheet in BackTest.xlsx with DBGVIEW.CSV. WARNING: DO NOT "DELETE" contents of existing "dbgview" sheet to accomplish this; alternatively, use "CLEAR ALL". If you "DELETE", the formulas in the "TradeResults" analysis sheet will result in #REF! cell references. Back-testing results for this loaded data set will appear in summary in the "TradeResults" sheet. Also, you may want to use the Format->Autoformat feature to make the "dbgview" sheet more readable. The TradeResults sheet can be enhanced to add additional back-testing summary data (for example, daily or weekly roll-up). 6. Again, you will have to kill the DBGVIEW.EXE process and re-start it to re-run or execute a different Back-test (yes, this is very crude), since an active DBGVIEW.EXE session will have accumulated data in it since its invocation.
  14. Yeah, I just downloaded the .EXE and tested this. This will definitely work for me. Need to think about it some, but I think I'll generate a concatenated CSV record for each trade in my Paintbar, filter output from Debug log file, and then parse/import into Excel, to do post-analysis, roll-ups, etc. Thanks again for sharing.
  15. Oh, interesting. I think you just resurrected my interest in a current backtesting system. Thanks for the heads up.
  16. Mike (or Jerry), I have an old Wealthlab system (Pascal-based) that I still use for back-testing, but unfortunately it doesn't support Range Bars, which has become a favorite in my trading. I'm looking into trying to accomplish this in MT, if possible. Paintbars are great for real-time trade alerts, but if I want to test my logic over 120 days, it is cumbersome to have to manually inspect trades, profit, etc. I am intrigued by your post above, where you suggest that Paintbar logic can simulate trades and alerts. As far as I can see, Alerts in Paintbars can only add visual or audio alerts, but cannot record/simulate trades. 1) Could you provide any examples on how I could send simulated trades (using a simulated acct) to the Alert Mgr, which in turn, could be fed into the Account View screen, which could then automate the calculation of P/L? 2) As an aside, are there any plans for any sort of crude back-testing facility being released in MT, or is your focus in developing a trading API that can be accessed in Paintbar logic? Thanks in advance for any advice you can provide on the above.
  17. Wow, that was easy. Was not aware that Charts have an associated time frame. I just needed a filter to examine paintbar logic during trading hours. Thanks!
  18. Hey guys, I am applying a Paintbar to MES CME micro futures ticker. I established a user-defined time frame in MT Settings to be from 9:30 AM ET to 4:15 PM ET, and have made this my Default time frame setting. Why does the following C++ code snippet not restrict my paintbar rules to be restricted to the above hours only? ...... } Thanks in advance.
  19. Excellent guys, thanks. I wasn’t aware of how to obtain the current candle state. That will work just fine.
  20. Hi guys, I have a strategy that makes use of Range Bars. I would like to provide an audible alert every time a range bar completes. Is there any way to achieve this (via Paintbar call or Other means)? Thanks in advance.
×
×
  • Create New...