Trading Articles
Article Categories
Article Tools
Store value in variable when emas crossover easy language
Updated December 24, 2021
trending_up
3,994 views
thumb_up
0 thanks given
group
4 followers
forum
4 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)
Store value in variable when emas crossover easy language
(login for full post details)
#1 (permalink )
Colombia
Posts: 10 since Mar 2021
Thanks: 1 given,
1
received
Hi traders,
I need your help to store a value when a condition is true and use it value during the code
For example
1. When crossover Ema 200 and Ma89 then
2. Store the high Value in a variable to use it in any moment the code.
3. Draw a horizontal line from store high value to the next crossover.,
Thanks for your help.
Carlos
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 )
Lyon/France
Posts: 23 since Aug 2012
Thanks: 1 given,
14
received
hi
Code
Inputs:
Price(Close),
PeriodShort(89),
PeriodLong(200),
width(2);
vars:
w(0),plotvalue(0),color(white);
value1 = Average(Price,PeriodShort);
value2 = XAverage(Price,PeriodLong);
condition1 = value1 crosses above value2;
condition2 = value1 crosses below value2;
if condition1 then begin
plotvalue = L;
color = red;
end;
if condition2 then begin
plotvalue = H;
color = green;
end;
if plotvalue <> 0 then begin
if plotvalue <> plotvalue[1] then w = 0 else w = width;
Plot(plotvalue, "cross", color, default, w);
end;
(login for full post details)
#3 (permalink )
Plainview
Experience: Intermediate
Platform: TradeStation
Broker: TradeStation
Trading: Futures
Posts: 19 since Mar 2012
Thanks: 1 given,
15
received
Nice code.
For some reason it originally looked like the last if statement had "//" in front of it.
I prefer to slightly alter the last 2 lines of code as follows:
Code
if plotvalue <> plotvalue[1] then w = 0 else w = width;
Plot1(plotvalue, "cross", color, default, w);
(login for full post details)
#4 (permalink )
Lyon/France
Posts: 23 since Aug 2012
Thanks: 1 given,
14
received
sure, I added the 2 lines because this line is not mandatory ,
it only disables the ennoying vertical lines of connection between the different levels of the horizontal lines
but i forgot to add the drawings for the moving averages;
so one should add the following lines if one wishes to see them
Code
Plot2(value1, "MA", green, default, 2);
Plot3(value2, "EMA", red, default, 2);
(login for full post details)
#5 (permalink )
Colombia
Posts: 10 since Mar 2021
Thanks: 1 given,
1
received
Thanks traders for your support it was helpful for me.
Last Updated on December 24, 2021
Ongoing