Jump to content
Medved Trader Forums

Mike Medved

Administrators
  • Posts

    1,543
  • Joined

  • Last visited

  • Days Won

    124

Posts posted by Mike Medved

  1. 3 hours ago, Thebattlefront said:

    Do you have any idea how I can change the value of a cell in a CurrentState array, by referencing itself and adding another value to it? Or do i have to switch back to individual currentstate variables and abandon the idea of keeping the data stored in a single array altogether?

    I remember before you showed me how to use the StateFIFOQueue to add data to a set, and then perform operations on that set (like getting the average) to get the important values i can use. So i know there are alternatives to using just a bunch of individual currentstate variables to hold the values. But I just don't know what those alternatives are.

    Yes for what you want (I think) it is best just to use StateFIFOQueue(20) for each of the arrays. You still have to manually save and restore state for each like you're already doing for the one StateFIFOQueue that you have. And you can only store Doubles of course...

  2. 3 hours ago, Thebattlefront said:

    Thanks Mike. Yeah i just want these arrays to store the data from the trades. Much like using individual currentstate variables and labelling them each CurrentState.m_dS1AtrPerBar, CurrentState.m_dS2AtrPerBar, CurrentState.m_dS3AtrPerBar, etc. but using just a single array for all to make it cleaner.

    Can i ask , what did you change? My results still look like this:

    Edit: The idea here is that each letter represents a different candlestick pattern. And what im doing is tracking the profit / number of trades / winrate of each candlestick, for each stock on my watchlist. That's what all the zeroes and the 1, 2, 3, 4, 5 numbers are in each column. They -should- be tracking the profit, tradecount, etc but i just get a bunch of zeroes.

     

     

    3f3c82b13fcd0aca4ef679788bff3844.png

    Look in the save and restore functions. Instead of copying just the structs, I specifically made it copy the arrays...

  3. Ok, I just realized something... I should mention it in help file.

    A struct that has arrays in it is a mutable struct. Which means that if you just do struct1=struct2, the arrays are not copied. They are there by reference, so both structs would be pointing to the same array.

    Let me figure out how to change your code the most elegantly so that this doesn't happen (and that the efficiency does not suffer).

     

  4. I haven't looked yet but here is a detail that may explain what you're seeing:

    MT's paintbars are a "state machine". There is a "state", and the new candle changes the "state". The thing is, this state-changing for the new candle may not be called only once per candle. It is for "past" candles, but for the new, latest candle, the "state" is restored to the condition right BEFORE the new candle - then the state-changing code is called for the new, latest candle. Hope this makes sense?

  5. 1 hour ago, ahujat said:

    Hi Mike

    Will this work across system reboot and MT restart or even system crash/hang (where I have to forcibly reboot the system without closing MT)?

    I also need something like this, high/low for a particular time range from the previous trading session.

    If you backfill (so that the gap is filled) sure it will work.

    And yes, that code works for every day. It only draws the line for the last day though. You can change it so it draws the line for every day.

  6. What value do you want to average? The "Change from Open" basically? Over how many candles?

    Average(20, Close-SymbolData.Open) - would do it for the last 20 candles 
    BUT it would only show correctly for the last day (since SymbolData.Open 
    is for current session only)
    
    If you want it correct for every day going back, the code needs to figure 
    out what the Open for each day is, so would be a bit more elaborate.
    
  7. First of all, am happy someone found trade beads useful. We have a lot of nifty features that I thought would be useful to traders - such as the trade beads, of option interest trees, or max pain box, that I don't get much feedback on, so I think no one uses them.

    There is already a clear beads shortcut. Look at keyboard shortcuts page in settings and do a search (the field uptop) for "bead"....

    The other two - will do although am not sure how useful the NumBeads variable will be. Also - if you have beads 1 2 and 5 turned on, the NumBeads will be 3.

     

  8. On 11/16/2023 at 10:26 AM, ocram1980 said:

    Thanks. I will watch it closely and try to find an example. Currently I got no problems. Confusing.

    Let me start with a similar question: I am already running the scanner for 1.5 hours. But TSLA has still not filled the historic data? I see this every day. Always with TSLA. What is going on with this stock?

    Marco.

    Not sure. But you can manually backfill. Just right click on TSLA and choose the option to backfill.

  9. I checked, and the MA is calculated on whatever shows, if you show premarket, MA is calculated using premarket values.

     

    Of course, as soon as the market starts, the volume jumps, becomes way over MA and you would get an alert.

     

    What you see (first opened the chart only with bars within the regular session. And after a few seconds he added the MA) is if you don't have premarket data to begin with, and get it from a backfill. But once you do get the backfilled data, next time you open the chart, it will be there.

    Also - alerts in MT only happen on "latest" data - that is, if you have a chart for a day and the alert condition is satisfied let's say 20 minutes ago, it won't trigger. It is only triggered on the last - rightmost - candle.

  10. The scan, when it runs, does not run only on the very last candle. It runs on every candle first (then, as  the real time data comes in, it keeps running on the last and then new candles).

    So something like this will work

    int lastdaynum  = -1;
    double CloseAt7 = 0;
    
    public void MainCalculation()
    {
        if (TradingDay.DayNumber != lastdaynum)
        {
            CloseAt7   = 0;
            lastdaynum = TradingDay.DayNumber;
        }
        if (CloseAt7 == 0 && Timestamp >= TradingDay.SessionStart.AddHours(3)) // session starts at 4am, so add 3 to get 7am
        {
            CloseAt7 = Close;
        }
        if (CloseAt7 == 0)
            SetScanResult(0);
        else
            SetScanResult(Close-CloseAt7);
    }
  11. Let's say your scan result (that you pass in SetScanResult) is Double.

    Just have a Double variable set in the scan (outside the functions). Call it TriggeredValue. At start, set it to 0 (or some "invalid" value).

    When the condition is satisfied, set it to whatever you're passing to SetScanResult. And before you check for the condition, just say if TriggeredValue is not 0, SetScanResult to it and don't even continue checking for the condition.

×
×
  • Create New...