Trading Articles
Article Categories
Article Tools
Help with simple Code / Request
Updated July 10, 2021
trending_up
2,284 views
thumb_up
2 thanks given
group
2 followers
forum
6 posts
attach_file
0 attachments
Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
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 and simple.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Help with simple Code / Request
(login for full post details)
#1 (permalink )
Linz, Upper Austria
Experience: Intermediate
Platform: NT8
Trading: Currency Futures
Posts: 16 since Sep 2020
Thanks: 22 given,
10
received
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 futures io?
Best Threads (Most Thanked) in the last 7 days on futures io
(login for full post details)
#2 (permalink )
Posts: 19 since Jan 2013
Thanks: 0 given,
9
received
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
The following user says Thank You to Anka Software for this post:
(login for full post details)
#3 (permalink )
Linz, Upper Austria
Experience: Intermediate
Platform: NT8
Trading: Currency Futures
Posts: 16 since Sep 2020
Thanks: 22 given,
10
received
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...
(login for full post details)
#4 (permalink )
Posts: 19 since Jan 2013
Thanks: 0 given,
9
received
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) ;
The following user says Thank You to Anka Software for this post:
(login for full post details)
#5 (permalink )
Linz, Upper Austria
Experience: Intermediate
Platform: NT8
Trading: Currency Futures
Posts: 16 since Sep 2020
Thanks: 22 given,
10
received
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
(login for full post details)
#6 (permalink )
Posts: 19 since Jan 2013
Thanks: 0 given,
9
received
Also what is the idea of using High of Data(TFPRice) in condition1 while close is used in condition 2?
(login for full post details)
#7 (permalink )
Linz, Upper Austria
Experience: Intermediate
Platform: NT8
Trading: Currency Futures
Posts: 16 since Sep 2020
Thanks: 22 given,
10
received
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
Ongoing