NexusFi: Find Your Edge


Home Menu

 





Store value in variable when emas crossover easy language


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,217 views
    2. thumb_up 0 thanks given
    3. group 4 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

Store value in variable when emas crossover easy language

  #1 (permalink)
Carlera
Colombia
 
Posts: 13 since Mar 2021
Thanks Given: 1
Thanks Received: 1

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

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
NexusFi Journal Challenge - May 2024
Feedback and Announcements
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
43 thanks
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #2 (permalink)
Kolnidrei
Lyon/France
 
Posts: 23 since Aug 2012
Thanks Given: 1
Thanks Received: 14

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;

Reply With Quote
  #3 (permalink)
 TraderDoc2 
Plainview
 
Experience: Intermediate
Platform: TradeStation
Broker: TradeStation
Trading: Futures
Posts: 34 since Mar 2012
Thanks Given: 1
Thanks Received: 21


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);

Follow me on Twitter Reply With Quote
  #4 (permalink)
Kolnidrei
Lyon/France
 
Posts: 23 since Aug 2012
Thanks Given: 1
Thanks Received: 14

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);

Reply With Quote
  #5 (permalink)
Carlera
Colombia
 
Posts: 13 since Mar 2021
Thanks Given: 1
Thanks Received: 1

Thanks traders for your support it was helpful for me.

Reply With Quote




Last Updated on December 24, 2021


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts