Jump to content
Medved Trader Forums

Mike Medved

Administrators
  • Posts

    1,543
  • Joined

  • Last visited

  • Days Won

    124

Everything posted by Mike Medved

  1. It is even worse. Current "real" LULD levels reported by the exchange for ATIF are 20% from reference price. According to all the definitions I could find, that only applies to stocks that have previous close >0.75. ATIF's previous close was 0.5something. So how in the world are exchanges calculating LULD of 20% right now I have no idea. Continuing to look, I took a look at a stock that is 0.4 currently and not moving so its previous close was also <0.75. Its current LULD levels are 0.25 and 0.55. Like - huh? That corresponds to 37.5% offsets - which is exactly HALF of what they are supposed to be (0.75%). This is driving me nuts and there is no one to ask because it seems like I am the only one in the universe who is doing these calculations.
  2. Yes here was the problem (as I said, LULD definitions from exchanges are 1. not "official", I can only find proposals and 2. are not written clearly) See https://www.luldplan.com/ (this is one of the "simpler" explanations, there are others, more elaborate) the problem was with how I was interpreting the "Calculation of Price Bands" part - see the table. My calculation was limiting the band width to 0.15 - because it was going off the previous close (which is 0.75) but I am pretty sure when they say "Symbols below $3.00" they actually mean current price (although the widths % calculations are still going off the previous close). I will correct my code and it will be in next update.
  3. SetLine parameters - in the help file. I just gave it to Jerry he will put it up on the web later today. The variables - I guess you have to know C# a little. Variables that are defined inside the function are scoped in the function - they get reinitialized every time the function is entered. Variables defined outside the function stay there between function calls. There are also "State Variables" you can have in paintbars - that is a bit more complicated. Basically the state is saved and restored for the same-candle calls. The code above didn't need that but some things that need to be done (for example, EMA calculations) need that. The way to do that and why it should be done is explained in help as well: https://www.medvedtrader.com/trader/WebHelp/state_keeping.htm Basically you can think of the paintbar as a "state machine". When the MainCalculation is called, it is given a "state" and it generates the new "state" for the next candle. When the MainCalculation is entered for the same candle again (which is what happens when the paintbar is calculated on the newly incoming data) it is again given a "state" for the previous candle. Example: for EMA calculation, you always need the previous candle's EMA. So if you put that in the State, the new candle's EMA can always be calculated from the State's EMA - and the State's EMA will stay the same (and contain the previous candle's EMA) no matter how many times the MainCalculation is called for this candle. When it is called for the next candle, the saved State will contain the previous candle's state again. CurrentState structure can contain only simple variables. If you want to do state-machine with the FIFOQueues (for things like averages, standard deviation calcs, or stuff like looking at what some calculated value was N candles ago, use the StateFIFOQueue classes, and do the Save/Restore in the for them in the appropriate functions in the code - again, look in Help for examples.
  4. * For Volume - what you could do is use the Volume indicator in the paintbar, set a specific averaging period in its parameters, and use its EMA line. Or you could just calculate your own average for the BarVolume - but then you would have to go Advanced, use the State machinery, and the StateFIFOQueue (for SMA). See an example of how to do that here: https://www.medvedtrader.com/trader/WebHelp/state_keeping.htm the last example is for how to do SMAs. * The SymbolData.xxx variables are for the current values for the symbol. So even if you're calculating the paintbar for some candle way back in the chart, the SymbolData.Volume for example will be the current cumulative day volume that is stored for this symbol.
  5. As for your other questions - in general, it is pretty inefficient to use loops in paintbar code, because it executes so often. So you have to take advantage of the fact that at start the paintbar code is called for every candle, and then it is called for the last candle every time it updates with incoming data. Take a look at the code I provided here and see if you can understand how it works.
  6. As to your question how to do the high/low not AT 11am but since 11am - it is a fairly small change in the paintbar code.. .fctbNone{ color:#000000; } .fctbStyle3{ color:#ff00ff; } .fctbStyle5{ color:#0000ff; } .fctbStyle1{ color:#a52a2a; } .fctbStyle1Style3{ color:#ff00ff; }Double Today11amHigh = 0; Double Today11amLow = 0; int Today11amCandleNumberHigh = -1; int Today11amCandleNumberLow = -1; Double Prev11amHigh = 0; Double Prev11amLow = 0; int Prev11amCandleNumberHigh = -1; int Prev11amCandleNumberLow = -1; int DayNumber = -1; public void MainCalculation() { var today = TradingDay; if (today.DayNumber!=DayNumber) { Prev11amHigh = Today11amHigh; Prev11amLow = Today11amLow; Prev11amCandleNumberHigh = Today11amCandleNumberHigh; Prev11amCandleNumberLow = Today11amCandleNumberLow; Today11amHigh = 0; Today11amLow = 0; DayNumber = today.DayNumber; } if (Timestamp>=today.SessionStart.AddHours(1.5)) { if (High>Today11amHigh) { Today11amHigh = High; Today11amCandleNumberHigh = CandleNumber; } if (Today11amLow==0 || Low<Today11amLow) { Today11amLow = Low; Today11amCandleNumberLow = CandleNumber; } } if (Prev11amHigh!=0) { var highColor = GetNamedColor("High", SysColor.Positive); SetLine(1, highColor, Prev11amCandleNumberHigh,Prev11amHigh, 100000, Prev11amHigh, 1, "11H", LineTextPosition.RightAbove); } if (Prev11amLow!=0) { var lowColor = GetNamedColor("Low", SysColor.Negative); SetLine(2, lowColor, Prev11amCandleNumberLow,Prev11amLow, 100000, Prev11amLow, 1, "11L", LineTextPosition.RightBelow); } }
  7. Ok - first of all, documentation - yes. Either press F1 in MT or go to https://www.medvedtrader.com/trader/WebHelp/ - it is a pretty comprehensive help file for MT in general. All the available variables and MT specific functions are found here: https://www.medvedtrader.com/trader/WebHelp/advanced_-_all_available_funct.htm CandleNumber is recent so it has not been compiled into the help yet, I will ask Jerry to do that and put it up
  8. .fctbNone{ color:#000000; } .fctbStyle3{ color:#ff00ff; } .fctbStyle5{ color:#0000ff; } .fctbStyle3Style7{ color:#000000; } .fctbStyle1{ color:#a52a2a; } .fctbStyle7{ color:#000000; } .fctbStyle1Style6{ color:#800000; } .fctbStyle1Style3Style6Style7{ color:#000000; }Double Today11amHigh = 0; Double Today11amLow = 0; int Today11amCandleNumber = -1; Double Prev11amHigh = 0; Double Prev11amLow = 0; int Prev11amCandleNumber = -1; int DayNumber = -1; public void MainCalculation() { var today = TradingDay; if (today.DayNumber!=DayNumber) { Prev11amHigh = Today11amHigh; Prev11amLow = Today11amLow; Prev11amCandleNumber = Today11amCandleNumber; Today11amHigh = 0; Today11amLow = 0; DayNumber = today.DayNumber; } if (Today11amHigh==0 && Timestamp>=today.SessionStart.AddHours(1.5)) { Today11amHigh = High; Today11amLow = Low; Today11amCandleNumber = CandleNumber; } if (Prev11amHigh!=0) { var highColor = GetNamedColor("High", SysColor.Positive); SetLine(1, highColor, Prev11amCandleNumber,Prev11amHigh, 100000, Prev11amHigh, 1, "11H", LineTextPosition.RightAbove); var lowColor = GetNamedColor("Low", SysColor.Negative); SetLine(2, lowColor, Prev11amCandleNumber,Prev11amLow, 100000, Prev11amLow, 1, "11L", LineTextPosition.RightBelow); } }
  9. There is a little circle with a ? inside it next to each parameter. It explains what it means.
  10. Press SHIFT to as you draw or modify the line to make it horizontal.
  11. I will have it put on the todo list
  12. It is somewhere Some window is subscribed to quotes for F. An open chart maybe?
  13. Yes. Just use 0 as a coordinate. You're getting errors 'cuz you're putting in "CandleNumber 0". That's wrong syntax for C#. SetLine(2, Red, 0, Line2, CandleNumber, Line2, 2, null); This will draw a line from left side of the chart to current candle.
  14. Well the leftmost candle is 0. If you draw from candle 0, it will just go to the left side of the chart, no matter what period you're showing.
  15. 1. CandleNumber+5 will work. Not "CandleNumber 5" . And yes you can just do +whatever, it will just go far to the right. 2. In order to start at a particular candle, you have to remember the number of the candle. Since the paintbar evaluates looking at all candles, from the earliest to the latest, in the code you can see whether the candle being looked at is at start of session, and if it is, remember its number to be used later.
  16. This is one that will draw the line from the high of the day with the highest turnover volume (that is, volume times price) in the last 300 days. It will also show you what the line's ratio is of the volume turnover to the average volume turnover for the last 30 days. Note that since there is only one line being drawn, it just has an ID of 1. Most of the code is housekeeping, the important code is at the top. .fctbNone{ color:#000000; } .fctbStyle2{ color:#008000; } .fctbStyle4{ color:#0000ff; } .fctbStyle3{ color:#000000; } .fctbStyle2Style3{ color:#000000; } .fctbStyle2Style4{ color:#0000ff; } .fctbStyle1{ color:#800000; } .fctbStyle6{ color:#808080; }StateFIFOQueue Volumes; // to find the SMA of $volumes double MaxRatio = 0; public void MainCalculation() { Volumes.Add(BarVolume*Close); // maintain the SMA if (Timestamp<DateTime.Now.Date.AddDays(-300)) // look only at the last 300 days return; if (Volumes.Average>0 && BarVolume*Close/Volumes.Average > MaxRatio) // if this is the highest volume ratio reset line { MaxRatio = BarVolume*Close/Volumes.Average; var Col = GetNamedColor("Line", SysColor.MainIndicator1); SetLine(1, Col, CandleNumber, High, CandleNumber+100000, High, 1, Convert.ToString(Math.Round(MaxRatio,2)), LineTextPosition.RightAbove, 1); } } /// <summary> /// Is called at start of paintbar calculation, should be used to initialize anything needed for the paintbar /// </summary> private void PaintbarInitialize() { Volumes = new StateFIFOQueue(30); MaxRatio = 0; } /// <summary> /// Holds paintbar state - fill with variables needed to be preserved for next paintbar calc /// </summary> private struct PaintbarState { } /// <summary> /// Holds current PB state - use to calc PB, changes to it carry over to next PB calc /// </summary> private PaintbarState CurrentState; /// <summary> /// Holds saved PB state - internal /// </summary> private PaintbarState SavedState; /// <summary> /// Is called at start of paintbar calculation, should be used to clear the paintbar state /// </summary> private void PaintbarClearState() { CurrentState = new PaintbarState(); Volumes.Clear(); } /// <summary> /// Saves paintbar state (called internally). /// </summary> private void PaintbarSaveState() { SavedState = CurrentState; Volumes.SaveState(); } /// <summary> /// Restores paintbar state (called internally). /// </summary> private void PaintbarRestoreState() { CurrentState = SavedState; Volumes.RestoreState(); }
  17. The ID is the unique ID of the line. What that means is that each SetLine that you are showing in your code is setting the same line - that is, it is re-setting the line to the new values. Because the ID of the line does not change. For example, If you have a line which starts at a particular candle number, AND you know that it's the only line that will start at that candlenumber AND you know that the line, once started, will stay at that candle number, then it would be logical to use the candle number as the line's ID. What your code above does is, for each day of the last few days, it draws a blue line (the last SetLine in your code) from the last candle of the day to the 15th candle prior to that. At 4445 - because that is the value have in the last SetLine.
  18. I will see about making something like that. By "normal average volume" you mean something like SMA30?
  19. Ok when you say "exceptionally high volume relative to other days" - what would it mean exactly. How would you describe determining this. I don't remember the code I gave you. It is pretty simple to determine the highest volume candle of the day. But that's probably not what you're after?
  20. We have streaming API. https://docs.google.com/document/d/15IvYQEYzSeftTSEdVhsptAguM0fGm9mTJFSDDAK7zWE/ email support@medvedtrader.com and Jerry will send you a tester app for it including C# source.
  21. It's literally two clicks of the mouse Or a click and a keypress.
  22. When you're connected to MT from outside through the streaming API, this will send information from the current window to the API.
  23. LogString is there for debugging. Once you debugged, take it out
  24. By popular request (well, a few people asked)... * added ability to draw "bands" in paintbars. You just do SetYValue(value1, value2) for upper/lower values of the band, and do SetColor(0,..) SetColor(1,...) for the band borders and SetColor(2,...) for the band fill if you want one. * added ability to draw lines on the chart from paintbar (this is not in beta yet, if you want to try it, email me. But will be in next beta). * the lines function will also allow you to put text on the chart from a paintbar. Just draw a 0-width line with text on it. Here is an example paintbar that draws High and Low lines on the chart every N minutes: .fctbNone{ color:#000000; } .fctbStyle5{ color:#0000ff; } .fctbStyle3{ color:#ff00ff; } .fctbStyle2{ color:#008000; } .fctbStyle1{ color:#a52a2a; }double PeriodHigh; double PeriodLow; double PrevPeriod; int PeriodStart; public void MainCalculation() { if (CandleNumber == 0) // just starting { PrevPeriod = -1; } var MinFromSessionStart = (Timestamp-TradingDay.SessionStart).Ticks / TimeSpan.TicksPerMinute; if (MinFromSessionStart<0) return; DefinePaintbarParameter("Period", "Minutes", true, 5, 1000, 1, 30); var min = Convert.ToInt32(GetPaintbarParameter("Period")); var Period = MinFromSessionStart/min; if (Period!=PrevPeriod) { PeriodHigh = High; PeriodLow = Low; PeriodStart = CandleNumber; PrevPeriod = Period; } PeriodHigh = Math.Max(PeriodHigh, High); PeriodLow = Math.Min(PeriodLow, Low); Color HColor = GetNamedColor("High", SysColor.MainIndicator1); SetLine(TradingDay.DayNumber*1000+Period, HColor, PeriodStart, PeriodHigh, CandleNumber + 1, PeriodHigh, 1, "H", LineTextPosition.RightAbove, 0.8); Color LColor = GetNamedColor("Low", SysColor.MainIndicator2); SetLine(TradingDay.DayNumber*2000+Period, LColor, PeriodStart, PeriodLow, CandleNumber + 1, PeriodLow, 1, "L", LineTextPosition.RightBelow, 0.8); }
×
×
  • Create New...