NexusFi: Find Your Edge


Home Menu

 





About performing a calculation only once(MultiCharts)


Discussion in EasyLanguage Programming

Updated
    1. trending_up 905 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 7 posts
    2. attach_file 1 attachments




 
Search this Thread

About performing a calculation only once(MultiCharts)

  #1 (permalink)
LW11041104
Tokyo,Sapporo
 
Posts: 74 since Jan 2023
Thanks Given: 2
Thanks Received: 3

Is it possible to make it so that the alerts and calculations are done only once, as they seem to be done every minute?


 
Code
var: maxHighday(high),maxhigh(high);


if date[0] <> date[1] then

begin

       maxHighday = maxhigh   ;           
       maxhigh = high;
      
       end

else begin 
     if high>maxhigh  then
            
            maxhigh =high;
            
            end;   
        
if maxhigh>maxHighday then 
       begin
         
       plot1("high");
       alert("high");
       print(symbol,date,time,maxHighday,maxhigh  );

       end
 
else 
       NoPlot(1);

Attached Thumbnails
Click image for larger version

Name:	2023-05-23 Execution Result.png
Views:	103
Size:	73.0 KB
ID:	332177  
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
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
33 thanks
Just another trading journal: PA, Wyckoff & Trends
28 thanks
Tao te Trade: way of the WLD
23 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

LW11041104,

your code line "if maxhigh>maxHighday then" remains true, because you do not update the value stored in maxHighday whenever maxhigh is greater than that.
You are correctly updating the value stored in maxhigh whenever high>maxhigh, but you might have missed doing the same for maxHighday when maxhigh>maxHighday.

Adding maxHighday = maxhigh; directly in the line above plot1("high"); should ensure the alert is only fired when there is a new high, but the plot1 would also only appear in this situation.

Regards,

ABCTG


LW11041104 View Post
Is it possible to make it so that the alerts and calculations are done only once, as they seem to be done every minute?


 
Code
var: maxHighday(high),maxhigh(high);


if date[0] <> date[1] then

begin

       maxHighday = maxhigh   ;           
       maxhigh = high;
      
       end

else begin 
     if high>maxhigh  then
            
            maxhigh =high;
            
            end;   
        
if maxhigh>maxHighday then 
       begin
         
       plot1("high");
       alert("high");
       print(symbol,date,time,maxHighday,maxhigh  );

       end
 
else 
       NoPlot(1);


Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
LW11041104
Tokyo,Sapporo
 
Posts: 74 since Jan 2023
Thanks Given: 2
Thanks Received: 3


Thank you for your response.

Yes, the alert was output each time the day's high was greater than the previous day's high and the intraday high was updated.

However, I would like the alert to go off only once when the day's high becomes greater than the previous day's high.
Therefore, I do not want an alert to be sounded each time the intraday high is subsequently renewed.

Reply With Quote
  #4 (permalink)
LW11041104
Tokyo,Sapporo
 
Posts: 74 since Jan 2023
Thanks Given: 2
Thanks Received: 3


ABCTG View Post
LW11041104,

your code line "if maxhigh>maxHighday then" remains true, because you do not update the value stored in maxHighday whenever maxhigh is greater than that.
You are correctly updating the value stored in maxhigh whenever high>maxhigh, but you might have missed doing the same for maxHighday when maxhigh>maxHighday.

Adding maxHighday = maxhigh; directly in the line above plot1("high"); should ensure the alert is only fired when there is a new high, but the plot1 would also only appear in this situation.

Regards,

ABCTG


The code here is for an indicator that sets the day resolution and sounds an alert only once when the day's high is greater than the previous day's high.

 
Code
variables:high_1(0),higf_2(0);

high_1=high;
higf_2=high[1];

if high_1>higf_2 then begin
  plot1(open,"open");
  plot2(high,"high");
  plot3(low,"low");
  plot4(close,"close");
  alert("High");
end


else  begin
     Noplot(1);
     Noplot(2);
     Noplot(3);
     Noplot(4);
    
end;
How can I perform the same operation as above with 1 minute resolution?

Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,435 since Apr 2013
Thanks Given: 482
Thanks Received: 1,628

LW11041104,

in that case instead of setting "maxHighday = maxhigh" setting maxHighday to a very large number that is never reached by the market directly in the line above "plot1("high");" should work.
maxHighday = 999999 should usually be enough.

Regards,

ABCTG


LW11041104 View Post
Thank you for your response.

Yes, the alert was output each time the day's high was greater than the previous day's high and the intraday high was updated.

However, I would like the alert to go off only once when the day's high becomes greater than the previous day's high.
Therefore, I do not want an alert to be sounded each time the intraday high is subsequently renewed.


Follow me on Twitter Reply With Quote
  #6 (permalink)
LW11041104
Tokyo,Sapporo
 
Posts: 74 since Jan 2023
Thanks Given: 2
Thanks Received: 3


ABCTG View Post
LW11041104,

in that case instead of setting "maxHighday = maxhigh" setting maxHighday to a very large number that is never reached by the market directly in the line above "plot1("high");" should work.
maxHighday = 999999 should usually be enough.

Regards,

ABCTG


Thank you for your reply.

I replaced maxHighday = 999999 and it seems to have worked.

I may ask for your help again, but I would appreciate it if you could assist me in that case.

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

I think this should work for you:

 
Code
var: maxHighday(high),maxhigh(high);

Vars:
	 MyAlert(true);


	if date[0] <> date[1] then
	begin
		MyAlert = False;
        maxHighday = maxhigh   ;           
        maxhigh = high;
      
  	end
else 
    if high>maxhigh then maxhigh =high; 
        
if maxhigh>maxHighday and Not MyAlert then 
  	begin
       plot1(High,"high");
       If AlertEnabled then alert("high above prior days high: " + GetSymbolName);
       MyAlert = True;
       print(symbol,"  Date = ",date,"  Time = ",Time,"  maxHighday = ",maxHighday,"  maxhigh = ",maxhigh );
 	end;
 
//else 
       //NoPlot(1);

Follow me on Twitter Reply With Quote
  #8 (permalink)
LW11041104
Tokyo,Sapporo
 
Posts: 74 since Jan 2023
Thanks Given: 2
Thanks Received: 3


TraderDoc2 View Post
I think this should work for you:

 
Code
var: maxHighday(high),maxhigh(high);

Vars:
	 MyAlert(true);


	if date[0] <> date[1] then
	begin
		MyAlert = False;
        maxHighday = maxhigh   ;           
        maxhigh = high;
      
  	end
else 
    if high>maxhigh then maxhigh =high; 
        
if maxhigh>maxHighday and Not MyAlert then 
  	begin
       plot1(High,"high");
       If AlertEnabled then alert("high above prior days high: " + GetSymbolName);
       MyAlert = True;
       print(symbol,"  Date = ",date,"  Time = ",Time,"  maxHighday = ",maxHighday,"  maxhigh = ",maxhigh );
 	end;
 
//else 
       //NoPlot(1);


Thank you very much for your reply to my question.

I seem to have solved about the sleaze.

Reply With Quote




Last Updated on August 14, 2023


© 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