Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Help with simple Code / Request
Updated July 10, 2021
trending_up
2,495 views
thumb_up
2 thanks given
group
2 followers
forum
6 posts
attach_file
0 attachments
Help with simple Code / Request
July 9th, 2021, 01:35 PM
Linz, Upper Austria
Experience: Intermediate
Platform: NT8
Trading: Currency Futures
Posts: 16 since Sep 2020
Thanks Given: 22
Thanks Received: 10
Hello Guys!
I'm pretty new to Multicharts and Powerlanguage and i tried to create a simple indicator that should give me a visual signal when a condition is met.
Condition:
When Price (instead of price i use close of 1 minute Candle) is greater than last weeks high => color the 1 minute Candles.
Code
Input:
MA_Period(34);
Vars:
MA_Value(0),
TF_Price(2), //Price data of Subchart#2, shall simulate the price
TF_Daily(3), //Price data of Subchart#2, TF D1
TF_Weekly(4), //Price data of Subchart#2, TF W1
counter(0),
beginValue(1),
endValue(1440);
condition1 = High of data(TF_Price) > High of data(TF_Weekly) ;
condition2 = Close of data(TF_Price) < Low of data(TF_Weekly) ;
If condition1 Then PlotPaintBar(High, Low, Open, Close, "", Yellow) of data(TF_Price) ;
If condition2 Then PlotPaintBar(High, Low, Open, Close, "", Magenta) of data(TF_Price);
The problem is, that the indicator paints the bars 1 Day too late as seen in the screenshots .
The price level where the arrow points to, is the last weeks high.
Seems that it recognizes or checks the condition too late...
I tried it now for hours, but i don't get any further... any ideas?
Thanks in advance!
https://prnt.sc/19s63rv
https://prnt.sc/19s68w8
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
July 10th, 2021, 05:21 AM
Posts: 19 since Jan 2013
Thanks Given: 0
Thanks Received: 9
Hi,
If your requirement is to paint bar when the current price is above or below the current week high/low then the following changes should work
Code
condition1 = High of data(TF_Price) >= High of data(TF_Weekly) ;
condition2 = Close of data(TF_Price) <= Low of data(TF_Weekly) ;
Regards
Vivek
July 10th, 2021, 07:13 AM
Linz, Upper Austria
Experience: Intermediate
Platform: NT8
Trading: Currency Futures
Posts: 16 since Sep 2020
Thanks Given: 22
Thanks Received: 10
Anka Software
Hi,
If your requirement is to paint bar when the current price is above or below the current week high/low then the following changes should work
Code
condition1 = High of data(TF_Price) >= High of data(TF_Weekly) ;
condition2 = Close of data(TF_Price) <= Low of data(TF_Weekly) ;
Regards
Vivek
Thanks for your answer!
I tried it, but it still doesn't recognize the break of last weeks High during the first day of the new week .
It's strange that it ignores the first day...
July 10th, 2021, 07:23 AM
Posts: 19 since Jan 2013
Thanks Given: 0
Thanks Received: 9
For last weeks high the code needs to be
Code
condition1 = High of data(TF_Price) >= High[1] of data(TF_Weekly) ;
condition2 = Close of data(TF_Price) <= Low[1] of data(TF_Weekly) ;
July 10th, 2021, 08:40 AM
Linz, Upper Austria
Experience: Intermediate
Platform: NT8
Trading: Currency Futures
Posts: 16 since Sep 2020
Thanks Given: 22
Thanks Received: 10
Anka Software
For last weeks high the code needs to be
Code
condition1 = High of data(TF_Price) >= High[1] of data(TF_Weekly) ;
condition2 = Close of data(TF_Price) <= Low[1] of data(TF_Weekly) ;
Thanks, i tried that already, but this messes the chart more up than before:
With >= High[1] AND <= Low[1]
https://prnt.sc/19zovd4
With >= High of data AND <= Low of data
https://prnt.sc/19zp77v
July 10th, 2021, 09:14 AM
Posts: 19 since Jan 2013
Thanks Given: 0
Thanks Received: 9
Also what is the idea of using High of Data(TFPRice) in condition1 while close is used in condition 2?
July 10th, 2021, 11:01 AM
Linz, Upper Austria
Experience: Intermediate
Platform: NT8
Trading: Currency Futures
Posts: 16 since Sep 2020
Thanks Given: 22
Thanks Received: 10
Anka Software
Also what is the idea of using High of Data(TFPRice) in condition1 while close is used in condition 2?
Was just an error (replaced it with ("Low of Data(TFPrice) "), but didn't do any changes for the example i posted :/
Guys, i think i got it... but i don't know why...
Code
condition1 = Close >= High of data(TF_Weekly) ;
condition2 = Low <= Low of data(TF_Weekly) ;
The key was to repace "High of data(TFPrice) " with "High " or "Close ".
But i thought "High of data(TFPrice) gives me the exact same value as Close...
Do you know my mistake in thinking?
Last Updated on July 10, 2021