3acor Posted January 21, 2021 Report Share Posted January 21, 2021 Hey, If the Paintbar code include values such as the Moving Average, will the indicators value be considered at the time of the data or whatever they are now. For example: It is Jan 04, 2021 and the SMA value is 100. Today Jan 21, 2021; looking at the SMA value on Jan04 it would show for example 105. So will the SMA value in the Paintbar on Jan04,2021 use 100 or 105? Thanks Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted January 22, 2021 Report Share Posted January 22, 2021 for indicators the paintbar references the values on that bar, so it will change for every bar Quote Link to comment Share on other sites More sharing options...
3acor Posted January 27, 2021 Author Report Share Posted January 27, 2021 So If I am taking the Bollinger Bands value it will take whatever value was on that bar and not whatever the Bollinger Bands value is right now, correct? Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted January 27, 2021 Report Share Posted January 27, 2021 correct Quote Link to comment Share on other sites More sharing options...
3acor Posted January 27, 2021 Author Report Share Posted January 27, 2021 So I am putting a paintbar on for example a 120min timeframe, if I change the timeframe and switchback to the 120min TF, the paintbar is gone. Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted January 27, 2021 Report Share Posted January 27, 2021 I think you are talking about frequency, not timeframe and really don't understand what "gone" means in your example. When initially computing the timeframe, MT calls your code for the timeframe once for every candle on the chart. Then as new quotes come in, it will call it again just for the updated candles. If you change frequency on the chart, the chart will need to be recomputed, so the entire process is done again. Quote Link to comment Share on other sites More sharing options...
3acor Posted January 27, 2021 Author Report Share Posted January 27, 2021 I meant when applying the paintbar to previous data. I apply on 120min frequency, the paintbar shows on the candles. I then change frequency and go back again to 120min frequency and the paintbar won't show anymore. Unless maybe something wrong in the code Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted January 27, 2021 Report Share Posted January 27, 2021 That should not happen. Please send us the PB. Quote Link to comment Share on other sites More sharing options...
3acor Posted January 27, 2021 Author Report Share Posted January 27, 2021 (edited) if (Last > Prev_Low && Last < Prev_High && Last > EMA20) { SetScanResult(@"bullish"); SetColor("blue", Color.Blue); } Last,Prev_High,Prev_Low are Variables based on Horizontal Line indicator. Apply it to TSLA on the 120min Frequency Edited January 27, 2021 by 3acor Quote Link to comment Share on other sites More sharing options...
3acor Posted January 27, 2021 Author Report Share Posted January 27, 2021 (edited) Maybe I had an Else If statement that was returning the same results that was bugging it? Or maybe it is me who is doing something wrong Anyway looks like it is fine now Edited January 27, 2021 by 3acor Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted January 28, 2021 Report Share Posted January 28, 2021 Yeah I really don't see anything weird in that code. When you apply it now it works as it should? Quote Link to comment Share on other sites More sharing options...
3acor Posted January 28, 2021 Author Report Share Posted January 28, 2021 Yea it does but I changed it anyway. If using Horizontal Line with Value "Last", it will consider all the price levels that happened during the trading session since all these prices were "Last", right? Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted January 29, 2021 Report Share Posted January 29, 2021 Um no For that, you can just use the Close of the current candle being considered no? Quote Link to comment Share on other sites More sharing options...
3acor Posted January 29, 2021 Author Report Share Posted January 29, 2021 So what is Last in Horizontal Line, same as SymbolData.Last? I could use High and Low instead but I would like to use the High/Low for the current timestamp such as in the post below. But I am not sure how to do it if I want to apply it for multiple trading sessions for backtesting. Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted January 30, 2021 Report Share Posted January 30, 2021 The Last, High, Low, Close come from the "Chart" - that is, current chart. Not from current-chart-up-to-the-candle-being-processed... Prev Close, Prev Open etc. also come from the chart but they obviously don't change as new data gets added. If you wanted to use High/Low for current timestamp, you'd keep track of it yourself. It is easy enough, you just have to define the DayHigh/DayLow and DayNum outside the function, zero it out when the DayNum is not equal to TradingDay.DayNumber, adjust the DayHigh and DayLow to the new candle's high and low, and set the DayNum to TradingDay.DayNumber. double DayHigh = 0; double DayLow = 0; int DayNum = -1; public void MainCalculation() { if (DayNum != TradingDay.DayNumber) { DayNum = TradingDay.DayNumber; DayHigh = High; DayLow = Low; } DayHigh = Math.Max(DayHigh, High); DayLow = Math.Max(DayLow, Low); } If you want to restrict it to only regular session, you'd have to also condition it on other TradingDay. properties. Like TradingDay.IsPreMarket or something. 1 Quote Link to comment Share on other sites More sharing options...
3acor Posted January 30, 2021 Author Report Share Posted January 30, 2021 Thanks a lot will do that. I appreciate it Quote Link to comment Share on other sites More sharing options...
3acor Posted January 30, 2021 Author Report Share Posted January 30, 2021 (edited) I am not sure why it is not working. This is my code applied to NNDM on Jan25 on the 120min frequency at 7am premarket //PM_Low variable is Horizontal Line, Low, including premarket //Prev_High variable is Horizontal Line, PrevHigh, Reg. sessions only double PM_Low_now = 0; int DayNum = -1; public void MainCalculation() { if (DayNum != TradingDay.DayNumber) { DayNum = TradingDay.DayNumber; PM_Low_now = PM_Low; } else { PM_Low_now = Math.Min(PM_Low_now, PM_Low); } if (PM_Low_now > 0.98 * Prev_High) { SetColor("green", Color.Green); } } Edited January 30, 2021 by 3acor Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted January 31, 2021 Report Share Posted January 31, 2021 Instead of PM_Low - just use Low. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.