MultiCharts Automated trading

Discussion in 'Automated Trading' started by MarkBrown, Oct 9, 2022.

  1. In general, with MultiCharts' intrabar order generation (IOG), while backtesting with historical data, sometimes entry and exit imprecisions (bugs) are known to occur, as a function of OHLC gross resolution. Yet, in this context the same code will correctly execute while forward-testing with realtime data.

    Specifically, while backtesting historical data with range bars, perhaps MultiCharts' 'bar magnifier' function is not available -- which would mean you can't rely on tick resolution while backtesting range bars -- only OHLC. In this case, I believe a 'down' range bar would be assumed to go from its O to H to L to C with no intermediate granularity. (Nothwithstanding, realtime data + IOG would work correctly with range bars.)

    Since range bars are similar to Point bars and Renko bars,
    reference:
    https://www.multicharts.com/trading...on,_Bar_Magnifier_on_Non-Standard_Chart_Types
     
    Last edited: Dec 31, 2022
    #101     Dec 31, 2022
  2. MarkBrown

    MarkBrown

    I have reported this issue as a bug on the MC developer forum and I see it is under review.

    Since text and other object will plot both historically and in real time exactly where I program them to be. I have to believe that there is a a bug with systems only.

    One reason I use Kase range bars is they are the only range bar to not add filler or fake data, what you see is what you get. Every time I load a chart I can rely on it always being the same. If I could send trade info from the indicator directly to the broker I would forget about this database bug with systems.

    But I'm pursuing full automating trading as MC promised their platform is capable of. I know they can do it I hired Globa the owner of MC to program a TT interface to Tradestation decades ago before there was a MC.
     
    #102     Dec 31, 2022
  3. The bad news is that this is how MultiCharts is currently designed w.r.t. Kase bars and backtesting.

    Notwithstanding, the good news is that your strategy will forward-test (and auto-trade real money) correctly / precisely on realtime data.
     
    #103     Dec 31, 2022
    MarkBrown likes this.
  4. MarkBrown

    MarkBrown

    just discovered something just now while testing

    if two bars occur withing the same second MC treats it as one bar - to slow it down and calculate properly i used a big wrapper.


    //code below for big wrapper

    if time_s>time_s[1]then begin

    code here

    end;
     
    #104     Dec 31, 2022
    Mononymous likes this.
  5. MarkBrown

    MarkBrown

    It seems no matter what it is impossible for MC to execute an order intra-bar though they continually claim it can be done. One day either I will understand or they will fix it LOL.

    So I have decided to waste some more money and make a chart with two data sets on it for two charts both of the ES - one will have the system on it and the other will be the same system on auto trade. that way i can audit the difference between actual order entry's and historical order entries.

    I don't think TradeStation can achieve this either but don't know for sure.

    Code is blow picture


    [​IMG]

    Response from MC support -


    Hello Mark,

    That’s expected behaviour for your script if those are backtesting results on your screenshot. Please see how signals are calculated depending on the environment here.

    The pink arrows are plotted by your script without the = false, so their values might change with new ticks and not correspond to the variable’s first value.

    When calculated on real-time data, your signal sends orders within a bar and corresponds to the arrow drawing. Please see the screenshot here.

    Here’s the full script used for testing: = false

    = true

    var:intrabarpersist dnband2(0),intrabarpersist upband2(0);

    dnband2 = Lowest(close, 10); {the lowest lower band "outside lowest"} upband2 = Highest(close, 10);{the highest high band "outside highest"}

    if c <= dnband2 and c1 >= dnband2 then begin

    sellshort next bar market;



    // code above will only sell on close of the bar no matter how you code it.



    //yet code below will put arrow where instructed by the code above



    value1 = Arw_New_s(Date, Time_s, dnband2, true); //plots the sell arrow at the sell stop price

    arw_setsize(value1, 0);
    arw_setstyle(value1, 3);
    arw_setcolor(value1, magenta);

    end;

    if c >= upband2 and c1 <= upband2 then begin
    buy next bar market;



    //code above will on buy on close of bar no matter how you code it.



    //yet code below will put arrow where instructed by the code above



    value2 = Arw_New_s(Date, Time_s, upband2, false); //plots the sell arrow at the sell stop price
    arw_setsize(value2, 0);
    arw_setstyle(value2, 3);
    arw_setcolor(value2, green);

    end;

    supposed proof that it does work from MC support. ;(

    [​IMG]
     
    #105     Jan 6, 2023
  6. In the context of standard chart types, such as candlesticks, MultiCharts correctly performs intrabar order generation (IOG) with historical and also with realtime data. My PowerLanguage systems on standard chart types correctly perform IOG.

    In the context of non-standard chart types, such as your Kase bars, MultiCharts openly published five years ago that the IOG feature is only available for real time data, but not for historical data.

    The reason is: for historical data on non-standard chart types, MultiCharts transforms tick-resolution to OHLC. This is why your backtest shows trades only at C's.

    Have you forward-tested your ("upband2") system with real time data? If / when you do, you'll see correct IOG.
     
    #106     Jan 7, 2023
    MarkBrown likes this.
  7. Bad_Badness

    Bad_Badness

    Hi Mark,

    Just FYI: I think the IOG bugs are a bit deeper. I encountered a bug with the SetStopLoss_pt(N) when IOG is off*.

    Essentially it double evaluates. Once when the condition is hit and another time at bar close.
    So this ended up actually reversing the position. Fortunately, it was on paper at IB. But heck if I am going to try it live.

    The reason I mention it, is that it appears that the IOG logic for evaluation execution has additional bugs. So, this casts doubt on a surgical fix, and more worry that it is a fundamental issue in the IOG code. I.e. if it is the latter, it will be fixed in a more major release update, versus a xx.xx.01 release.

    * I was going through doing performance tuning.
     
    #107     Jan 7, 2023
    MarkBrown likes this.
  8. MarkBrown

    MarkBrown

    just to make it real simple the code below say we buy at a fixed price which would you pick below 1-3?


    /////////// test code for real time intra-bar entry

    [ IntrabarOrderGeneration = true ]

    input: band ( some fixed price );
    1. if c > band then begin buy this bar on c ; end ;
    2. if c > band then begin buy next bar on c ; end ;
    3. if c > band then begin buy next bar at market ; end ;

    setprofittarget_pt(profit amount);
    setstoploss_pt(stop loss ampunt);
     
    #108     Jan 7, 2023
  9. VSTscalper

    VSTscalper

    Mark,

    I have tried several Charting_Trading programs over the years - and in my opinion - Multicharts is one of the better ones. I do have some issues with it - mainly about Auto Trading - but overall - I like it the best. For me though - all I really care about is making my Net Daily Goal (NDG) - within a 2 Hour Trading period. If I hit my NDG - in 30 minutes - an Hour or however long it takes - but no more than 2 Hours - I am DONE for the day.

    Notice the Entries on the trades in the picture below. The previous bar Closed - but the Entry in each case had a much better Price than the Close of the previous bar. This Code was designed to take Multiple trades per Bar - and depending on how it is setup - it will try to get the Same Entry Price and Exits. This picture shows it taking a One Contract trade - up to 5 times. Notice on the MES - bottom chart - there is one Candle where it only took 2 trades.

    If this Code is setup to trade Multiple Contracts with each Entry instead of just One Contract - you could see different Entry Prices.

    These are both 25 Tick Range Bars. I have tried just about every type of Bar over the years - and I much prefer Range Bars - which are called "Point" in Multicharts.

    By the way - in that first picture you added - you said - "where I wanted to sell" - for me - I would have wanted to Short - Above the Close of the Previous Bar - as shown in the Pictures below. Which would give a much Higher Profit.


    .ES_MES_01-07-23_1.png
     
    #109     Jan 7, 2023
    SimpleMeLike and MarkBrown like this.
  10. MarkBrown

    MarkBrown

    • MC is the best available we agree.
    • I stop trading also at NDG cause they say pigs get slaughtered - besides I'm retired LOL.
    • Thank you very much for you post - I understand completely what your saying.
    • Currently I am using 20 "Point" bars in MC.
    You have given me something to think about "better entries" and for that I am very appreciative.

    Developing the model on live data and live account with auto trade enabled is the only way if I'm to get the model to actually auto trade. Back to trial and error.

    IOG - having a hard time figuring out how this converts things like " buy next bar on c " to buy next tick" < which is what they say it will convert to.
     
    #110     Jan 8, 2023
    SimpleMeLike likes this.